mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 09:58:09 +00:00
zdtm: don't use getpwnam and getgrnam
For us it doesn't matter what names of users and groups are used, we want to be sure that we restore right uid-s and gid-s. If we use these functions, we can't run tests in namespaces and they use an external unix socket, what can be a problem too. sk unix: Runaway socket: ino 0x1df1ae4 peer_ino 0x1df1ae3 family 1 type 1 state 1 name /run/dbus/system_bus_socket Error (criu/sk-unix.c:712): sk unix: External socket is used. Consider using --ext-unix-sk option. Cc: Vitaly Ostrosablin <vostrosablin@virtuozzo.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
ac21ffe215
commit
44dc01597a
@ -6,7 +6,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <syscall.h>
|
||||
|
||||
@ -81,8 +80,6 @@ int main(int argc, char **argv)
|
||||
|
||||
int ret;
|
||||
cap_t newcaps;
|
||||
struct group *group;
|
||||
struct passwd *user;
|
||||
pthread_t diff_cred_thread;
|
||||
test_init(argc, argv);
|
||||
int maingroup;
|
||||
@ -115,31 +112,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
test_msg("Main thread runs as UID: %d; GID: %d\n", getuid(), getgid());
|
||||
group = getgrnam("nogroup");
|
||||
group = (group) ? group : getgrnam("nobody");
|
||||
if (!group) {
|
||||
pr_perror("Failed to get nogroup/nobody GID\n");
|
||||
exit(1);
|
||||
}
|
||||
user = getpwnam("nobody");
|
||||
if (!user) {
|
||||
pr_perror("Failed to get nobody UID\n");
|
||||
exit(1);
|
||||
}
|
||||
gid = group->gr_gid;
|
||||
uid = user->pw_uid;
|
||||
group = getgrnam("mail");
|
||||
if (!group) {
|
||||
pr_perror("Failed to get mail GID\n");
|
||||
exit(1);
|
||||
}
|
||||
user = getpwnam("mail");
|
||||
if (!user) {
|
||||
pr_perror("Failed to get mail UID\n");
|
||||
exit(1);
|
||||
}
|
||||
maingroup = group->gr_gid;
|
||||
mainuser = user->pw_uid;
|
||||
gid = 99;
|
||||
uid = 99;
|
||||
maingroup = 8;
|
||||
mainuser = 12;
|
||||
|
||||
test_msg("Creating thread with different UID/GID\n");
|
||||
ret = pthread_create(&diff_cred_thread, NULL, &chg_uid_gid, NULL);
|
||||
|
@ -1 +1 @@
|
||||
{'flavor': 'h', 'flags': 'suid'}
|
||||
{'flags': 'suid'}
|
||||
|
Loading…
x
Reference in New Issue
Block a user