Commit graph

243 commits

Author SHA1 Message Date
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
Felix Fietkau
4c4f35cf22 libubus: define _GNU_SOURCE, needed for O_CLOEXEC
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-17 13:32:43 +02:00
Zefir Kurtisi
9841dae95a 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>
2014-09-17 13:29:30 +02:00
Zefir Kurtisi
4d1cdc5527 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>
2014-09-17 13:29:24 +02:00
Alexandru Ardelean
e52db46c9c 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>
2014-09-15 15:48:54 +02:00
Felix Fietkau
9562291f68 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>
2014-09-15 15:40:07 +02:00
Felix Fietkau
6a285141d9 libubus: rework buffer allocation code
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-15 15:36:03 +02:00
Felix Fietkau
3e45a782b2 libubus: remove ubus_msghdr_data() by passing in the right data structure pointer
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-15 15:33:27 +02:00
Felix Fietkau
7c25c119a5 libubus: use calloc_a for queued msgs to reduce the number of allocations
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-15 15:21:40 +02:00
Felix Fietkau
73cbb94b48 libubus: fix a small memleak in ubus_register_event_handler()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-04 20:01:13 +02:00
Alexandru Ardelean
6280cbaf09 libubus: fix msgbuf reduction logic during receive
Signed-off-by: Alexandru Ardelean <aa@ocedo.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-08-31 14:12:55 +02:00
Felix Fietkau
b79e808944 libubus: mark ubus socket with close-on-exec
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-08-31 14:10:26 +02:00