]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/nspawn/nspawn.c
Merge pull request #7469 from kinvolk/dongsu/nspawn-netns
[thirdparty/systemd.git] / src / nspawn / nspawn.c
index 64819b5e853e68b2cdd59ecfc7976e84c99e4cd9..71b14e23029dd97a894009e6b782f22eaf1dd0f2 100644 (file)
@@ -2891,7 +2891,7 @@ static int uid_shift_pick(uid_t *shift, LockFile *ret_lock_file) {
         (void) mkdir("/run/systemd/nspawn-uid", 0755);
 
         for (;;) {
-                char lock_path[strlen("/run/systemd/nspawn-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
+                char lock_path[STRLEN("/run/systemd/nspawn-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
                 _cleanup_release_lock_file_ LockFile lf = LOCK_FILE_INIT;
 
                 if (--n_tries <= 0)
@@ -2945,7 +2945,7 @@ static int uid_shift_pick(uid_t *shift, LockFile *ret_lock_file) {
 }
 
 static int setup_uid_map(pid_t pid) {
-        char uid_map[strlen("/proc//uid_map") + DECIMAL_STR_MAX(uid_t) + 1], line[DECIMAL_STR_MAX(uid_t)*3+3+1];
+        char uid_map[STRLEN("/proc//uid_map") + DECIMAL_STR_MAX(uid_t) + 1], line[DECIMAL_STR_MAX(uid_t)*3+3+1];
         int r;
 
         assert(pid > 1);
@@ -3834,11 +3834,10 @@ int main(int argc, char *argv[]) {
         if (r <= 0)
                 goto finish;
 
-        if (geteuid() != 0) {
-                log_error("Need to be root.");
-                r = -EPERM;
+        r = must_be_root();
+        if (r < 0)
                 goto finish;
-        }
+
         r = determine_names();
         if (r < 0)
                 goto finish;