Browse Source

Merge branch 'no-nobody-critical-abort' of git://github.com/Demindiro/cjdns into crashey

Caleb James DeLisle 5 years ago
parent
commit
45c9d282dc
1 changed files with 11 additions and 3 deletions
  1. 11 3
      client/Configurator.c

+ 11 - 3
client/Configurator.c

@@ -544,9 +544,11 @@ static void security(struct Allocator* tempAlloc, List* conf, struct Log* log, s
         Dict_putStringCC(d, "user", "nobody", tempAlloc);
         if (!Defined(win32)) {
             Dict* ret = NULL;
-            rpcCall0(String_CONST("Security_getUser"), d, ctx, tempAlloc, &ret, true);
-            uid = *Dict_getIntC(ret, "uid");
-            group = Dict_getIntC(ret, "gid");
+            int r = rpcCall0(String_CONST("Security_getUser"), d, ctx, tempAlloc, &ret, false);
+            if (!r) {
+                uid = *Dict_getIntC(ret, "uid");
+                group = Dict_getIntC(ret, "gid");
+            }
         }
     } while (0);
 
@@ -603,6 +605,12 @@ static void security(struct Allocator* tempAlloc, List* conf, struct Log* log, s
         Log_info(ctx->logger, "Unrecognized entry in security at index [%d]", i);
     }
 
+    if (uid == -1) {
+        Log_critical(ctx->logger,
+                     "User \"nobody\" doesn't exist and no alternative user is set");
+        die(ctx->currentResult, ctx, tempAlloc);
+    }
+
     if (chroot) {
         Log_debug(log, "Security_chroot(/var/run)");
         Dict* d = Dict_new(tempAlloc);