project/uci.git
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

12 years agoadd new command del_list
Luka Perkov [Fri, 9 Nov 2012 10:40:10 +0000 (11:40 +0100)]
add new command del_list

12 years agolua: include /opt/local/lib and /opt/local/include in the search path on mac os x
Felix Fietkau [Thu, 4 Oct 2012 14:04:46 +0000 (16:04 +0200)]
lua: include /opt/local/lib and /opt/local/include in the search path on mac os x

12 years agocli: return non-zero status on errors
Felix Fietkau [Wed, 28 Mar 2012 10:29:09 +0000 (13:29 +0300)]
cli: return non-zero status on errors

12 years agoDo quote section names to keep the same style as option values
Jo-Philipp Wich [Fri, 24 Feb 2012 14:08:34 +0000 (15:08 +0100)]
Do quote section names to keep the same style as option values

12 years agoSection names, option names, list names can only be identifiers, so they don't need...
Jo-Philipp Wich [Fri, 24 Feb 2012 11:24:17 +0000 (12:24 +0100)]
Section names, option names, list names can only be identifiers, so they don't need to be quoted.
Strip quotes except from values.
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
12 years agolua: properly handle corner cases in changes
Jo-Philipp Wich [Tue, 20 Dec 2011 16:06:50 +0000 (17:06 +0100)]
lua: properly handle corner cases in changes
The previous rework of the change serialization caused some deltas to incorrectly
get promoted to list appends. Rework the code to explicitely check for an add list
change type, in all other cases simply overwrite existing fields with the current
string value instead of coercing existing values into a table and append to that.
This hopefully sorts out the remaining issues.

12 years agolua: expose completely new lists in changes() as well
Jo-Philipp Wich [Mon, 19 Dec 2011 18:25:00 +0000 (19:25 +0100)]
lua: expose completely new lists in changes() as well
Since the first delta of a new list is of type UCI_CMD_CHANGE and
not UCI_CMD_LIST_ADD, the current code does not start a new table
and subsequent items are silently disacarded. Expose all items of
new list by coercing the existing string element into a table when
encountering subsequent items.

12 years agoMerge branch 'master' of git://nbd.name/uci
Jo-Philipp Wich [Mon, 19 Dec 2011 18:10:07 +0000 (19:10 +0100)]
Merge branch 'master' of git://nbd.name/uci

13 years agolua: simplify add_list changes handling, always create a table for LIST_ADD commands
Jo-Philipp Wich [Sat, 12 Nov 2011 14:16:31 +0000 (15:16 +0100)]
lua: simplify add_list changes handling, always create a table for LIST_ADD commands

13 years agolua: expose add_list change items as table values
Jo-Philipp Wich [Sat, 12 Nov 2011 13:35:12 +0000 (14:35 +0100)]
lua: expose add_list change items as table values

13 years agolua: simplify add_list changes handling, always create a table for LIST_ADD commands
Jo-Philipp Wich [Sat, 12 Nov 2011 14:16:31 +0000 (15:16 +0100)]
lua: simplify add_list changes handling, always create a table for LIST_ADD commands

13 years agolua: expose add_list change items as table values
Jo-Philipp Wich [Sat, 12 Nov 2011 13:35:12 +0000 (14:35 +0100)]
lua: expose add_list change items as table values

13 years agofix segfault on import of anonymous sections
Felix Fietkau [Fri, 21 Oct 2011 20:48:01 +0000 (22:48 +0200)]
fix segfault on import of anonymous sections

13 years agolua: always return after calling luaL_error (patch by Stanislav Fomichev)
Felix Fietkau [Fri, 21 Oct 2011 13:15:53 +0000 (15:15 +0200)]
lua: always return after calling luaL_error (patch by Stanislav Fomichev)

13 years agocli: check against multiple -f invocations to avoid leaks (patch by Stanislav Fomichev)
Felix Fietkau [Fri, 21 Oct 2011 13:15:24 +0000 (15:15 +0200)]
cli: check against multiple -f invocations to avoid leaks (patch by Stanislav Fomichev)

13 years agoucimap: initialize an uninitialized pointer (patch by Stanislav Fomichev)
Felix Fietkau [Fri, 21 Oct 2011 13:14:30 +0000 (15:14 +0200)]
ucimap: initialize an uninitialized pointer (patch by Stanislav Fomichev)

