[CRIU] [PATCH] zdtm: don't use getpwnam and getgrnam
Andrei Vagin
avagin at openvz.org
Fri Oct 13 11:22:08 MSK 2017
From: Andrei Vagin <avagin at virtuozzo.com>
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 at virtuozzo.com>
Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
test/zdtm/static/thread_different_uid_gid.c | 32 ++++----------------------
test/zdtm/static/thread_different_uid_gid.desc | 2 +-
2 files changed, 5 insertions(+), 29 deletions(-)
diff --git a/test/zdtm/static/thread_different_uid_gid.c b/test/zdtm/static/thread_different_uid_gid.c
index 1951668fb..2a5e4bdd8 100644
--- a/test/zdtm/static/thread_different_uid_gid.c
+++ b/test/zdtm/static/thread_different_uid_gid.c
@@ -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);
diff --git a/test/zdtm/static/thread_different_uid_gid.desc b/test/zdtm/static/thread_different_uid_gid.desc
index fa2c82d08..2eac7e654 100644
--- a/test/zdtm/static/thread_different_uid_gid.desc
+++ b/test/zdtm/static/thread_different_uid_gid.desc
@@ -1 +1 @@
-{'flavor': 'h', 'flags': 'suid'}
+{'flags': 'suid'}
--
2.13.3
More information about the CRIU
mailing list