diff options
author | José Bollo <jose.bollo@iot.bzh> | 2017-04-12 14:11:16 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2017-04-12 16:59:51 +0200 |
commit | a05138e6bf1257b0e7b1ad90c974fb9e12f1d040 (patch) | |
tree | d9f546535b58f7b10ec845b2ec2624602388cba7 /src/afb-api-ws.c | |
parent | 43d031e1833c5d373600cf44c05d760ade9a150d (diff) |
Add computation of credentials
Credentials are computed if possible.
Change-Id: I36c7e95a35431b27109c26b51eab690d685862e1
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-api-ws.c')
-rw-r--r-- | src/afb-api-ws.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/afb-api-ws.c b/src/afb-api-ws.c index 4b870d45..8be74c03 100644 --- a/src/afb-api-ws.c +++ b/src/afb-api-ws.c @@ -38,6 +38,7 @@ #include "afb-common.h" #include "afb-session.h" +#include "afb-cred.h" #include "afb-ws.h" #include "afb-msg-json.h" #include "afb-apis.h" @@ -125,6 +126,9 @@ struct api_ws_client /* websocket */ struct afb_ws *ws; + + /* credentials */ + struct afb_cred *cred; }; /******************* websocket interface for client part **********************************/ @@ -903,6 +907,7 @@ static void api_ws_server_client_unref(struct api_ws_client *client) if (!--client->refcount) { afb_evt_listener_unref(client->listener); afb_ws_destroy(client->ws); + afb_cred_unref(client->cred); free(client); } } @@ -994,6 +999,7 @@ static void api_ws_server_accept(struct api_ws *api) lenaddr = (socklen_t)sizeof addr; client->fd = accept(api->fd, &addr, &lenaddr); if (client->fd >= 0) { + client->cred = afb_cred_create_for_socket(client->fd); fcntl(client->fd, F_SETFD, FD_CLOEXEC); fcntl(client->fd, F_SETFL, O_NONBLOCK); client->ws = afb_ws_create(afb_common_get_event_loop(), client->fd, &api_ws_server_ws_itf, client); @@ -1002,6 +1008,7 @@ static void api_ws_server_accept(struct api_ws *api) client->refcount = 1; return; } + afb_cred_unref(client->cred); close(client->fd); } afb_evt_listener_unref(client->listener); |