project/ubus.git
8 years agolibubus.h: marking unused variables
Emanuel Taube [Fri, 12 Feb 2016 12:28:12 +0000 (13:28 +0100)]
libubus.h: marking unused variables

Inform the compiler that the variables are not gona be used to avoid
compiler warnings.

Signed-off-by: Emanuel Taube <emanuel.taube@gmail.com>
8 years agolibubus.h: add ubus_auto_shutdown()
Ben Kelly [Tue, 2 Feb 2016 13:02:59 +0000 (15:02 +0200)]
libubus.h: add ubus_auto_shutdown()

Add ubus_auto_shutdown function, which ensures any pending uloop_timer is cancelled before calling ubus_shutdown on the context.

This avoids a condition where ubus_shutdown() is called during ubus_auto_connect attempting a reconnection.

Signed-off-by: Ben Kelly <ben@benjii.net>
8 years agoubusd: fix a memory leak on user/group client info
Felix Fietkau [Tue, 26 Jan 2016 09:10:39 +0000 (10:10 +0100)]
ubusd: fix a memory leak on user/group client info

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 years agolua: fix stack leak in ubus method handling
Felix Fietkau [Wed, 20 Jan 2016 13:59:04 +0000 (14:59 +0100)]
lua: fix stack leak in ubus method handling

Signed-off-by: Chen Bin <ewolfok@126.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
8 years agoubusd: add missing NULL pointer checks for ACL processing
Felix Fietkau [Wed, 13 Jan 2016 11:28:37 +0000 (12:28 +0100)]
ubusd: add missing NULL pointer checks for ACL processing

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agolibubus: add null for ubus_context object in ubus_shutdown()
Alexandru Ardelean [Thu, 17 Dec 2015 08:45:22 +0000 (10:45 +0200)]
libubus: add null for ubus_context object in ubus_shutdown()

At the moment, we do our own null checks before calling ubus_free().
The likely-hood of 'ctx' being null (in ubus_free()) is low,
but since free() handles null, might make sense for ubus_free() to do so as well.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
9 years agoubusd: allow all object access if uid=0 (ignore gid)
Felix Fietkau [Wed, 9 Dec 2015 19:16:31 +0000 (20:16 +0100)]
ubusd: allow all object access if uid=0 (ignore gid)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoubusd: fix the return code for acl check mismatch
Felix Fietkau [Wed, 9 Dec 2015 18:48:08 +0000 (19:48 +0100)]
ubusd: fix the return code for acl check mismatch

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoubusd: simplify/fix avl loop in ubusd_reply_add()
Felix Fietkau [Wed, 9 Dec 2015 18:39:24 +0000 (19:39 +0100)]
ubusd: simplify/fix avl loop in ubusd_reply_add()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoubusd: simplify/fix avl loop in ubusd_acl_check()
Felix Fietkau [Wed, 9 Dec 2015 18:36:49 +0000 (19:36 +0100)]
ubusd: simplify/fix avl loop in ubusd_acl_check()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agolibubus: add socket EOF handling to ubus_complete_request()
Felix Fietkau [Wed, 9 Dec 2015 17:35:07 +0000 (18:35 +0100)]
libubus: add socket EOF handling to ubus_complete_request()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agolibubus: fix error handling during close after partially receiving a message
Felix Fietkau [Wed, 9 Dec 2015 17:26:43 +0000 (18:26 +0100)]
libubus: fix error handling during close after partially receiving a message

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoubusd: make ACL path configurable on the command line
Felix Fietkau [Wed, 9 Dec 2015 16:44:00 +0000 (17:44 +0100)]
ubusd: make ACL path configurable on the command line

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoubusd: remove a faulty and redundant check
Felix Fietkau [Wed, 9 Dec 2015 16:36:08 +0000 (17:36 +0100)]
ubusd: remove a faulty and redundant check

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoubus: Correct usage of timeout on poll function
Karl Vogel [Mon, 7 Dec 2015 07:35:52 +0000 (08:35 +0100)]
ubus: Correct usage of timeout on poll function