13 years agoucimap: fix a memory leak (patch by Stanislav Fomichev)
Felix Fietkau [Fri, 21 Oct 2011 13:14:03 +0000 (15:14 +0200)]
ucimap: fix a memory leak (patch by Stanislav Fomichev)

13 years agoadd a few missing null pointer checks, and fix check vs dereference order in some...
Felix Fietkau [Fri, 21 Oct 2011 13:13:32 +0000 (15:13 +0200)]
add a few missing null pointer checks, and fix check vs dereference order in some cases (patch by Stanislav Fomichev)

13 years agocheck result of memory allocations (patch by Stanislav Fomichev)
Felix Fietkau [Fri, 21 Oct 2011 13:12:04 +0000 (15:12 +0200)]
check result of memory allocations (patch by Stanislav Fomichev)

13 years agoucimap: fix use-after-free on cleanup (patch by Stanislav Fomichev)
Felix Fietkau [Fri, 21 Oct 2011 13:09:11 +0000 (15:09 +0200)]
ucimap: fix use-after-free on cleanup (patch by Stanislav Fomichev)

13 years agofree memory for uci hooks
Felix Fietkau [Fri, 23 Sep 2011 13:12:47 +0000 (07:12 -0600)]
free memory for uci hooks

13 years agolua: allow overriding of LUA_CFLAGS
Felix Fietkau [Thu, 15 Sep 2011 14:41:57 +0000 (16:41 +0200)]
lua: allow overriding of LUA_CFLAGS

13 years agolua: use pkg-config to find the correct lua cflags
Felix Fietkau [Thu, 15 Sep 2011 14:39:05 +0000 (16:39 +0200)]
lua: use pkg-config to find the correct lua cflags

13 years agofix lgpl license headers
Felix Fietkau [Wed, 31 Aug 2011 14:55:25 +0000 (16:55 +0200)]
fix lgpl license headers

13 years agofix one more unused-but-set variable
Felix Fietkau [Tue, 19 Jul 2011 20:39:56 +0000 (22:39 +0200)]
fix one more unused-but-set variable

13 years agofix more unused-but-set errors
Felix Fietkau [Mon, 18 Jul 2011 10:05:42 +0000 (12:05 +0200)]
fix more unused-but-set errors

13 years agoremove unused but set variable to fix a compiler warning
Felix Fietkau [Mon, 18 Jul 2011 06:25:27 +0000 (08:25 +0200)]
remove unused but set variable to fix a compiler warning

13 years agodo not attempt to build lua if disabled
Felix Fietkau [Wed, 6 Apr 2011 23:13:57 +0000 (01:13 +0200)]
do not attempt to build lua if disabled

13 years agoconstify arguments to parser function
Felix Fietkau [Tue, 5 Apr 2011 01:33:38 +0000 (03:33 +0200)]
constify arguments to parser function

13 years agoadd parser helpers similar to the blobmsg parser in libubox
Felix Fietkau [Tue, 5 Apr 2011 01:29:17 +0000 (03:29 +0200)]
add parser helpers similar to the blobmsg parser in libubox

13 years agocli: do not return 0 if the command was invalid
Felix Fietkau [Sat, 2 Apr 2011 13:44:34 +0000 (15:44 +0200)]
cli: do not return 0 if the command was invalid

13 years agoalso link the shared libuci to libdl
Felix Fietkau [Sun, 27 Mar 2011 12:52:58 +0000 (14:52 +0200)]
also link the shared libuci to libdl

13 years agofix lua plugin linker error
Felix Fietkau [Sun, 27 Mar 2011 00:47:23 +0000 (01:47 +0100)]
fix lua plugin linker error

13 years agofix building without plugin support
Felix Fietkau [Sat, 26 Mar 2011 22:37:53 +0000 (23:37 +0100)]
fix building without plugin support

13 years agofix include path
Felix Fietkau [Sat, 26 Mar 2011 20:55:03 +0000 (21:55 +0100)]
fix include path

13 years agouse libdl
Felix Fietkau [Sat, 26 Mar 2011 20:53:17 +0000 (21:53 +0100)]
use libdl

13 years agoallow the user to override the lua path
Felix Fietkau [Sat, 26 Mar 2011 20:46:11 +0000 (21:46 +0100)]
allow the user to override the lua path

13 years agomove ucimap to a separate library
Felix Fietkau [Sat, 26 Mar 2011 20:42:30 +0000 (21:42 +0100)]
move ucimap to a separate library

