Commit 907a444c authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

zdtm: use syscalls to set hostname and domaninname

We don't have enough permissions to set sysctl-s from userns, while
system calls are ns_capable()-protected in the kernel and thus work
in user-namespaces.
Signed-off-by: 's avatarAndrew Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 3ec9e128
...@@ -293,7 +293,6 @@ generate_test_list() ...@@ -293,7 +293,6 @@ generate_test_list()
ns/static/cow01 ns/static/cow01
ns/static/tempfs_ro ns/static/tempfs_ro
ns/static/ipc_namespace ns/static/ipc_namespace
ns/static/utsname
" "
# Add tests which can be executed in an user namespace # Add tests which can be executed in an user namespace
......
...@@ -15,39 +15,18 @@ static struct utsname after; ...@@ -15,39 +15,18 @@ static struct utsname after;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int ret;
int fd;
test_init(argc, argv); test_init(argc, argv);
fd = open("/proc/sys/kernel/hostname", O_WRONLY); if (sethostname(ZDTM_NODE, sizeof(ZDTM_NODE))) {
if (fd < 0) { pr_perror("Unable to set hostname");
pr_perror("Can't open hostname");
return 1;
}
ret = write(fd, ZDTM_NODE, sizeof(ZDTM_NODE));
if (ret != sizeof(ZDTM_NODE)) {
pr_perror("Can't write nodename");
return 1; return 1;
} }
close(fd); if (setdomainname(ZDTM_DOMAIN, sizeof(ZDTM_DOMAIN))) {
pr_perror("Unable to set domainname");
fd = open("/proc/sys/kernel/domainname", O_WRONLY);
if (fd < 0) {
pr_perror("Can't open domainname");
return -errno;
}
ret = write(fd, ZDTM_DOMAIN, sizeof(ZDTM_DOMAIN));
if (ret != sizeof(ZDTM_DOMAIN)) {
pr_perror("Can't write domainname");
return 1; return 1;
} }
close(fd);
test_daemon(); test_daemon();
test_waitsig(); test_waitsig();
......
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