As the man page explains:

"Specifying a timeout of zero causes poll() to return immediately,
even if no file descriptors are ready."

The use of 0 as timeout could cause libubus to busy loop if the
socket was non-blocking. For blocking sockets, this was less
apparent as the subsequent read() would then block.

Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
9 years agocli: add monitor support
Felix Fietkau [Thu, 19 Nov 2015 21:32:29 +0000 (22:32 +0100)]
cli: add monitor support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agolibubus: add monitor support
Felix Fietkau [Thu, 19 Nov 2015 21:32:25 +0000 (22:32 +0100)]
libubus: add monitor support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoubusd: add monitor support
Felix Fietkau [Thu, 19 Nov 2015 21:32:11 +0000 (22:32 +0100)]
ubusd: add monitor support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agolibubus: Fix reverse order processing of pending ubus notifications messages
Hans Dedecker [Mon, 2 Nov 2015 10:16:11 +0000 (11:16 +0100)]
libubus: Fix reverse order processing of pending ubus notifications messages

Append ubus notification messages to the tail of the pending list
so they're processed in the order as they're put onto the pending list

Signed-off-by: Xinxing Hu <xinxing.huchn@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agolua: Fix stack imbalance in ubus_event_handler
Hans Dedecker [Mon, 2 Nov 2015 10:16:10 +0000 (11:16 +0100)]
lua: Fix stack imbalance in ubus_event_handler

The value from getglobal wasn't being removed from the stack,
resulting in an ever growing stack in the ubus event handler.

Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agofix off-by-one in acl match iteration
John Crispin [Tue, 22 Sep 2015 04:20:55 +0000 (06:20 +0200)]
fix off-by-one in acl match iteration

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agounbreak acl allocation
John Crispin [Tue, 22 Sep 2015 04:12:08 +0000 (06:12 +0200)]
unbreak acl allocation

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agofix a copy & paste bug
John Crispin [Wed, 1 Jul 2015 00:22:36 +0000 (02:22 +0200)]
fix a copy & paste bug

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agoubusd: fix offset calculation (based on patch by Yang Chao)
Felix Fietkau [Mon, 6 Jul 2015 16:42:36 +0000 (18:42 +0200)]
ubusd: fix offset calculation (based on patch by Yang Chao)

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoubusd: fix build on non-linux systems without peercred support
Felix Fietkau [Wed, 24 Jun 2015 16:28:37 +0000 (18:28 +0200)]
ubusd: fix build on non-linux systems without peercred support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agochange socket permission to allow !root users to connect
John Crispin [Mon, 13 Apr 2015 16:31:28 +0000 (18:31 +0200)]
change socket permission to allow !root users to connect

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agohook acl into ubusd
John Crispin [Sat, 25 Apr 2015 08:10:34 +0000 (10:10 +0200)]
hook acl into ubusd

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agohook acl into libubus
John Crispin [Sat, 25 Apr 2015 08:10:26 +0000 (10:10 +0200)]
hook acl into libubus

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agoadd acl code
John Crispin [Sat, 25 Apr 2015 08:50:39 +0000 (10:50 +0200)]
add acl code

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agomake ubusd load the acl on start and HUP
John Crispin [Wed, 15 Apr 2015 23:54:15 +0000 (01:54 +0200)]
make ubusd load the acl on start and HUP

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agoadd optional tags to the ubus methos struct and the wrapper macros
John Crispin [Mon, 13 Apr 2015 15:21:21 +0000 (17:21 +0200)]
add optional tags to the ubus methos struct and the wrapper macros

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agocall openlog on startup
John Crispin [Wed, 15 Apr 2015 23:54:54 +0000 (01:54 +0200)]
call openlog on startup

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agomake ubus_proto_send_msg_from_blob() none static
John Crispin [Sat, 25 Apr 2015 07:48:09 +0000 (09:48 +0200)]
make ubus_proto_send_msg_from_blob() none static

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agomake ubus_parse_msg() none static
John Crispin [Mon, 20 Apr 2015 23:01:26 +0000 (01:01 +0200)]
make ubus_parse_msg() none static

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agomake ubusd_send_event() none static
John Crispin [Mon, 20 Apr 2015 22:45:52 +0000 (00:45 +0200)]
make ubusd_send_event() none static

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agopass ubus_msg_buf to callback of internal object
John Crispin [Mon, 20 Apr 2015 09:08:26 +0000 (11:08 +0200)]
pass ubus_msg_buf to callback of internal object

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agoremove obseleted validation of key
John Crispin [Tue, 14 Apr 2015 03:12:34 +0000 (05:12 +0200)]
remove obseleted validation of key