13 years agoreplace the existing build system with cmake
Felix Fietkau [Sat, 26 Mar 2011 20:40:51 +0000 (21:40 +0100)]
replace the existing build system with cmake

13 years agoimprove support for C++ stuff
Felix Fietkau [Tue, 15 Mar 2011 03:05:15 +0000 (04:05 +0100)]
improve support for C++ stuff

13 years agofix uci_list_set_pos to reorder sections properly, even when moving a section to...
Felix Fietkau [Wed, 19 Jan 2011 20:30:35 +0000 (21:30 +0100)]
fix uci_list_set_pos to reorder sections properly, even when moving a section to the last position

13 years agomake uci_file_commit() static
Felix Fietkau [Tue, 28 Dec 2010 17:14:39 +0000 (18:14 +0100)]
make uci_file_commit() static

14 years agolua: use uci_foreach_element_safe in uci_lua_foreach() - patch by jow
Felix Fietkau [Mon, 1 Nov 2010 13:43:00 +0000 (14:43 +0100)]
lua: use uci_foreach_element_safe in uci_lua_foreach() - patch by jow

14 years agoadd a helper function for looking up an option string
Felix Fietkau [Tue, 28 Sep 2010 09:17:23 +0000 (11:17 +0200)]
add a helper function for looking up an option string

14 years agofix return value in inline lookup functions
Felix Fietkau [Tue, 28 Sep 2010 09:12:41 +0000 (11:12 +0200)]
fix return value in inline lookup functions

14 years agoucimap: ucimap_parse: consider smap_offset when allocating the section data
Lars-Peter Clausen [Sat, 21 Aug 2010 00:51:48 +0000 (02:51 +0200)]
ucimap: ucimap_parse: consider smap_offset when allocating the section data

Currently when there is no custom section data allocator the ucimap_section_data
struct has to be at the beginning at the containing structure.
This patch gets rid of that restriction by taking smap_offset into account.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
14 years agoadd convenience functions for looking up packages/sections/options
Felix Fietkau [Sat, 21 Aug 2010 01:17:38 +0000 (03:17 +0200)]
add convenience functions for looking up packages/sections/options

14 years agoremove the unused "complete" parameter for uci_fill_ptr()
Felix Fietkau [Sat, 21 Aug 2010 00:47:25 +0000 (02:47 +0200)]
remove the unused "complete" parameter for uci_fill_ptr()

14 years agoadd support for partial lookups - skip lookup for filled-in sections or packages
Felix Fietkau [Sat, 21 Aug 2010 00:44:32 +0000 (02:44 +0200)]
add support for partial lookups - skip lookup for filled-in sections or packages

14 years agoprovide backwards compatibility in the lua module after the history -> delta change
Felix Fietkau [Fri, 20 Aug 2010 18:45:04 +0000 (20:45 +0200)]
provide backwards compatibility in the lua module after the history -> delta change

14 years agomake uci_lookup_ptr() use the extended flag properly again
Felix Fietkau [Fri, 20 Aug 2010 13:51:07 +0000 (15:51 +0200)]
make uci_lookup_ptr() use the extended flag properly again

14 years agosplit off and compile delta.c separately
Felix Fietkau [Fri, 20 Aug 2010 13:27:22 +0000 (15:27 +0200)]
split off and compile delta.c separately

14 years agouci_history -> uci_delta
Felix Fietkau [Fri, 20 Aug 2010 12:59:27 +0000 (14:59 +0200)]
uci_history -> uci_delta

14 years agosplit off and compile util.c separately
Felix Fietkau [Fri, 20 Aug 2010 12:56:30 +0000 (14:56 +0200)]
split off and compile util.c separately

14 years agoexport uci_parse_ptr
Felix Fietkau [Fri, 20 Aug 2010 12:55:15 +0000 (14:55 +0200)]
export uci_parse_ptr

14 years agosplit off and compile file.c separately
Felix Fietkau [Fri, 20 Aug 2010 12:51:18 +0000 (14:51 +0200)]
split off and compile file.c separately

14 years agosimplify dependency handling
Felix Fietkau [Tue, 17 Aug 2010 11:34:04 +0000 (13:34 +0200)]
simplify dependency handling

14 years agosimplify code (thx, henning)
Felix Fietkau [Sat, 23 Jan 2010 19:55:55 +0000 (20:55 +0100)]
simplify code (thx, henning)

