From: Zbigniew Jędrzejewski-Szmek Date: Wed, 12 Oct 2016 09:12:11 +0000 (-0400) Subject: Allow block and char classes in DeviceAllow bus properties (#4353) X-Git-Tag: v232.2~39 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=d96290d8fd01ba77eec7f4a5fb493bc1ff80a98b Allow block and char classes in DeviceAllow bus properties (#4353) Allowed paths are unified betwen the configuration file parses and the bus property checker. The biggest change is that the bus code now allows "block-" and "char-" classes. In addition, path_startswith("/dev") was used in the bus code, and startswith("/dev") was used in the config file code. It seems reasonable to use path_startswith() which allows a slightly broader class of strings. Fixes #3935. --- diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 369a2b2a0..3af2bd0fd 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -817,9 +817,14 @@ bool is_device_path(const char *path) { /* Returns true on paths that refer to a device, either in * sysfs or in /dev */ - return - path_startswith(path, "/dev/") || - path_startswith(path, "/sys/"); + return path_startswith(path, "/dev/") || + path_startswith(path, "/sys/"); +} + +bool is_deviceallow_pattern(const char *path) { + return path_startswith(path, "/dev/") || + startswith(path, "block-") || + startswith(path, "char-"); } #endif // 0 diff --git a/src/basic/path-util.h b/src/basic/path-util.h index 786276c01..cdb194d2a 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -141,5 +141,6 @@ bool hidden_or_backup_file(const char *filename) _pure_; #if 0 /// UNNEEDED by elogind bool is_device_path(const char *path); #endif // 0 +bool is_deviceallow_pattern(const char *path); int systemd_installation_has_version(const char *root, unsigned minimal_version);