service: lift the limit of four supplementary groups

A service listing more than four supplementary groups, in extra-groups
or as @user:group,sup1,sup2,..., got only the first four:

    too many supplementary groups, max 4

The names were stored in a fixed array of four.  It was also only
reset when the new configuration listed groups, so groups dropped from
a service lingered until reboot.

Store the list as one string, split when the service starts, and set
it on every (re)registration.  A list longer than 511 characters drops
the name it cuts off, which may otherwise match another group.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-17 06:21:24 +01:00
1 parent 8451c4087a
commit de73b06415
5 files changed
+76 -22

No files matched your search

+2 -3
View File
@@ -101,7 +101,7 @@ typedef enum {
#define MAX_STR_LEN 64
#define MAX_COND_LEN (MAX_ARG_LEN * 3)
#define MAX_USER_LEN MAX_ARG_LEN
#define MAX_NUM_SUPGROUPS 4
#define MAX_SUPGROUPS_LEN (MAX_CMD_LEN * 2)
#define MAX_NUM_PROVIDES 4
#define MAX_NUM_FDS 64 /* Max number of I/O plugins */
#define MAX_NUM_SVC_ARGS 64
@@ -200,8 +200,7 @@ typedef struct svc {
/* Identity */
char username[MAX_USER_LEN];
char group[MAX_USER_LEN];
char supgroups[MAX_NUM_SUPGROUPS][MAX_USER_LEN];
int num_supgroups;
char supgroups[MAX_SUPGROUPS_LEN]; /* sup1,sup2,... */
char capabilities[MAX_CMD_LEN];
char pam[MAX_ARG_LEN]; /* /etc/pam.d/NAME, block format only */