Commit graph

254 commits

Author SHA1 Message Date
John Crispin
96ab0b3032 ubusd: remove systemd socket activation support
Signed-off-by: John Crispin <john@phrozen.org>
2016-06-01 11:39:34 +02:00
Matthias Schiffer
964adfdd39 ubusd: fix systemd socket activation support
62cdfc3 added systemd units including a ubus.socket unit, but didn't
actually add socket activation support to ubusd. This would cause the first
connection that activated ubusd to hang (as ubusd ignored it), and stopping
ubusd would break it completely (as ubusd removed the socket file).

The ENABLE_SYSTEMD default is changed to OFF as the socket activation uses
libsystemd, so setting ENABLE_SYSTEMD to ON will now require libsystemd.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
2016-06-01 11:32:46 +02:00
Eyal Birger
3b8d4b5653 libubus: nullify stale msgbuf pointer in case of ubus_connect_ctx() failure
If the ubus_reconnect() call fails in ubus_connect_ctx(), the msgbuf.data
newly allocated buffer is freed, but its pointer in the ubus_context is not
removed.

This leads to a double free error if ubus_auto_shutdown() is called for cleanup
after ubus_auto_connect() failed to connect to ubusd.

Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
2016-05-15 09:39:24 +02:00
Petr Štetiar
fcf5d8af65 cmake: Add ubox, blobmsg_json libraries and include dirs lookup
Otherwise cmake uses files from system which sometimes isn't wanted, ie.
for testing.

Signed-off-by: Petr Å tetiar <ynezz@true.cz>
2016-03-07 09:38:04 +01:00
Zhao, Gang
b958a9aa60 cli: add timeout support for listen command
Currently 'ubus listen' command does not respect the timeout parameter,
i.e., whether timeout parameter is provided, 'ubus listen' will always
run infinitely. This patch let 'ubus listen' command support the timeout
parameter. For example, 'ubus listen -t 60' will cause the command to
exit after 60 seconds.

Signed-off-by: Zhao, Gang <gang.zhao.42@gmail.com>
2016-02-29 21:06:42 +01:00
Zhao, Gang
6cd8912f10 cli: static keyword tweak
Function ubus_cli_listen() is called only once, and function uloop_run()
and uloop_done() which need struct ubus_event_handler listener are
called within this function, so it's not needed to mark struct
ubus_event_handler listener as static. The same as pointer struct
ubus_context *ctx in main function.

Global struct commands is only used in this file, so it should be marked
static.

Signed-off-by: Zhao, Gang <gang.zhao.42@gmail.com>
2016-02-29 21:06:28 +01:00
Eyal Birger
5dfd3c16fa ubus: use network order in ubus message header fields
Changing the ubus message header fields from 'host' order to 'network' order
allows passing ubus messages between hosts with different endianity.

Example use (creating a ubus proxy):

on host A (e.g. big endian router already running ubusd), run:
$ socat TCP-LISTEN:5699,fork UNIX:/var/run/ubus.sock &

On host B (e.g. little endian development PC) run:
$ socat UNIX-LISTEN:/var/run/ubus.sock,fork TCP:<host A IP>:5699 &