Signed-off-by: John Crispin <blogic@openwrt.org>
9 years agolua: fix memory leak problem
陈斌 [Wed, 13 May 2015 05:52:22 +0000 (13:52 +0800)]
lua: fix memory leak problem

Signed-off-by: Chen Bin <ewolfok@126.com>
9 years agocli: flush stdout after printing an event
Felix Fietkau [Tue, 12 May 2015 14:56:09 +0000 (16:56 +0200)]
cli: flush stdout after printing an event

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 years agoubus: Fix memleak in examples/client in case of failure
Hans Dedecker [Tue, 28 Apr 2015 14:07:28 +0000 (16:07 +0200)]
ubus: Fix memleak in examples/client in case of failure

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agoubus: Fix issues reported by static code analysis tool Klocwork
Hans Dedecker [Mon, 13 Apr 2015 16:18:36 +0000 (18:18 +0200)]
ubus: Fix issues reported by static code analysis tool Klocwork

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
9 years agolibubus: fix processing queued messages after blocking requests
Felix Fietkau [Thu, 22 Jan 2015 12:30:20 +0000 (13:30 +0100)]
libubus: fix processing queued messages after blocking requests

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: expose ubus_connect_ctx() in public API
Delio Brignoli [Wed, 1 Oct 2014 17:57:56 +0000 (19:57 +0200)]
libubus: expose ubus_connect_ctx() in public API

ubus_connect_ctx() is equivalent to ubus_connect() but accepts a
pointer to a previously allocated ubus_context struct.
ubus_shutdown() is made available as an alternative to ubus_free()
to clean up contexts initialised by ubus_connect_ctx().

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
10 years agolibubus: define _GNU_SOURCE, needed for O_CLOEXEC
Felix Fietkau [Wed, 17 Sep 2014 11:32:43 +0000 (13:32 +0200)]
libubus: define _GNU_SOURCE, needed for O_CLOEXEC

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: fix build error in examples/server
Zefir Kurtisi [Wed, 17 Sep 2014 10:33:32 +0000 (12:33 +0200)]
libubus: fix build error in examples/server

This fixes build warning:
/ubus.git/examples/server.c: In function 'test_hello_reply':
/ubus.git/examples/server.c:69:6: error: ignoring return value of 'pipe', declared with attribute warn_unused_result [-Werror=unused-result]

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
10 years agolibubus: replace __init with __constructor
Zefir Kurtisi [Wed, 17 Sep 2014 10:30:49 +0000 (12:30 +0200)]
libubus: replace __init with __constructor

__init has a naming collision with C++ and prevents ubus_common.h
from being included. Instead, use __constructor as defined from
libubox.

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>
10 years agolibubus: restore uloop_cancelled on timeout
Alexandru Ardelean [Mon, 15 Sep 2014 12:42:09 +0000 (15:42 +0300)]
libubus: restore uloop_cancelled on timeout

