mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 06:45:35 +00:00
zdtm: set additional groups along with uids and gids
Currently zdtm doesn't set additional groups when running tests. It sets uids and gids to some non-root values, but additional groups remain untouched, which allows tests to inherit groups list, which leads to different behaviour depending on a way you run tests. Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com> Acked-by: Andrew Vagin <avagin@parallels.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
8eaf0142ab
commit
7dbd38dbc9
@@ -475,10 +475,12 @@ start_test()
|
|||||||
|
|
||||||
unset ZDTM_UID
|
unset ZDTM_UID
|
||||||
unset ZDTM_GID
|
unset ZDTM_GID
|
||||||
|
unset ZDTM_GROUPS
|
||||||
|
|
||||||
if ! echo $TEST_SUID_LIST | grep -q $tname; then
|
if ! echo $TEST_SUID_LIST | grep -q $tname; then
|
||||||
export ZDTM_UID=18943
|
export ZDTM_UID=18943
|
||||||
export ZDTM_GID=58467
|
export ZDTM_GID=58467
|
||||||
|
export ZDTM_GROUPS="27495 48244"
|
||||||
chmod a+w $tdir
|
chmod a+w $tdir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
|
#include <grp.h>
|
||||||
|
|
||||||
#include "zdtmtst.h"
|
#include "zdtmtst.h"
|
||||||
#include "lock.h"
|
#include "lock.h"
|
||||||
@@ -120,6 +121,24 @@ void test_init(int argc, char **argv)
|
|||||||
/* "3" -- run the test */
|
/* "3" -- run the test */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val = getenv("ZDTM_GROUPS");
|
||||||
|
if (val) {
|
||||||
|
char *tok = NULL;
|
||||||
|
unsigned int size = 0, groups[NGROUPS_MAX];
|
||||||
|
|
||||||
|
tok = strtok(val, " ");
|
||||||
|
while (tok) {
|
||||||
|
size++;
|
||||||
|
groups[size - 1] = atoi(tok);
|
||||||
|
tok = strtok(NULL, " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setgroups(size, groups)) {
|
||||||
|
fprintf(stderr, "Can't set groups: %m");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val = getenv("ZDTM_GID");
|
val = getenv("ZDTM_GID");
|
||||||
if (val && (setgid(atoi(val)) == -1)) {
|
if (val && (setgid(atoi(val)) == -1)) {
|
||||||
fprintf(stderr, "Can't set gid: %m");
|
fprintf(stderr, "Can't set gid: %m");
|
||||||
|
Reference in New Issue
Block a user