chiark / gitweb /
Allow block and char classes in DeviceAllow bus properties (#4353)
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 12 Oct 2016 09:12:11 +0000 (05:12 -0400)
committerSven Eden <yamakuzure@gmx.net>
Wed, 5 Jul 2017 06:50:55 +0000 (08:50 +0200)
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
src/basic/path-util.h

index 369a2b2a07d6fa113fc6f5aca403845b40c610f1..3af2bd0fd4ab82aeb5ede0d7fbd8274f2a9285d2 100644 (file)
@@ -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
 
index 786276c0168ad6ceac3eb8efcf4aefdf7bb18c10..cdb194d2a34bb3a02e7ae6b4984be6c394e37726 100644 (file)
@@ -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);