14 years agoFix memory leak in uci_list_config_files
Justin Bronder [Tue, 1 Dec 2009 16:13:41 +0000 (11:13 -0500)]
Fix memory leak in uci_list_config_files

When glob returns non-zero, the path buffer was not unallocated.

14 years agoAllow setting of libdirname.
Justin Bronder [Thu, 18 Jun 2009 17:49:28 +0000 (13:49 -0400)]
Allow setting of libdirname.

Modifies the Makefiles so that the installer can specify the name
of the directory that libraries should be installed into by setting
LIBDIRNAME.  For instance 'lib' or 'lib64'.

15 years agofix compile on snow leopard
Felix Fietkau [Fri, 6 Nov 2009 08:14:58 +0000 (09:14 +0100)]
fix compile on snow leopard

15 years agolua: use extended lookups by default
Felix Fietkau [Wed, 28 Oct 2009 20:13:27 +0000 (21:13 +0100)]
lua: use extended lookups by default

15 years agolua: add uci.foreach() error handling patch by xMff
Felix Fietkau [Mon, 19 Oct 2009 11:33:27 +0000 (13:33 +0200)]
lua: add uci.foreach() error handling patch by xMff

15 years agofix uci_lookup_ptr comments
Felix Fietkau [Thu, 17 Sep 2009 09:27:15 +0000 (11:27 +0200)]
fix uci_lookup_ptr comments

15 years agoadd test/save to .gitignore
Felix Fietkau [Sun, 6 Sep 2009 19:42:17 +0000 (21:42 +0200)]
add test/save to .gitignore

15 years agoucimap: simplify the parse/format callbacks. the data argument now always points...
Felix Fietkau [Sun, 6 Sep 2009 19:40:10 +0000 (21:40 +0200)]
ucimap: simplify the parse/format callbacks. the data argument now always points to the field in the data structure

15 years agoucimap: fix list size initialization, validate list size on fixups as well
Felix Fietkau [Sun, 6 Sep 2009 17:20:01 +0000 (19:20 +0200)]
ucimap: fix list size initialization, validate list size on fixups as well

15 years agoucimap: fix list initialization
Felix Fietkau [Sun, 6 Sep 2009 17:07:21 +0000 (19:07 +0200)]
ucimap: fix list initialization

15 years agoadd some comments to the header file
Felix Fietkau [Sat, 5 Sep 2009 00:51:42 +0000 (02:51 +0200)]
add some comments to the header file

15 years agoreplace the use of list.h in the ucimap core, relicense ucimap to LGPL v2.1, update...
Felix Fietkau [Sat, 5 Sep 2009 00:32:37 +0000 (02:32 +0200)]
replace the use of list.h in the ucimap core, relicense ucimap to LGPL v2.1, update copyright headers

15 years agoremove ucimap type->name conversion unless DEBUG is enabled
Felix Fietkau [Fri, 4 Sep 2009 23:24:40 +0000 (01:24 +0200)]
remove ucimap type->name conversion unless DEBUG is enabled

15 years agofix a typo
Felix Fietkau [Fri, 4 Sep 2009 23:22:37 +0000 (01:22 +0200)]
fix a typo

15 years agoucimap: add support for saving lists to uci
Felix Fietkau [Fri, 4 Sep 2009 23:10:42 +0000 (01:10 +0200)]
ucimap: add support for saving lists to uci

15 years agotest: do not print expected error messages
Felix Fietkau [Fri, 4 Sep 2009 22:45:12 +0000 (00:45 +0200)]
test: do not print expected error messages

15 years agoucimap: add helper function for resizing lists and freeing items (both using ucimap...
Felix Fietkau [Fri, 4 Sep 2009 22:39:41 +0000 (00:39 +0200)]
ucimap: add helper function for resizing lists and freeing items (both using ucimap internal allocation list), add test coverage for config change operations

15 years agoadd sanity checks for optmap section type vs sectionmap type
Felix Fietkau [Fri, 4 Sep 2009 18:07:06 +0000 (20:07 +0200)]
add sanity checks for optmap section type vs sectionmap type

15 years agoucimap: add custom free() callbacks for options, only used on custom datatypes
Felix Fietkau [Fri, 4 Sep 2009 01:59:11 +0000 (03:59 +0200)]
ucimap: add custom free() callbacks for options, only used on custom datatypes