ubusd: fix build on non-linux systems without peercred support
authorFelix Fietkau <nbd@openwrt.org>
Wed, 24 Jun 2015 16:28:37 +0000 (18:28 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 24 Jun 2015 16:28:37 +0000 (18:28 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ubusd_acl.c

index 31f8b45f1a7b5558d3ff59f510486b154df75650..3c16114e57eb6b3303f2d493eb51a691c3cf1292 100644 (file)
 
 #include "ubusd.h"
 
+#ifndef SO_PEERCRED
+struct ucred {
+       int pid;
+       int uid;
+       int gid;
+};
+#endif
+
 struct ubusd_acl_obj {
        struct avl_node avl;
        struct list_head list;
@@ -135,13 +143,18 @@ ubusd_acl_check(struct ubus_client *cl, const char *obj,
 int
 ubusd_acl_init_client(struct ubus_client *cl, int fd)
 {
-       unsigned int len = sizeof(struct ucred);
        struct ucred cred;
        struct passwd *pwd;
        struct group *group;
 
+#ifdef SO_PEERCRED
+       unsigned int len = sizeof(struct ucred);
+
        if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) == -1)
                return -1;
+#else
+       memset(&cred, 0, sizeof(cred));
+#endif
 
        pwd = getpwuid(cred.uid);
        if (!pwd)