X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fubus.git;a=blobdiff_plain;f=ubusd_acl.c;h=4d047b7a240e9fb3454a12a6b931a60a39bd06ee;hp=31f8b45f1a7b5558d3ff59f510486b154df75650;hb=7ec9b8dec77b969bfc860995f96fe91fd40ba5e4;hpb=8309c75828acbcee73b11d9ce90d76b7ef14b891 diff --git a/ubusd_acl.c b/ubusd_acl.c index 31f8b45..4d047b7 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; @@ -92,7 +100,7 @@ ubusd_acl_check(struct ubus_client *cl, const char *obj, struct blob_attr *cur; int rem; - if (!cl->gid && !cl->gid) + if (!cl->gid && !cl->uid) return 0; acl = avl_find_ge_element(&ubusd_acls, obj, acl, avl); @@ -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)