Context: 1 loop with a single ubus_invoke() that times out calls
uloop_end() which ends the loop, and thus ends the application.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: preserve the received message buffer for incoming invoke calls
Felix Fietkau [Mon, 15 Sep 2014 13:40:05 +0000 (15:40 +0200)]
libubus: preserve the received message buffer for incoming invoke calls

Set ctx->msgbuf.data to NULL during the call. If ctx->msgbuf is needed
during the call, a new buffer will be allocated. If not,
ctx->msgbuf.data is restored to the previous value afterwards

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: rework buffer allocation code
Felix Fietkau [Mon, 15 Sep 2014 13:36:03 +0000 (15:36 +0200)]
libubus: rework buffer allocation code

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: remove ubus_msghdr_data() by passing in the right data structure pointer
Felix Fietkau [Mon, 15 Sep 2014 13:29:29 +0000 (15:29 +0200)]
libubus: remove ubus_msghdr_data() by passing in the right data structure pointer

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: use calloc_a for queued msgs to reduce the number of allocations
Felix Fietkau [Mon, 15 Sep 2014 13:21:40 +0000 (15:21 +0200)]
libubus: use calloc_a for queued msgs to reduce the number of allocations

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: fix a small memleak in ubus_register_event_handler()
Felix Fietkau [Thu, 4 Sep 2014 18:01:13 +0000 (20:01 +0200)]
libubus: fix a small memleak in ubus_register_event_handler()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: fix msgbuf reduction logic during receive
Alexandru Ardelean [Thu, 7 Aug 2014 04:32:53 +0000 (04:32 +0000)]
libubus: fix msgbuf reduction logic during receive

Signed-off-by: Alexandru Ardelean <aa@ocedo.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: mark ubus socket with close-on-exec
Felix Fietkau [Sun, 31 Aug 2014 12:10:26 +0000 (14:10 +0200)]
libubus: mark ubus socket with close-on-exec

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: use explicit type name in ubus_msghdr_data instead of typeof()
Felix Fietkau [Thu, 3 Jul 2014 18:58:37 +0000 (20:58 +0200)]
libubus: use explicit type name in ubus_msghdr_data instead of typeof()

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: move ubus_msghdr_data to libubus-internal.h
Felix Fietkau [Thu, 3 Jul 2014 18:58:01 +0000 (20:58 +0200)]
libubus: move ubus_msghdr_data to libubus-internal.h

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoubus: add count test to validate large message sizes
Alexandru Ardelean [Fri, 27 Jun 2014 16:11:45 +0000 (19:11 +0300)]
ubus: add count test to validate large message sizes

Client creates a string "1 2 3 ... 10000 ...", sends it to the server
along with the maximum number in the string.

Server creates another string like the client sent.

It validates it and, returns strcmp()'s result.

This is loop-ed every 2 seconds.

10 years agolibubus: fix ubus_invoke() to return err in case ubus_start_request() fails
Alexandru Ardelean [Fri, 27 Jun 2014 16:11:44 +0000 (19:11 +0300)]
libubus: fix ubus_invoke() to return err in case ubus_start_request() fails

Seems the UBUS_MAX_MSGLEN is ignored by ubus_invoke(),
and then segfault happens.

This issue is present before this set of patches.

10 years agoubusd: replace ubusd_msg_unshare() with ubus_msg_new() to prevent invalid free-ing
Alexandru Ardelean [Fri, 27 Jun 2014 16:11:43 +0000 (19:11 +0300)]
ubusd: replace ubusd_msg_unshare() with ubus_msg_new() to prevent invalid free-ing

The realloc is problematic mostly with large packets, as the pointer changes
so what eventually gets free'd is invalid.
Note that ub ptr param in the  call will be passed on to a ubus_msg_free(),
right after ubus_msg_ref() finishes.

This bug stayed hidden the same way as the bug in libubus writev_retry().
Since the write/sendmsg function can send about ~200k the ubus_msg_enqueue()
call does not get triggered.

10 years agolibubus: fix writev_retry() function when writing large packets
Alexandru Ardelean [Fri, 27 Jun 2014 16:11:42 +0000 (19:11 +0300)]
libubus: fix writev_retry() function when writing large packets

Seems this bug stayed hidden for a while, because the write/sendmsg function
can send up to ~200k in one send, so it looked at first why there was
some data mismatch.

10 years agolibubus: add logic to reduce msgbuf data size after 16 small messages
Alexandru Ardelean [Fri, 27 Jun 2014 16:11:41 +0000 (19:11 +0300)]
libubus: add logic to reduce msgbuf data size after 16 small messages

10 years agoubus: increase message size limit and make it configurable at build-time
Alexandru Ardelean [Fri, 27 Jun 2014 16:11:40 +0000 (19:11 +0300)]
ubus: increase message size limit and make it configurable at build-time

10 years agolibubus: refactor ubus_context msgbuf data to be dynamically allocated
Alexandru Ardelean [Fri, 27 Jun 2014 16:11:39 +0000 (19:11 +0300)]
libubus: refactor ubus_context msgbuf data to be dynamically allocated

10 years agolibubus: fix deferring invoke processing for non-uloop usage
Felix Fietkau [Tue, 24 Jun 2014 20:42:14 +0000 (22:42 +0200)]
libubus: fix deferring invoke processing for non-uloop usage

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: always defer processing incoming invoke/unsubscribe/notify if there is a...
Felix Fietkau [Tue, 24 Jun 2014 20:34:50 +0000 (22:34 +0200)]
libubus: always defer processing incoming invoke/unsubscribe/notify if there is a request pending

This fixes recursion problems on config reload in netifd and simplifies
application handling of requests

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agocli: implement wait_for
Felix Fietkau [Tue, 6 May 2014 14:55:34 +0000 (16:55 +0200)]
cli: implement wait_for

Allows waiting for one or more objects to appear
Returns instantly if objects are already present

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolua: forward return codes from lua to ubus
Steven Barth [Mon, 5 May 2014 17:47:32 +0000 (19:47 +0200)]
lua: forward return codes from lua to ubus

Signed-off-by: Steven Barth <cyrus@openwrt.org>
Tested-by: Luka Perkov <luka@openwrt.org>
10 years agolibubus: add support for defining a policy mask
Felix Fietkau [Sat, 26 Apr 2014 22:40:23 +0000 (00:40 +0200)]
libubus: add support for defining a policy mask

This allows sharing a policy array across methods, but masking out
unused entries for individual methods.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoubusd: fix processing object method signatures
Felix Fietkau [Tue, 1 Apr 2014 11:45:29 +0000 (13:45 +0200)]
ubusd: fix processing object method signatures

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: do not use uloop_run() inside ubus_complete_request
Felix Fietkau [Tue, 18 Mar 2014 21:36:36 +0000 (22:36 +0100)]
libubus: do not use uloop_run() inside ubus_complete_request

Avoid unrelated uloop callbacks by using poll() on the ubus fd instead.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus-internal: use the __hidden definition from libubox
Felix Fietkau [Tue, 18 Mar 2014 21:12:21 +0000 (22:12 +0100)]
libubus-internal: use the __hidden definition from libubox

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: close file descriptor after passing it in the status msg
Felix Fietkau [Thu, 27 Feb 2014 15:48:53 +0000 (16:48 +0100)]
libubus: close file descriptor after passing it in the status msg

Simplifies handling of non-deferred requests

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoubus: Fix imbalance in lua stack push/pop of values.
Karl Vogel [Tue, 11 Feb 2014 08:27:36 +0000 (09:27 +0100)]
ubus: Fix imbalance in lua stack push/pop of values.

The lua getglobal and rawgeti both push a value onto the lua stack,
but they weren't being removed by the ubus_method_handler function,
thus corrupting the lua stack.

In case the specified method wasn't a function, the stack was also
corrupted as the method name remained on the stack.

Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
10 years agoexamples/client: receive data from the passed file descriptor
Felix Fietkau [Tue, 18 Feb 2014 14:03:44 +0000 (15:03 +0100)]
examples/client: receive data from the passed file descriptor

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoexamples/server: send a file descriptor as part of the request to the "hello" method
Felix Fietkau [Tue, 18 Feb 2014 14:03:22 +0000 (15:03 +0100)]
examples/server: send a file descriptor as part of the request to the "hello" method

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolibubus: implement file descriptor passing support
Felix Fietkau [Tue, 18 Feb 2014 14:02:48 +0000 (15:02 +0100)]
libubus: implement file descriptor passing support

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agoubusd: implement protocol support for passing file descriptors as part of request...
Felix Fietkau [Tue, 18 Feb 2014 14:01:39 +0000 (15:01 +0100)]
ubusd: implement protocol support for passing file descriptors as part of request completion msgs from objects to clients

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10 years agolua: allow methods with no arguments
Luka Perkov [Sun, 26 Jan 2014 17:33:36 +0000 (17:33 +0000)]
lua: allow methods with no arguments

In C it is possible to have methods without arguments (UBUS_METHOD_NOARG).
Enable support for the same calls in Lua too.

This commit also fixes segfault which can be caused by passing non-table type
where table is expected. The lua_gettablelen() function is called after we have
made sure we are dealing with a table in the first place.

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agolua: fix whitespaces and typo
Luka Perkov [Sun, 26 Jan 2014 17:32:10 +0000 (17:32 +0000)]
lua: fix whitespaces and typo

Signed-off-by: Luka Perkov <luka@openwrt.org>
10 years agoadd auto (re)connect logic to libubus
John Crispin [Wed, 22 Jan 2014 13:53:11 +0000 (13:53 +0000)]
add auto (re)connect logic to libubus

Signed-off-by: John Crispin <blogic@openwrt.org>
11 years agoadd Lua bindings for ubus events
John Crispin [Thu, 7 Nov 2013 12:51:11 +0000 (13:51 +0100)]
add Lua bindings for ubus events

It mostly mimick the style of the existing code.

With it and the ubox Lua bindings, you can now send ubus events
through Lua or listen for events (you can register for multiple events
at the same time).

Signed-off-by: Jeff Remy <jeff.remy@gmail.com>
11 years agolibubus: pull the variable length data array out of struct ubus_msghdr to fix builds...
Felix Fietkau [Tue, 29 Oct 2013 16:28:33 +0000 (17:28 +0100)]
libubus: pull the variable length data array out of struct ubus_msghdr to fix builds with clang

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoubusd: use umask of 0177 for now to prevent a world- and group-writable unix socket
Jo-Philipp Wich [Sat, 28 Sep 2013 17:23:01 +0000 (17:23 +0000)]
ubusd: use umask of 0177 for now to prevent a world- and group-writable unix socket

11 years agolibubus: Check if remove callback exists before call it
Lukasz Baj [Thu, 29 Aug 2013 09:05:51 +0000 (11:05 +0200)]
libubus: Check if remove callback exists before call it

When process unsubscribes then remove callback is called. But it
can be NULL if not defined, so we should check it before we call it.

Signed-off-by: Lukasz Baj <l.baj@radytek.com>
11 years agolibubus: detect read/write errors and set the eof flag, even if uloop is not used...
Felix Fietkau [Thu, 8 Aug 2013 20:42:50 +0000 (22:42 +0200)]
libubus: detect read/write errors and set the eof flag, even if uloop is not used as main event loop

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agolibubus: fix publishing objects after reconnect
Felix Fietkau [Thu, 8 Aug 2013 20:14:27 +0000 (22:14 +0200)]
libubus: fix publishing objects after reconnect

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoAdd a return value to make compiler silent.
Yousong Zhou [Thu, 25 Jul 2013 12:38:09 +0000 (20:38 +0800)]
Add a return value to make compiler silent.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
11 years agoFix the condition for stopping the writev_retry.
Yousong Zhou [Thu, 25 Jul 2013 12:38:08 +0000 (20:38 +0800)]
Fix the condition for stopping the writev_retry.

