diff options
author | Felix Fietkau <nbd@openwrt.org> | 2008-08-18 18:49:28 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2008-08-18 18:49:28 +0200 |
commit | 672d68a8765c242dd939a31b520acbe1c9c1d7c2 (patch) | |
tree | e02f9100bb64951c260f2de76d6e72e123b440aa | |
parent | 5a275e5558a70a2f3b0e88dd66117acf8cdf61f6 (diff) | |
download | uci-672d68a8765c242dd939a31b520acbe1c9c1d7c2.tar.gz |
fix lookup for section commands in the cli
-rw-r--r-- | cli.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -329,10 +329,12 @@ static int uci_do_section_cmd(int cmd, int argc, char **argv) struct uci_section *s = NULL; struct uci_element *e = NULL; struct uci_option *o = NULL; + char *package = NULL; char *section = NULL; char *option = NULL; char *value = NULL; int ret = UCI_OK; + char *str; if (argc != 2) return 255; @@ -345,9 +347,20 @@ static int uci_do_section_cmd(int cmd, int argc, char **argv) return 1; } + str = strdup(argv[1]); + if (!str) + return 1; + if (value && (cmd != CMD_SET) && (cmd != CMD_ADD_LIST) && (cmd != CMD_RENAME)) return 1; + if (uci_parse_tuple(ctx, str, &package, §ion, &option, NULL) != UCI_OK) { + cli_perror(); + return 1; + } + sprintf(argv[1], "%s.%s", package, section); + free(str); + if (uci_lookup_ext(ctx, &e, argv[1]) != UCI_OK) { cli_perror(); return 1; |