ubusd: make ACL path configurable on the command line
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
parent
152dd96f63
commit
83461b9791
3 changed files with 12 additions and 2 deletions
6
ubusd.c
6
ubusd.c
|
@ -356,6 +356,7 @@ static int usage(const char *progname)
|
|||
{
|
||||
fprintf(stderr, "Usage: %s [<options>]\n"
|
||||
"Options: \n"
|
||||
" -A <path>: Set the path to ACL files\n"
|
||||
" -s <socket>: Set the unix domain socket to listen on\n"
|
||||
"\n", progname);
|
||||
return 1;
|
||||
|
@ -378,11 +379,14 @@ int main(int argc, char **argv)
|
|||
openlog("ubusd", LOG_PID, LOG_DAEMON);
|
||||
uloop_init();
|
||||
|
||||
while ((ch = getopt(argc, argv, "s:")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "A:s:")) != -1) {
|
||||
switch (ch) {
|
||||
case 's':
|
||||
ubus_socket = optarg;
|
||||
break;
|
||||
case 'A':
|
||||
ubusd_acl_dir = optarg;
|
||||
break;
|
||||
default:
|
||||
return usage(argv[0]);
|
||||
}
|
||||
|
|
2
ubusd.h
2
ubusd.h
|
@ -64,6 +64,8 @@ struct ubus_path {
|
|||
const char name[];
|
||||
};
|
||||
|
||||
extern const char *ubusd_acl_dir;
|
||||
|
||||
struct ubus_msg_buf *ubus_msg_new(void *data, int len, bool shared);
|
||||
void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub, bool free);
|
||||
void ubus_msg_free(struct ubus_msg_buf *ub);
|
||||
|
|
|
@ -62,6 +62,7 @@ struct ubusd_acl_file {
|
|||
int ok;
|
||||
};
|
||||
|
||||
const char *ubusd_acl_dir = "/usr/share/acl.d";
|
||||
static struct blob_buf bbuf;
|
||||
static struct avl_tree ubusd_acls;
|
||||
static int ubusd_acl_seq;
|
||||
|
@ -379,8 +380,11 @@ ubusd_acl_load(void)
|
|||
struct stat st;
|
||||
glob_t gl;
|
||||
int j;
|
||||
const char *suffix = "/*.json";
|
||||
char *path = alloca(strlen(ubusd_acl_dir) + strlen(suffix) + 1);
|
||||
|
||||
if (glob("/usr/share/acl.d/*.json", GLOB_NOESCAPE | GLOB_MARK, NULL, &gl))
|
||||
sprintf(path, "%s%s", ubusd_acl_dir, suffix);
|
||||
if (glob(path, GLOB_NOESCAPE | GLOB_MARK, NULL, &gl))
|
||||
return;
|
||||
|
||||
vlist_update(&ubusd_acl_files);
|
||||
|
|
Loading…
Add table
Reference in a new issue