diff options
author | Etienne CHAMPETIER <etienne.champetier@free.fr> | 2013-02-05 17:09:34 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2013-04-24 11:23:35 +0200 |
commit | 07d6fd66f6a20e35490bc8b55d26fdb389016120 (patch) | |
tree | 6c29ae686e0a06620b1aa5c38bb530e3e3c43803 /delta.c | |
parent | ef12e67516d224e9cd2ca3fd293dbe5ab385c75a (diff) | |
download | uci-07d6fd66f6a20e35490bc8b55d26fdb389016120.tar.gz |
uci: copy permisions of /etc/config/ files for temp files
Hi
Using uci as a non root user i can get network configuration but not network state (for exemple).
The idea of this patch is to copy permission from config file, or if it doesn't exist use UCI_FILEMODE / UCI_DIRMODE
Tested on tplink wr1043nd. (you have to remove some mkdir from /etc/init.d/boot to fully see this patch work)
If you apply this patch (or a modified version), please also backport to AA
Signed-off-by: Etienne CHAMPETIER <etienne.champetier@free.fr>
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Diffstat (limited to 'delta.c')
-rw-r--r-- | delta.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -425,10 +425,15 @@ int uci_save(struct uci_context *ctx, struct uci_package *p) if (uci_list_empty(&p->delta)) return 0; - if (stat(ctx->savedir, &statbuf) < 0) - mkdir(ctx->savedir, UCI_DIRMODE); - else if ((statbuf.st_mode & S_IFMT) != S_IFDIR) + if (stat(ctx->savedir, &statbuf) < 0) { + if (stat(ctx->confdir, &statbuf) == 0) { + mkdir(ctx->savedir, statbuf.st_mode); + } else { + mkdir(ctx->savedir, UCI_DIRMODE); + } + } else if ((statbuf.st_mode & S_IFMT) != S_IFDIR) { UCI_THROW(ctx, UCI_ERR_IO); + } if ((asprintf(&filename, "%s/%s", ctx->savedir, p->e.name) < 0) || !filename) UCI_THROW(ctx, UCI_ERR_MEM); |