afb-autoset: Automatic prefix with unix: 19/14619/1
authorJosé Bollo <jose.bollo@iot.bzh>
Fri, 22 Jun 2018 16:24:46 +0000 (18:24 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Fri, 22 Jun 2018 16:24:46 +0000 (18:24 +0200)
Change-Id: I325d768b3bdfcb313b57e1752cbc156b3735b55a
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afb-autoset.c

index b8f8a2e..f43b011 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <stdlib.h>
 #include <stdint.h>
+#include <stdio.h>
+#include <limits.h>
 #include <string.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -113,6 +115,7 @@ static int create_any(const char *path, struct afb_apiset *declare_set, struct a
 {
        int rc;
        struct stat st;
+       char sockname[PATH_MAX + 7];
 
        rc = stat(path, &st);
        if (!rc) {
@@ -121,7 +124,8 @@ static int create_any(const char *path, struct afb_apiset *declare_set, struct a
                        rc = afb_api_so_add_binding(path, declare_set, call_set);
                        break;
                case S_IFSOCK:
-                       rc = afb_api_ws_add_client(path, declare_set, call_set, 0);
+                       snprintf(sockname, sizeof sockname, "unix:%s", path);
+                       rc = afb_api_ws_add_client(sockname, declare_set, call_set, 0);
                        break;
                default:
                        NOTICE("Unexpected autoset entry: %s", path);