Commit 23cd0703 authored by Pavel Emelyanov's avatar Pavel Emelyanov

zdtp: Test that supplementary groups are supported

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent f429de66
...@@ -24,6 +24,7 @@ static/timers ...@@ -24,6 +24,7 @@ static/timers
static/futex static/futex
static/futex-rl static/futex-rl
static/xids00 static/xids00
static/groups
static/pthread00 static/pthread00
streaming/pipe_loop00 streaming/pipe_loop00
streaming/pipe_shared00 streaming/pipe_shared00
......
...@@ -47,6 +47,7 @@ TST_NOFILE = \ ...@@ -47,6 +47,7 @@ TST_NOFILE = \
sem \ sem \
maps01 \ maps01 \
xids00 \ xids00 \
groups \
file_fown \ file_fown \
eventfs00 \ eventfs00 \
signalfd00 \ signalfd00 \
......
#define _GNU_SOURCE
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <grp.h>
#include <sys/wait.h>
#include "zdtmtst.h"
const char *test_doc = "Check that supplementary groups are supported";
const char *test_author = "Pavel Emelianov <xemul@parallels.com>";
int main(int argc, char **argv)
{
unsigned int ng, *grp, *grp2, i, max;
test_init(argc, argv);
ng = getgroups(0, NULL);
if (ng < 0) {
err("Can't get groups");
return -1;
}
grp = malloc((ng + 1) * sizeof(*grp));
ng = getgroups(ng, grp);
if (ng < 0) {
err("Can't get groups2");
return -1;
}
max = 0;
for (i = 0; i < ng; i++)
if (max < grp[i])
max = grp[i];
grp[ng++] = max + 1;
if (setgroups(ng, grp) < 0) {
err("Can't set groups");
return -1;
}
test_daemon();
test_waitsig();
grp2 = malloc(ng * sizeof(*grp2));
if (getgroups(ng, grp2) != ng) {
fail("Nr groups changed");
return -1;
}
if (memcmp(grp, grp2, ng * sizeof(*grp))) {
fail("Groups have changed");
return -1;
}
pass();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment