Commit graph

21 commits

Author SHA1 Message Date
Rafał Miłecki
b743a33142 ubusd: log ACL init errors
This makes it easier to notice ubusd (and so often a system) failing to
start properly. Some users reported procd failing to initialize fully
without a clear error in case of faulty /etc/passwd.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
2021-09-07 09:39:18 +02:00
Ansuel Smith
ad0cd117db ubusd_acl: add support for wildcard in methods
Add support for wildcard in methods to permit access to all methods
defined by the object. This can be usefull for process that run as
non-root user and needs to access ubus method.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2020-10-25 18:01:19 +00:00
Petr Štetiar
a1523d76b0 fix blob parsing vulnerability by using blob_parse_untrusted
blob_parse expects blobs from trusted inputs, but it can be supplied
with possibly malicious blobs from untrusted inputs as well, which might
lead to undefined behaviour and/or crash of ubus daemon. In order to
prevent such conditions, switch to blob_parse_untrusted which should
hopefully handle such untrusted inputs appropriately.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-12-19 19:53:25 +01:00
Petr Štetiar
d2e026a33d iron out all extra compiler warnings
clang-9 on x86/64 has reported following warnings/errors:

 libubus-acl.c:123:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 libubus-io.c:108:18: error: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
 libubus-io.c:395:56: error: comparison of integers of different signs: 'ssize_t' (aka 'long') and 'size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
 libubus-req.c:441:4: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:119:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd_acl.c:152:5: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:348:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:352:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:357:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:362:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:367:3: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
 ubusd_acl.c:447:16: error: comparison of integers of different signs: 'int' and '__size_t' (aka 'unsigned long') [-Werror,-Wsign-compare]
 ubusd_acl.c:502:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd.c:123:13: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd.c:170:15: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd.c:262:43: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd.c:287:30: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd_event.c:170:18: error: comparison of integers of different signs: 'int' and 'unsigned long' [-Werror,-Wsign-compare]
 ubusd_obj.c:71:2: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-12-16 23:39:16 +01:00
Hans Dedecker
221ce7e7ff ubusd_acl: event send access list support
Adds event send access list support in ubus via the "send" keyword

Example of a json file:
{
	"user": "superuser",
	"send": [ "wireless.*" ],
}

Signed-off-by: Koen Dergent <koen.cj.dergent@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-10-06 20:40:24 +02:00
Hans Dedecker
da503db660 ubusd_acl: event listen access list support
Adds event listen access list support in ubus via the "listen" keyword

Example of a json file:

{
    "user": "superuser",
    "listen": [ "network.*" ],
}

Signed-off-by: Koen Dergent <koen.cj.dergent@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-10-06 20:39:34 +02:00
Hans Dedecker
c035bab01c ubusd_acl: rework wildcard support
Wildcard access list support was failing in case multiple wildcards
entries were defined and/or when a specific access list string
overlapped a wildcard entry.
Root cause of the problem was the way how wildcard entries were sorted
in the avl tree by the compare function ubusd_acl_match_path resulting
into a non acces list match for a given object path.

The avl_tree sorting has been changed to make use of avl_strcmp; as such
there's no distinction anymore between non-wildcard and wildcard entries
in the avl_tree compare function as the boolean partial marks an access
list entry as a wildcard entry.

When trying to find an access list match for an object path the access list
tree is iterated as long as the number of characters between the access list
string and object path is monotonically increasing.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2018-10-06 20:39:20 +02:00
Denis Osvald
ba45b27f8c ubusd: fix inverted check in ubusd_reply_add
Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
2016-09-05 13:59:34 +02:00
Denis Osvald
d6bb4f1a1d ubusd: don't check ACL when object is NULL
If there are any ACLs present other than global wildcard "*", the AVL
tree comparator will compare ACL key to object name. However, object
name can be NULL in cases where ACL check is done on call to internal
ubus objects (e.g. ubus monitor).

With this change we skip checking ACLs on such NULL objects.

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
2016-08-25 13:58:11 +02: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
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
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
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
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
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
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
8309c75828 add acl code
Signed-off-by: John Crispin <blogic@openwrt.org>
2015-06-18 19:01:17 +02:00