chiark / gitweb /
uaccess: become a nop when not run on a systemd system
[elogind.git] / src / uaccess.c
index 2f6ac43754b450dfff8dafcf50be235868d144e0..a9713a5023cb751cbfc6ec07ceb80ef7b2342dec 100644 (file)
 #include "logind-acl.h"
 #include "util.h"
 #include "log.h"
+#include "sd-daemon.h"
 
 int main(int argc, char *argv[]) {
         int r;
-        const char *path, *seat;
+        const char *path = NULL, *seat;
         char *p, *active_uid = NULL;
         unsigned long ul;
         bool changed_acl = false;
@@ -43,12 +44,18 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
+        /* Make sure we don't muck around with ACLs the system is not
+         * running systemd. */
+        if (!sd_booted())
+                return 0;
+
         path = argv[1];
-        seat = argc >= 3 ? argv[2] : "seat0";
+        seat = argc < 3 || isempty(argv[2]) ? "seat0" : argv[2];
 
         p = strappend("/run/systemd/seats/", seat);
         if (!p) {
                 log_error("Out of memory.");
+                r = -ENOMEM;
                 goto finish;
         }