service_start(): Must set GID before dropping user privs, obvs
@@ -192,6 +192,9 @@ static int service_start(svc_t *svc)
char *args[MAX_NUM_SVC_ARGS];
/* Set desired user+group */
+ if (gid >= 0)
+ setgid(gid);
+
if (uid >= 0) {
setuid(uid);
@@ -204,9 +207,6 @@ static int service_start(svc_t *svc)
}
}
- if (gid >= 0)
- setgid(gid);
-
/* Serve copy of args to process in case it modifies them. */
for (i = 0; i < (MAX_NUM_SVC_ARGS - 1) && svc->args[i][0] != 0; i++)
args[i] = svc->args[i];
