Go to the source code of this file.
◆ ubusd_acl_type
Enumerator |
---|
UBUS_ACL_PUBLISH | |
UBUS_ACL_SUBSCRIBE | |
UBUS_ACL_ACCESS | |
UBUS_ACL_LISTEN | |
UBUS_ACL_SEND | |
Definition at line 17 of file ubusd_acl.h.
◆ ubusd_acl_check()
Definition at line 90 of file ubusd_acl.c.
96 if (!cl || !cl->
uid || !obj)
106 const char *key = acl->
avl.key;
111 if (cur_match_len < match_len)
114 match_len = cur_match_len;
120 if (match_len != (
int) strlen(key))
150 struct blob_attr *cur;
154 blobmsg_for_each_attr(cur, acl->
methods, rem)
155 if (blobmsg_type(cur) == BLOBMSG_TYPE_STRING) {
156 cur_method = blobmsg_get_string(cur);
158 if (!strcmp(method, cur_method) || !strcmp(
"*", cur_method))
struct blob_attr * methods
static bool ubus_strmatch_len(const char *s1, const char *s2, int *len)
static struct avl_tree ubusd_acls
static int ubusd_acl_match_cred(struct ubus_client *cl, struct ubusd_acl_obj *obj)
◆ ubusd_acl_free_client()
◆ ubusd_acl_init_client()
int ubusd_acl_init_client |
( |
struct ubus_client * |
cl, |
|
|
int |
fd |
|
) |
| |
Definition at line 170 of file ubusd_acl.c.
177 unsigned int len =
sizeof(
struct ucred);
179 if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) == -1) {
180 ULOG_ERR(
"Failed getsockopt(): %m\n");
184 memset(&cred, 0,
sizeof(cred));
187 pwd = getpwuid(cred.uid);
189 ULOG_ERR(
"Failed getpwuid(): %m\n");
193 group = getgrgid(cred.gid);
195 ULOG_ERR(
"Failed getgrgid(): %m\n");
202 cl->
group = strdup(group->gr_name);
203 cl->
user = strdup(pwd->pw_name);
◆ ubusd_acl_load()
void ubusd_acl_load |
( |
void |
| ) |
|
Definition at line 445 of file ubusd_acl.c.
450 const char *suffix =
"/*.json";
454 if (glob(
path, GLOB_NOESCAPE | GLOB_MARK, NULL, &gl))
457 vlist_update(&ubusd_acl_files);
458 for (j = 0; j < gl.gl_pathc; j++) {
459 if (stat(gl.gl_pathv[j], &st) || !S_ISREG(st.st_mode))
462 if (st.st_uid || st.st_gid) {
463 syslog(LOG_ERR,
"%s has wrong owner\n", gl.gl_pathv[j]);
466 if (st.st_mode & (S_IWOTH | S_IWGRP | S_IXOTH)) {
467 syslog(LOG_ERR,
"%s has wrong permissions\n", gl.gl_pathv[j]);
474 vlist_flush(&ubusd_acl_files);
int ubusd_send_event(struct ubus_client *cl, const char *id, event_fill_cb fill_cb, void *cb_priv)
const char * ubusd_acl_dir
static int ubusd_acl_load_file(const char *filename)
static struct ubus_msg_buf * ubusd_create_sequence_event_msg(void *priv, const char *id)