All iov's were sent only after the last were sent (iov_len == 0). We
could have 'cur_len == 0' if the sent iov's were sent wholly but not all
iov's were sent (how about all but the last).

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
11 years agolibubus: fix logic inversion for cancelling requests
Felix Fietkau [Thu, 30 May 2013 10:39:51 +0000 (12:39 +0200)]
libubus: fix logic inversion for cancelling requests

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agocli: use the new json-c library name
Felix Fietkau [Wed, 29 May 2013 10:53:17 +0000 (12:53 +0200)]
cli: use the new json-c library name

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agolibubus: fix deadlock in recursive synchronous ubus requests
Felix Fietkau [Sat, 11 May 2013 18:39:54 +0000 (20:39 +0200)]
libubus: fix deadlock in recursive synchronous ubus requests

When synchronous request completion loops are running, the innermost
loop can receive events that can unblock the outer loops, however the
loop clears uloop_cancelled (which is set by the request completion).

This causes the event loop to continue running even while a completion
loop has already been unblocked.

Fix this by not clearing uloop_cancelled for inner loops

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agolibubus: fix crash on reconnect with objects that have no type
Felix Fietkau [Thu, 4 Apr 2013 20:03:03 +0000 (22:03 +0200)]
libubus: fix crash on reconnect with objects that have no type

Signed-off-by: John Crispin <blogic@openwrt.org>
11 years agolibubus: fix passing the return code of the subscriber callback to the notifier
Felix Fietkau [Sun, 17 Mar 2013 17:29:38 +0000 (18:29 +0100)]
libubus: fix passing the return code of the subscriber callback to the notifier

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agolibubus: fix synchronous ubus_notify without waiting for a timeout
Felix Fietkau [Sun, 17 Mar 2013 16:55:11 +0000 (17:55 +0100)]
libubus: fix synchronous ubus_notify without waiting for a timeout

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agolibubus: add ubus_unregister_subscriber wrapper
Felix Fietkau [Sun, 17 Mar 2013 02:11:35 +0000 (03:11 +0100)]
libubus: add ubus_unregister_subscriber wrapper

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agolibubus: add UBUS_METHOD_NOARG
Felix Fietkau [Wed, 6 Mar 2013 15:56:33 +0000 (16:56 +0100)]
libubus: add UBUS_METHOD_NOARG

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 years agoadd systemd support
Thomas Gstädtner [Mon, 4 Mar 2013 18:05:09 +0000 (19:05 +0100)]
add systemd support

This adds basic systemd support, incl. socket activation.
If systemd build is disabled, there won't be any sign of it neither
during build nor after.
If systemd build is enabled (default), but systemd is not available,
no systemd stuff is installed, so there is no impact whatsoever.

11 years agomake UBUS_UNIX_SOCKET configurable via cmake
Thomas Gstädtner [Mon, 4 Mar 2013 18:05:08 +0000 (19:05 +0100)]
make UBUS_UNIX_SOCKET configurable via cmake

this is mainly useful to have a single location to read the setting
from, when it is used multiple times at build time (which it will in a
following patch) :)

11 years agoadd INCLUDE_DIRECTORIES to subdirectories
Thomas Gstädtner [Sun, 3 Mar 2013 02:06:20 +0000 (03:06 +0100)]
add INCLUDE_DIRECTORIES to subdirectories

11 years agomake building examples an option
Thomas Gstädtner [Sun, 3 Mar 2013 02:06:19 +0000 (03:06 +0100)]
make building examples an option