diff --git a/doc/manpages/dinit-service.5.m4 b/doc/manpages/dinit-service.5.m4 index 11775fdd..29fa1459 100644 --- a/doc/manpages/dinit-service.5.m4 +++ b/doc/manpages/dinit-service.5.m4 @@ -163,9 +163,11 @@ The value is subject to variable substitution (see \fBVARIABLE SUBSTITUTION\fR). Specifies which user to run the process(es) for this service as. Specify as a username or numeric ID. If specified by name, the group for the process will also be set to the primary -group of the specified user. -Supplementary groups will be initialized unless disabled, not supported on -the platform, or the user could not be found in passwd database. +group of the specified user, and supplementary groups will be initialised (unless support +for them is disabled) according to the system's group database. +If specified by number, the group for the process will remain the same as that of the +running \fBdinit\fR process, and all supplementary groups will be dropped (unless support +has been disabled). .TP \fBenv\-file\fR = \fIfile\fR Specifies a file containing value assignments for environment variables, in the same diff --git a/src/includes/load-service.h b/src/includes/load-service.h index 6d6973b1..61f4801b 100644 --- a/src/includes/load-service.h +++ b/src/includes/load-service.h @@ -1014,7 +1014,13 @@ class service_settings_wrapper // likewise for "run as" gid/uid, but only if we aren't supporting supplementary group initialisation // (if we do support supplementary groups, run_as_gid==-1 means "use the user groups including // supplementary groups" whereas run_as_gid==X means "use group X with no supplementary groups"). -#if !USE_INITGROUPS +#if USE_INITGROUPS + if (run_as_uid_gid == -1 && run_as_gid == -1) { + // run-as-UID specified by number; set run_as_gid to inhibit initialisation of + // supplementary groups + run_as_gid = getgid(); + } +#else // !USE_INITGROUPS if (run_as_gid == (gid_t)-1) run_as_gid = run_as_uid_gid; #endif