mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
Add support for setting effective group ID of services
Finit has long since supported an @user:group syntax to services, tasks, and run stanzas. Setting UID was implemented at that time, but setting GID never was. This patch fixes that oversight. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
84369ab8b5
commit
eb870efaff
1 file changed
+6
-1
+6
-1
@@ -184,12 +184,14 @@ static int service_start(svc_t *svc)
|
|||||||
char *home = NULL;
|
char *home = NULL;
|
||||||
#ifdef ENABLE_STATIC
|
#ifdef ENABLE_STATIC
|
||||||
int uid = 0; /* XXX: Fix better warning that dropprivs is disabled. */
|
int uid = 0; /* XXX: Fix better warning that dropprivs is disabled. */
|
||||||
|
int gid = 0;
|
||||||
#else
|
#else
|
||||||
int uid = getuser(svc->username, &home);
|
int uid = getuser(svc->username, &home);
|
||||||
|
int gid = getgroup(svc->group);
|
||||||
#endif
|
#endif
|
||||||
char *args[MAX_NUM_SVC_ARGS];
|
char *args[MAX_NUM_SVC_ARGS];
|
||||||
|
|
||||||
/* Set desired user */
|
/* Set desired user+group */
|
||||||
if (uid >= 0) {
|
if (uid >= 0) {
|
||||||
setuid(uid);
|
setuid(uid);
|
||||||
|
|
||||||
@@ -202,6 +204,9 @@ static int service_start(svc_t *svc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gid >= 0)
|
||||||
|
setgid(gid);
|
||||||
|
|
||||||
/* Serve copy of args to process in case it modifies them. */
|
/* 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++)
|
for (i = 0; i < (MAX_NUM_SVC_ARGS - 1) && svc->args[i][0] != 0; i++)
|
||||||
args[i] = svc->args[i];
|
args[i] = svc->args[i];
|
||||||
|
|||||||
Reference in new issue
Block a user