Now ubus applications can be run on host B and seamlessly interact with ubus
applications on host A.

Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
2016-02-28 09:56:48 +01:00
Emanuel Taube
fda009d8ba 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>
2016-02-22 11:41:03 +01:00
Ben Kelly
6a86e65f7d 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>
2016-02-07 14:24:28 +01:00
Felix Fietkau
619f3a160d ubusd: fix a memory leak on user/group client info
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-01-26 10:10:39 +01:00
Felix Fietkau
8bb34756ce lua: fix stack leak in ubus method handling
Signed-off-by: Chen Bin <ewolfok@126.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-01-20 14:59:06 +01:00
Felix Fietkau
1d2b3bbdbe ubusd: add missing NULL pointer checks for ACL processing
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-01-13 12:29:01 +01:00
Alexandru Ardelean
85e4de4193 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>
2015-12-19 12:29:23 +01:00
Felix Fietkau
68da4ceb87 ubusd: allow all object access if uid=0 (ignore gid)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 20:16:36 +01:00
Felix Fietkau
8c9322c723 ubusd: fix the return code for acl check mismatch
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 19:48:08 +01:00
Felix Fietkau
766d49876f ubusd: simplify/fix avl loop in ubusd_reply_add()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 19:40:20 +01:00
Felix Fietkau
0eff70a64c ubusd: simplify/fix avl loop in ubusd_acl_check()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 19:36:49 +01:00
Felix Fietkau
635ada4251 libubus: add socket EOF handling to ubus_complete_request()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 18:35:07 +01:00
Felix Fietkau
04e644bcce libubus: fix error handling during close after partially receiving a message
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 18:26:43 +01:00
Felix Fietkau
83461b9791 ubusd: make ACL path configurable on the command line
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 17:44:00 +01:00
Felix Fietkau
152dd96f63 ubusd: remove a faulty and redundant check
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-12-09 17:36:08 +01:00
Karl Vogel
f09d18878b 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>
2015-12-07 18:03:13 +01:00
Felix Fietkau
259450f414 cli: add monitor support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-19 22:32:29 +01:00
Felix Fietkau
44a62711e0 libubus: add monitor support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-19 22:32:25 +01:00
Felix Fietkau
47d75dd84a ubusd: add monitor support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-19 22:32:11 +01:00
Hans Dedecker
95648dadba 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>
2015-11-02 19:02:53 +01:00
Hans Dedecker
d23b07a9ff 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>
2015-11-02 19:02:35 +01:00
John Crispin
33b2abf631 fix off-by-one in acl match iteration
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-09-22 06:20:55 +02:00
John Crispin
f7f899d2d3 unbreak acl allocation
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-09-22 06:12:08 +02:00
John Crispin
7ec9b8dec7 fix a copy & paste bug
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-07-01 02:22:36 +02:00
Felix Fietkau
ab1bffddb3 ubusd: fix offset calculation (based on patch by Yang Chao)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-07-06 18:42:36 +02:00
Felix Fietkau
e59b445734 ubusd: fix build on non-linux systems without peercred support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-06-24 18:28:37 +02:00
John Crispin
b2e629a4e9 change socket permission to allow !root users to connect
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
3df5b18af2 hook acl into ubusd
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
2cfdb81889 hook acl into libubus
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
8309c75828 add acl code
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
3bfa6ab128 make ubusd load the acl on start and HUP
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
e3815962c1 add optional tags to the ubus methos struct and the wrapper macros
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
6c0fa3a8cf call openlog on startup
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
9ffec46f73 make ubus_proto_send_msg_from_blob() none static
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
8c992a556b make ubus_parse_msg() none static
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
0bb927125f make ubusd_send_event() none static
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
ba607d976b pass ubus_msg_buf to callback of internal object
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
John Crispin
df0292c3af remove obseleted validation of key
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00
陈斌
f361bfa5fc lua: fix memory leak problem
Signed-off-by: Chen Bin <ewolfok@126.com>
2015-05-25 23:06:19 +02:00
Felix Fietkau
2c30506a4f cli: flush stdout after printing an event
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-05-12 16:56:09 +02:00
Hans Dedecker
38174a05a5 ubus: Fix memleak in examples/client in case of failure
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-05-08 12:06:39 +02:00
Hans Dedecker
7798d56301 ubus: Fix issues reported by static code analysis tool Klocwork
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-04-20 15:43:19 +02:00
Felix Fietkau
2d660c519d libubus: fix processing queued messages after blocking requests
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-01-22 13:30:20 +01:00
Delio Brignoli
7b79b6226e 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>
2014-10-14 09:57:11 +02:00