From d96290d8fd01ba77eec7f4a5fb493bc1ff80a98b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 12 Oct 2016 05:12:11 -0400 Subject: [PATCH] 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. --- src/basic/path-util.c | 11 ++++++++--- src/basic/path-util.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) 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); -- 2.30.2