mirror of
https://github.com/troglobit/finit.git
synced 2026-10-24 11:54:36 +00:00
Default to user/group root for services and check for errors
This is a refactor of getuser() and getgroup() so that they always return a valid user, and group, for all normal use-cases. When an error occurs we now handle it properly in service_fork() so as to not attempt to start services with an invalid user/group setting as root. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
2 files changed
+50
-4
No files matched your search
@@ -556,6 +556,18 @@ static pid_t service_fork(svc_t *svc)
|
||||
#else
|
||||
int uid = getuser(svc->username, &home);
|
||||
int gid = getgroup(svc->group);
|
||||
|
||||
/* Check for invalid user/group - fail rather than silent fallback */
|
||||
if (uid < 0) {
|
||||
err(1, "%s: user '%s' not found, cannot start service",
|
||||
svc_ident(svc, NULL, 0), svc->username);
|
||||
return -1;
|
||||
}
|
||||
if (gid < 0) {
|
||||
err(1, "%s: group '%s' not found, cannot start service",
|
||||
svc_ident(svc, NULL, 0), svc->group);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
sched_yield();
|
||||
|
||||
Reference in new issue
Block a user