mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-25 23:21:33 +03:00
test-condition: fix test_condition_test_group() (#6531)
I hit a test failure with the `max_gid+1` test. Problem is that we loop over 0..r, but set `r` again within the loop (to 1). So max_gid is only set based on the first supplementary GID. ConditionGroup=1000 → 1 ConditionGroup=4 → 1 ConditionGroup=adm → 1 ConditionGroup=1001 → 1 Assertion 'r == 0' failed at ../src/test/test-condition.c:462, function test_condition_test_group(). Aborting. $ id uid=1000(alan-sysop) gid=1000(alan-sysop) groups=1000(alan-sysop),4(adm), 10(wheel),1001(sshlogin)
This commit is contained in:
parent
d7cefe8b2b
commit
ecaa5ad89f
@ -402,7 +402,7 @@ static void test_condition_test_group(void) {
|
||||
char* gid;
|
||||
char* groupname;
|
||||
gid_t *gids, max_gid;
|
||||
int ngroups_max, r, i;
|
||||
int ngroups_max, ngroups, r, i;
|
||||
|
||||
assert_se(0 < asprintf(&gid, "%u", UINT32_C(0xFFFF)));
|
||||
condition = condition_new(CONDITION_GROUP, gid, false, false);
|
||||
@ -427,11 +427,11 @@ static void test_condition_test_group(void) {
|
||||
|
||||
gids = alloca(sizeof(gid_t) * ngroups_max);
|
||||
|
||||
r = getgroups(ngroups_max, gids);
|
||||
assert(r >= 0);
|
||||
ngroups = getgroups(ngroups_max, gids);
|
||||
assert(ngroups >= 0);
|
||||
|
||||
max_gid = getgid();
|
||||
for (i = 0; i < r; i++) {
|
||||
for (i = 0; i < ngroups; i++) {
|
||||
assert_se(0 < asprintf(&gid, "%u", gids[i]));
|
||||
condition = condition_new(CONDITION_GROUP, gid, false, false);
|
||||
assert_se(condition);
|
||||
|
Loading…
Reference in New Issue
Block a user