project/uci.git
6 years agocmake: Fix cli shared linking against ubox
Andre Castro [Fri, 2 Feb 2018 12:04:44 +0000 (12:04 +0000)]
cmake: Fix cli shared linking against ubox

The 'ubox' library used in 'cli' target is not using the output of the
'find_library' command. This is a problem when the 'ubox' library is not
located on the standard system library locations.

Use the CMake variable 'ubox', output of 'find_library' call that points
to the library found on the system, instead of hardcoding the library's
name to 'ubox'.

Signed-off-by: Andre Castro <andre.castro.sw@gmail.com>
6 years agolua: additionally return name when looking up sections
Jo-Philipp Wich [Sun, 31 Dec 2017 10:30:32 +0000 (11:30 +0100)]
lua: additionally return name when looking up sections

Return the resolved name in addition to the type when looking up sections
through `get()` - for example a `cursor:get("firewall", "@rule[0]")` will
now return two values in the form ("rule", "cfg0a92bd") instead of only
the type name.

This is mainly useful to resolve extended section names without having to
reimplement the section count logic in Lua code.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
6 years agolua: support extended section notation
Jo-Philipp Wich [Sun, 31 Dec 2017 10:08:22 +0000 (11:08 +0100)]
lua: support extended section notation

Wrap uci_lookup_ptr() to enable extended section format lookups
when the passed section literal is in "@" notation.

