diff options
author | Felix Fietkau <nbd@openwrt.org> | 2015-06-24 18:28:37 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2015-06-24 18:28:37 +0200 |
commit | e59b44573423ad608d0752b46a6073222db9ed45 (patch) | |
tree | fd40d30ac66f404fe6f0f4418707b238a244f216 /ubusd_acl.c | |
parent | b2e629a4e915e68acba129a5e00480e255ebc164 (diff) | |
download | ubus-e59b44573423ad608d0752b46a6073222db9ed45.tar.gz |
ubusd: fix build on non-linux systems without peercred support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'ubusd_acl.c')
-rw-r--r-- | ubusd_acl.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ubusd_acl.c b/ubusd_acl.c index 31f8b45..3c16114 100644 --- a/ubusd_acl.c +++ b/ubusd_acl.c @@ -28,6 +28,14 @@ #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) |