From 83461b97917d5a6a49357e9c981a9de840af5b6e Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 9 Dec 2015 17:44:00 +0100 Subject: [PATCH] ubusd: make ACL path configurable on the command line Signed-off-by: Felix Fietkau --- ubusd.c | 6 +++++- ubusd.h | 2 ++ ubusd_acl.c | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ubusd.c b/ubusd.c index 6629720..f1f8ac7 100644 --- a/ubusd.c +++ b/ubusd.c @@ -356,6 +356,7 @@ static int usage(const char *progname) { fprintf(stderr, "Usage: %s []\n" "Options: \n" + " -A : Set the path to ACL files\n" " -s : 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]); } diff --git a/ubusd.h b/ubusd.h index 6078e02..5031ed4 100644 --- a/ubusd.h +++ b/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); diff --git a/ubusd_acl.c b/ubusd_acl.c index e5a7b56..dbfa83a 100644 --- a/ubusd_acl.c +++ b/ubusd_acl.c @@ -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); -- 2.30.2