This allows calls in the form `cursor:get("conf", "@stype[0]", "opt")`
which is useful to resolve options in numerically indexed anonymous
sections.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
6 years agolist: remove unncessary increment of n_section (FS#1182)
Hans Dedecker [Thu, 21 Dec 2017 10:56:32 +0000 (11:56 +0100)]
list: remove unncessary increment of n_section (FS#1182)

The package n_section counter is already incremented in uci_alloc_section;
so no need to increment it again in uci_fixup_section.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
6 years agofile: remove unnecessary uci_fixup_section calls
Hans Dedecker [Thu, 21 Dec 2017 10:56:31 +0000 (11:56 +0100)]
file: remove unnecessary uci_fixup_section calls

This makes it clear uci_fixup_section only needs to be called in
uci_add_section when an unnamed section is added.

Before it was a bit misleading when walking through the code seeing
uci_fixup_section being called in uci_parse_config and uci_import.
When uci config is parsed via these functions uci_add_section is
eventually called which in the end constructs a name for an unnamed
section.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
7 years agoAdd bitfield_set function from libubox.
Stijn Tintel [Thu, 17 Aug 2017 14:27:20 +0000 (16:27 +0200)]
Add bitfield_set function from libubox.

The bitfield functions and macros where removed from libubox. Add the
bitfield_set function which is used by uci, and prefix it with uci_.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
7 years agofile: remove redundant NULL check on return value of uci_realloc()
Yousong Zhou [Tue, 21 Mar 2017 03:15:12 +0000 (11:15 +0800)]
file: remove redundant NULL check on return value of uci_realloc()

Because the check will be done by uci_realloc itself.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
7 years agobuild: fix BUILD_STATIC
Yousong Zhou [Tue, 21 Mar 2017 03:15:11 +0000 (11:15 +0800)]
build: fix BUILD_STATIC

- Build libuci.a in addition to libuci.so
 - Build uci cli utitlity statically if BUILD_STATIC is enabled

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
8 years agoFix skipping directories in uci_list_config_files
Michal 'vorner' Vaner [Tue, 22 Nov 2016 15:50:24 +0000 (16:50 +0100)]
Fix skipping directories in uci_list_config_files

Don't create a hole in the array of configs if there's a directory. Such
a hole would be mistaken for the end of the array.

Signed-off-by: Michal 'vorner' Vaner <michal.vaner@nic.cz>
8 years agoRevert "mandatory anonymous section identifier"
Felix Fietkau [Thu, 10 Nov 2016 12:13:00 +0000 (13:13 +0100)]
Revert "mandatory anonymous section identifier"

This reverts commits:
df72af474075 "mandatory anonymous section identifier"
2eb9c097e392 "cli: remove now-defunct UCI_FLAG_EXPORT_NAME support"
fe45f97302cb "test: adjust for auto-naming anonymous sections"

After some discussion we came to the conclusion that we need a different
fix.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agouci/lua: add explicit close() method
Dirk Feytons [Thu, 29 Sep 2016 15:39:57 +0000 (17:39 +0200)]
uci/lua: add explicit close() method

This allows a caller to explicitly free the cursor as soon as it is
no longer needed instead of having to wait for the garbage collector.

Signed-off-by: Dirk Feytons <dirk.feytons@gmail.com>
8 years agouci/lua: add list_configs() function
Dirk Feytons [Thu, 29 Sep 2016 15:39:56 +0000 (17:39 +0200)]
uci/lua: add list_configs() function

Returns an array with all the available configs.

Signed-off-by: Dirk Feytons <dirk.feytons@gmail.com>
8 years agotest: adjust for auto-naming anonymous sections
Felix Fietkau [Thu, 6 Oct 2016 18:04:52 +0000 (20:04 +0200)]
test: adjust for auto-naming anonymous sections

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agocli: remove now-defunct UCI_FLAG_EXPORT_NAME support
Felix Fietkau [Thu, 6 Oct 2016 18:02:36 +0000 (20:02 +0200)]
cli: remove now-defunct UCI_FLAG_EXPORT_NAME support

Preserve command line switches for compatibility reasons

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years agomandatory anonymous section identifier
Antonio Paunovic [Thu, 6 Oct 2016 13:47:56 +0000 (15:47 +0200)]
mandatory anonymous section identifier

This change makes sure there are no more anonymous (unnamed) sections
in configuration files. Previously it was optional and now the choice
is being removed.

All sections will have generated identifiers. This is important because
anonymous sections will be simpler to manipulate.

Signed-off-by: Antonio Paunovic <antonio.paunovic@sartura.hr>
Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
8 years agoprojects/uci: lua: use built in pkg-config support for alternatives
Karl Palsson [Fri, 15 Apr 2016 15:12:18 +0000 (15:12 +0000)]
projects/uci: lua: use built in pkg-config support for alternatives

Different distributions have different names for the lua 5.1 package.
Use cmake's built in pkg-config support to search for the first one,
rather than running it explicitly and searching for a single version.

Signed-off-by: Karl Palsson <karlp@remake.is>
8 years agofile: write through symlinks on uci commit
Jo-Philipp Wich [Thu, 31 Mar 2016 00:06:12 +0000 (02:06 +0200)]
file: write through symlinks on uci commit

The rename() syscall operates on the destination path directly, therfore
resolve the real path before doing the rename to not clobber the destination
in case it is a symlink pointing to another file.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
8 years agocmake: Add ubox library and include dir lookup
Petr Štetiar [Sat, 5 Mar 2016 13:59:14 +0000 (14:59 +0100)]
cmake: Add ubox library and include dir lookup

Otherwise cmake uses files from system which sometimes isn't wanted, ie.
for testing.

Signed-off-by: Petr Å tetiar <ynezz@true.cz>
8 years agocli: fix uci show output for anonymous sections (#21781)
Felix Fietkau [Tue, 2 Feb 2016 17:12:54 +0000 (18:12 +0100)]
cli: fix uci show output for anonymous sections (#21781)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 years agofile: raise parse error on conflicting section types in strict mode
Jo-Philipp Wich [Thu, 5 Nov 2015 18:15:40 +0000 (19:15 +0100)]
file: raise parse error on conflicting section types in strict mode

If strict mode is enabled and we're parsing a config file with multiple
sections of the same name but different types, then raise a parse error
to notify the user that the subsequent section declaration would shadow
all prior ones of the same name.

The error would be triggered by a config like that:

  config typeA example
    option test 1

  config typeB example
    option test 2

In such a case, libuci will raise this error:

  uci: Parse error (section of different type overwrites prior section with same name) at line 4, byte 23

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
8 years agofile: defer checking the tmpfile until it is actually needed.
Felix Fietkau [Mon, 11 Jan 2016 12:27:26 +0000 (13:27 +0100)]
file: defer checking the tmpfile until it is actually needed.

Avoids creating useless entries in the kernel dentry cache

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoremove list.h
Felix Fietkau [Wed, 11 Nov 2015 12:17:11 +0000 (13:17 +0100)]
remove list.h

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agolua: remove pointless double check of autoload flag
Karl Palsson [Thu, 5 Nov 2015 17:27:48 +0000 (17:27 +0000)]
lua: remove pointless double check of autoload flag

In e2b1433b the autoload param went from being an enumerated type to a
simple boolean.  Drop the pointless double check of this flag.

Signed-off-by: Karl Palsson <karlp@remake.is>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agolua: fix invocation of foreach() with nil type and implicit self
Jo-Philipp Wich [Thu, 5 Nov 2015 17:47:34 +0000 (18:47 +0100)]
lua: fix invocation of foreach() with nil type and implicit self

The check for nil on the 2nd argument misses the offset in order to skip over
implicit self which results in
  `bad argument #2 to 'foreach' (string expected, got nil)`
when invoking `uci.cursor():foreach("test", nil, function(s) end)`.

The same call works fine when using dot instead of colon notation.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
9 years agofile: remove unnecessary sync() call
Felix Fietkau [Thu, 27 Aug 2015 12:40:57 +0000 (14:40 +0200)]
file: remove unnecessary sync() call

It can be too expensive during filesystem initialization, and it is not
required for atomic handling of config changes.
If the write gets interrupted, the config file will always contain
either the new state or the old state

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agotests: add test case for parsing long option values.
Yousong Zhou [Mon, 25 May 2015 12:32:43 +0000 (20:32 +0800)]
tests: add test case for parsing long option values.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agofile.c: lift the 4096 bytes line length limit.
Yousong Zhou [Mon, 25 May 2015 12:32:42 +0000 (20:32 +0800)]
file.c: lift the 4096 bytes line length limit.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agodelta: catch error when parsing delta line.
Yousong Zhou [Mon, 25 May 2015 12:32:41 +0000 (20:32 +0800)]
delta: catch error when parsing delta line.

Reported by sarumpaet [1]

 [1] uci fails to handle long values properly,
     https://github.com/openwrt/packages/issues/1231

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agocli: suppress printing error messages when -q is specified.
Yousong Zhou [Mon, 25 May 2015 12:32:40 +0000 (20:32 +0800)]
cli: suppress printing error messages when -q is specified.

 - Introduce cli_error() for printing local errors.
 - Convert existing fprintf(stderr, ) and perror() to cli_error().
 - N.B. error messages will still be printed if they occured before -q
   flag was parsed.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agouci: properly close input before exit
Hans Dedecker [Tue, 28 Apr 2015 14:07:27 +0000 (16:07 +0200)]
uci: properly close input before exit

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agofile: reset parsing position on starting over a newline.
Yousong Zhou [Thu, 9 Apr 2015 13:48:47 +0000 (21:48 +0800)]
file: reset parsing position on starting over a newline.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agotests: add test coverage for comment lines within batch commands.
Yousong Zhou [Thu, 9 Apr 2015 13:48:46 +0000 (21:48 +0800)]
tests: add test coverage for comment lines within batch commands.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agodelta: fix adding new savedir.
Yousong Zhou [Wed, 1 Apr 2015 12:44:23 +0000 (20:44 +0800)]
delta: fix adding new savedir.

Newly added savedir should be at the last position while
uci_add_delta_path() will add it to the position second to the last.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agotests: add test coverage for uci export with -P option.
Yousong Zhou [Wed, 1 Apr 2015 12:44:22 +0000 (20:44 +0800)]
tests: add test coverage for uci export with -P option.

 - With "uci -P xxx/ export", changes in "xxx/" should be applied last.
 - With "uci -p xxx/ commit", changes in "xxx/" should be applied before
   ctx->savedir.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agoFix delta path handling.
Yousong Zhou [Tue, 31 Mar 2015 16:20:18 +0000 (00:20 +0800)]
Fix delta path handling.

 - Make ctx->savedir sit at the end of ctx->delta_path.
 - Add notes to uci_set_savedir() and uci_add_delta_path() to document
   the behaviour changes.

9 years agotests: add test cases for -P and -p options.
Yousong Zhou [Tue, 31 Mar 2015 16:20:17 +0000 (00:20 +0800)]
tests: add test cases for -P and -p options.

9 years agolua: restore return value of require('uci') to module table.
Yousong Zhou [Wed, 18 Mar 2015 04:44:45 +0000 (12:44 +0800)]
lua: restore return value of require('uci') to module table.

Before commit "b121dd lua: add lua 5.2 compatibility changes", the
module table was filled by luaL_register() which would leave the table
at the top of the stack.  But in current code the module table will be
popped by lua_setglobal() causing the return value defaulting to boolean
value true.

Also fix the return value of luaopen_uci() to 1 to indicate the number
of return value on stack.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agocli: fix return value of package_cmd().
Yousong Zhou [Wed, 18 Mar 2015 04:44:44 +0000 (12:44 +0800)]
cli: fix return value of package_cmd().

It's a bug revealed by commit 446e774 "cli: properly unload package
before quit".  The current code would exit with value 1 even if
uci_export() succceeded.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agotestenv: test for exit status of "uci export".
Yousong Zhou [Wed, 18 Mar 2015 04:44:43 +0000 (12:44 +0800)]
testenv: test for exit status of "uci export".

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agoAdd a few notes on the return value of uci_lookup_ptr().
Yousong Zhou [Sat, 24 Jan 2015 15:07:53 +0000 (23:07 +0800)]
Add a few notes on the return value of uci_lookup_ptr().

While at it, use UCI_OK instead of literal integer 0 for return value of
uci_lookup_ptr().

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agocli: enhance "uci show" command on nonexistent sections and options.
Yousong Zhou [Sat, 24 Jan 2015 15:07:52 +0000 (23:07 +0800)]
cli: enhance "uci show" command on nonexistent sections and options.

When doing "uci show network.nilsection", the current behaviour is that
uci will emit a error message complaining "Entry not found", then
continue to show all content of the package network itself.  This is
couter-intuition.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agocli: properly unload package before quit.
Yousong Zhou [Sat, 24 Jan 2015 15:07:51 +0000 (23:07 +0800)]
cli: properly unload package before quit.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
9 years agotests: add test cases for showing nonexistent section and option.
Yousong Zhou [Sat, 24 Jan 2015 15:07:50 +0000 (23:07 +0800)]
tests: add test cases for showing nonexistent section and option.

Also fix the false error message about absence of uci-static.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agolua: add lua 5.2 compatibility changes
Felix Fietkau [Thu, 18 Dec 2014 15:49:16 +0000 (16:49 +0100)]
lua: add lua 5.2 compatibility changes

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoallow "-" in package names
Felix Fietkau [Thu, 18 Dec 2014 14:19:47 +0000 (15:19 +0100)]
allow "-" in package names

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agodelta: fix outputing of delta entries occupying multiple lines.
Yousong Zhou [Tue, 16 Dec 2014 07:00:17 +0000 (15:00 +0800)]
delta: fix outputing of delta entries occupying multiple lines.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agodelta: use a table for converting between UCI_CMD_XXX and prefixes.
Yousong Zhou [Tue, 16 Dec 2014 07:00:16 +0000 (15:00 +0800)]
delta: use a table for converting between UCI_CMD_XXX and prefixes.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agodelta: preprocess delta line with uci_parse_argument().
Yousong Zhou [Tue, 16 Dec 2014 07:00:15 +0000 (15:00 +0800)]
delta: preprocess delta line with uci_parse_argument().

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agodelta: add a simple duplication check when adding delta path.
Yousong Zhou [Tue, 16 Dec 2014 07:00:14 +0000 (15:00 +0800)]
delta: add a simple duplication check when adding delta path.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agocli: fix printing option values occupying multiple lines.
Yousong Zhou [Tue, 16 Dec 2014 07:00:13 +0000 (15:00 +0800)]
cli: fix printing option values occupying multiple lines.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agotests: add test coverage for uci list related commands.
Yousong Zhou [Tue, 16 Dec 2014 07:00:12 +0000 (15:00 +0800)]
tests: add test coverage for uci list related commands.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agotests: add test coverage for `uci revert' command.
Yousong Zhou [Tue, 16 Dec 2014 07:00:11 +0000 (15:00 +0800)]
tests: add test coverage for `uci revert' command.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agotests: add test coverage for `uci batch' command.
Yousong Zhou [Tue, 16 Dec 2014 07:00:10 +0000 (15:00 +0800)]
tests: add test coverage for `uci batch' command.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agotests: add more test coverage for `uci show' command.
Yousong Zhou [Tue, 16 Dec 2014 07:00:09 +0000 (15:00 +0800)]
tests: add more test coverage for `uci show' command.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agotests: remove straying echo in 020_get.
Yousong Zhou [Tue, 16 Dec 2014 07:00:08 +0000 (15:00 +0800)]
tests: remove straying echo in 020_get.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agofile: fix error string about "unterminated XXX".
Yousong Zhou [Tue, 16 Dec 2014 07:00:07 +0000 (15:00 +0800)]
file: fix error string about "unterminated XXX".

 - Remove unreachable call to uci_parse_error().
 - Fix false claim of unterminated double quote to single quote.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agofile: fix EOF check.
Yousong Zhou [Tue, 16 Dec 2014 07:00:06 +0000 (15:00 +0800)]
file: fix EOF check.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agofile: fix use-after-free bug.
Yousong Zhou [Tue, 16 Dec 2014 07:00:05 +0000 (15:00 +0800)]
file: fix use-after-free bug.

Currently, it's possible that pointers returned by next_arg() could be
invalidated by another call to next_arg() due to uci_realloc().

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agoFix memory leaks found by using valgrind on test cases.
Yousong Zhou [Tue, 16 Dec 2014 07:00:04 +0000 (15:00 +0800)]
Fix memory leaks found by using valgrind on test cases.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agoFix a few style issues.
Yousong Zhou [Tue, 16 Dec 2014 07:00:03 +0000 (15:00 +0800)]
Fix a few style issues.

 - Remove deprecated uci-static and ucimap-example from .gitignore.
 - Minor code formatting fix.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agofix a few formatting issues
Felix Fietkau [Tue, 25 Nov 2014 10:54:09 +0000 (11:54 +0100)]
fix a few formatting issues

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agotests: use uci instead of uci-static
Felix Fietkau [Tue, 25 Nov 2014 10:50:25 +0000 (11:50 +0100)]
tests: use uci instead of uci-static

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoAdd test coverage for multi-line option value.
Yousong Zhou [Thu, 6 Nov 2014 20:21:48 +0000 (04:21 +0800)]
Add test coverage for multi-line option value.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agoUse offset into parser buffer to avoid potential heap overflow.
Yousong Zhou [Thu, 6 Nov 2014 20:21:47 +0000 (04:21 +0800)]
Use offset into parser buffer to avoid potential heap overflow.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agoSync ref test result with current implementation.
Yousong Zhou [Thu, 6 Nov 2014 20:21:46 +0000 (04:21 +0800)]
Sync ref test result with current implementation.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agoDrop test cases for deprecated ucimap-example.
Yousong Zhou [Thu, 6 Nov 2014 20:21:45 +0000 (04:21 +0800)]
Drop test cases for deprecated ucimap-example.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
10 years agoPreserve original permissions when rewriting config files on commit
Jo-Philipp Wich [Fri, 11 Apr 2014 16:02:51 +0000 (18:02 +0200)]
Preserve original permissions when rewriting config files on commit

Patch provided by Patrick Grimm <patrick@lunatiki.de>

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
10 years agouci: fix Lua finding
Yegor Yefremov [Sun, 6 Apr 2014 19:41:32 +0000 (21:41 +0200)]
uci: fix Lua finding

If ${LUAPATH} is not quoted and Lua is not provided, then following
error occurs:

"NOT" "No such file or directory" "EQUAL" "0" "OR" "EQUAL" ""

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
10 years agofix `uci import` with not yet existing packages
Alexander Couzens [Wed, 19 Mar 2014 12:50:01 +0000 (13:50 +0100)]
fix `uci import` with not yet existing packages

uci_file_commit() tries to open and lock a package file (e.g.
/etc/config/system)
before writing into. When the package file doesn't exist, uci fails with
'Entry not found'.

10 years agoblob: add support for u64
Steven Barth [Tue, 18 Feb 2014 09:15:49 +0000 (10:15 +0100)]
blob: add support for u64

10 years agouci_blob: add an element to uci_blob_param_list to allow the tracking of validation...
John Crispin [Mon, 17 Feb 2014 12:15:17 +0000 (12:15 +0000)]
uci_blob: add an element to uci_blob_param_list to allow the tracking of validation info

Signed-off-by: John Crispin <blogic@openwrt.org>
11 years agoblob: use BLOBMSG_TYPE_STRING as a fallback type for arrays if no type was specified
Felix Fietkau [Mon, 2 Dec 2013 10:11:21 +0000 (11:11 +0100)]
blob: use BLOBMSG_TYPE_STRING as a fallback type for arrays if no type was specified

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoremove ucimap-example, as ucimap is deprecated
Felix Fietkau [Mon, 2 Dec 2013 07:36:33 +0000 (08:36 +0100)]
remove ucimap-example, as ucimap is deprecated

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoblob: allow values to be added to blobmsg using multiple different types, but suppres...
Felix Fietkau [Mon, 4 Nov 2013 15:43:49 +0000 (16:43 +0100)]
blob: allow values to be added to blobmsg using multiple different types, but suppress duplicates

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoucimap: get rid of duplicate initialization warnings
Felix Fietkau [Tue, 29 Oct 2013 15:50:47 +0000 (16:50 +0100)]
ucimap: get rid of duplicate initialization warnings

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoparse: remove a check that is always true (due to unsigned data type)
Felix Fietkau [Tue, 29 Oct 2013 15:48:23 +0000 (16:48 +0100)]
parse: remove a check that is always true (due to unsigned data type)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agofile: add missing return code check for mktemp()
Felix Fietkau [Thu, 24 Oct 2013 21:25:02 +0000 (23:25 +0200)]
file: add missing return code check for mktemp()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agofile: fix memleak on mktemp() errors
Felix Fietkau [Thu, 24 Oct 2013 21:24:32 +0000 (23:24 +0200)]
file: fix memleak on mktemp() errors

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agostyle: fix whitespace errors
Luka Perkov [Tue, 15 Oct 2013 10:57:14 +0000 (12:57 +0200)]
style: fix whitespace errors

Signed-off-by: Luka Perkov <luka@openwrt.org>
11 years agostyle: free(NULL) is perfectly valid so we can drop some checks
Luka Perkov [Tue, 15 Oct 2013 10:44:19 +0000 (12:44 +0200)]
style: free(NULL) is perfectly valid so we can drop some checks

Signed-off-by: Luka Perkov <luka@openwrt.org>
11 years agofile: make uci commits atomic
Luka Perkov [Thu, 10 Oct 2013 14:48:07 +0000 (16:48 +0200)]
file: make uci commits atomic

Avoids issues with UBIFS file system.

http://www.linux-mtd.infradead.org/faq/ubifs.html#L_atomic_change

Signed-off-by: Luka Perkov <luka@openwrt.org>
Reported-by: Tim Harvey <tharvey@gateworks.com>
11 years agouci_delete: check ptr->o and its type before checking ptr->value
Felix Fietkau [Sun, 29 Sep 2013 11:20:34 +0000 (13:20 +0200)]
uci_delete: check ptr->o and its type before checking ptr->value

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agouci: fix excessive reorder delta entry duplication
Felix Fietkau [Tue, 11 Jun 2013 12:50:57 +0000 (14:50 +0200)]
uci: fix excessive reorder delta entry duplication

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoblob: add uci<->blob conversion library code
Felix Fietkau [Mon, 10 Jun 2013 12:00:02 +0000 (14:00 +0200)]
blob: add uci<->blob conversion library code

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoutil: fix compile error
Felix Fietkau [Mon, 10 Jun 2013 11:19:45 +0000 (13:19 +0200)]
util: fix compile error

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agolua: emit a proper deletion when setting an existing list to a new list with only...
Jo-Philipp Wich [Sun, 26 May 2013 16:55:20 +0000 (18:55 +0200)]
lua: emit a proper deletion when setting an existing list to a new list with only a single item

11 years agouci: Fix uci_delete() when ptr->value is empty string
Krzysztof Kuźnik [Thu, 28 Feb 2013 13:44:00 +0000 (13:44 +0000)]
uci: Fix uci_delete() when ptr->value is empty string

After fix for deleting list elements by index this function was
broken and didn't allow to invoke from command line:
uci set some.fancy.list=''
i.e. list wasn't cleared

Signed-off-by: Krzysztof Kuźnik <k.kuznik@avsystem.com>
11 years agouci: copy permisions of /etc/config/ files for temp files
Etienne CHAMPETIER [Tue, 5 Feb 2013 17:09:34 +0000 (17:09 +0000)]
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

11 years agoChange delta encoding of list deletions
Jo-Philipp Wich [Mon, 22 Apr 2013 13:50:08 +0000 (15:50 +0200)]
Change delta encoding of list deletions

When encoding list_del commands in delta files, '_' is used as prefix but this
breaks any command operating on files starting with an underscore since the
command prefix becomes indistinguishable from the filename.

The regression was introduced with ec8cbbbe0f20e67cbd3bd471b9ac55ceacaef7b8.

Avoid this problem by using '~' as command prefix for list deletions.

11 years agoAdd multiple free for each call to lookup_args()
Jérôme Poulin [Wed, 6 Feb 2013 18:10:17 +0000 (18:10 +0000)]
Add multiple free for each call to lookup_args()

This memory leak can be reproduced using a tight loop to uci:get() a config.

lua -e 'require("posix"); require("uci");
function getconf()
   local tmp, uc = uci.cursor();
   tmp = uc:get("system", "ntp", "enable_server");
end;

while 1
do
   for i=0,1000 do getconf() end;
   print("gc");
   print(collectgarbage("count"));
   collectgarbage();
   print(collectgarbage("count"));
   print("sleep 1");
   posix.sleep(1);
end'

11 years agouci: libuci leaking memory on non-existent config file
Krzysztof Kuznik [Wed, 22 Aug 2012 08:11:23 +0000 (10:11 +0200)]
uci: libuci leaking memory on non-existent config file

In file file.c function uci_file_load() allocates memory for filename.
When uci_open_stream() failed with exception this memory was never freed.
This patch makes call to uci_open_stream() wrapped in exception handling
inside uci_file_load() where filename is freed.

Signed-off-by: Krzysztof Kuznik <k.kuznik@avsystem.com>
11 years agoignore trailing carriage returns in file parser
Jo-Philipp Wich [Tue, 5 Mar 2013 14:48:04 +0000 (15:48 +0100)]
ignore trailing carriage returns in file parser

11 years agoadd main directory to include path
Thomas Gstädtner [Sun, 3 Mar 2013 15:20:13 +0000 (16:20 +0100)]
add main directory to include path

11 years agobuild: remove install prefix override
Felix Fietkau [Wed, 23 Jan 2013 14:21:53 +0000 (15:21 +0100)]
build: remove install prefix override

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoget rid of -rdynamic on link
Felix Fietkau [Fri, 4 Jan 2013 16:24:35 +0000 (17:24 +0100)]
get rid of -rdynamic on link

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoremove unused hook support
Felix Fietkau [Fri, 4 Jan 2013 16:16:41 +0000 (17:16 +0100)]
remove unused hook support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoremove the libdl dependency
Felix Fietkau [Fri, 4 Jan 2013 16:12:39 +0000 (17:12 +0100)]
remove the libdl dependency

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoremove plugin support, it has been unused for a long time and should not be used...
Felix Fietkau [Fri, 4 Jan 2013 16:07:59 +0000 (17:07 +0100)]
remove plugin support, it has been unused for a long time and should not be used for any new code

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoremove static libraries/binaries
Felix Fietkau [Mon, 31 Dec 2012 15:56:27 +0000 (16:56 +0100)]
remove static libraries/binaries

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
12 years agoextend delete command so it can delete list elemets using index
Luka Perkov [Fri, 9 Nov 2012 10:44:11 +0000 (11:44 +0100)]
extend delete command so it can delete list elemets using index