or whenever they change if it wants to integrate with `systemd-logind`'s
APIs.
-`systemd-udevd`:
+`systemd-udevd` and sd-device library:
* `$NET_NAMING_SCHEME=` — if set, takes a network naming scheme (i.e. one of
"v238", "v239", "v240"…, or the special value "latest") as parameter. If
prefixed with `:` in which case the kernel command line option takes
precedence, if it is specified as well.
+* `$SYSTEMD_DEVICE_VERIFY_SYSFS` — if set to "0", disables verification that
+ devices sysfs path are actually backed by sysfs. Relaxing this verification
+ is useful for testing purposes.
+
`nss-systemd`:
* `$SYSTEMD_NSS_BYPASS_SYNTHETIC=1` — if set, `nss-systemd` won't synthesize
#include "device-private.h"
#include "device-util.h"
#include "dirent-util.h"
+#include "env-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
#include "hashmap.h"
#include "id128-util.h"
#include "macro.h"
+#include "missing_magic.h"
#include "netlink-util.h"
#include "parse-util.h"
#include "path-util.h"
return log_debug_errno(SYNTHETIC_ERRNO(ENODEV),
"sd-device: the syspath \"%s\" is not a directory.", syspath);
}
+
+ /* Only operate on sysfs, i.e. refuse going down into /sys/fs/cgroup/ or similar places where
+ * things are not arranged as kobjects in kernel, and hence don't necessarily have
+ * kobject/attribute structure. */
+ r = getenv_bool_secure("SYSTEMD_DEVICE_VERIFY_SYSFS");
+ if (r < 0 && r != -ENXIO)
+ log_debug_errno(r, "Failed to parse $SYSTEMD_DEVICE_VERIFY_SYSFS value: %m");
+ if (r != 0) {
+ r = fd_is_fs_type(fd, SYSFS_MAGIC);
+ if (r < 0)
+ return log_debug_errno(r, "sd-device: failed to check if syspath \"%s\" is backed by sysfs.", syspath);
+ if (r == 0)
+ return log_debug_errno(SYNTHETIC_ERRNO(ENODEV),
+ "sd-device: the syspath \"%s\" is outside of sysfs, refusing.", syspath);
+ }
} else {
syspath = strdup(_syspath);
if (!syspath)
}
}
+# Relax sd-device's sysfs verification, since we want to provide a fake sysfs
+# here that actually is a tmpfs.
+$ENV{"SYSTEMD_DEVICE_VERIFY_SYSFS"}="0";
+
my $udev_bin = "./test-udev";
my $valgrind = 0;
my $gdb = 0;