Commit eb22658e authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

test: pty01 -- Add custom uid/gid

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 4f99370c
#define _XOPEN_SOURCE 500 #define _XOPEN_SOURCE 500
#define _DEFAULT_SOURCE
#include <stdlib.h> #include <stdlib.h>
#include "zdtmtst.h"
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -9,6 +10,8 @@ ...@@ -9,6 +10,8 @@
#include <termios.h> #include <termios.h>
#include <signal.h> #include <signal.h>
#include "zdtmtst.h"
const char *test_doc = "Check two pts on ptmx"; const char *test_doc = "Check two pts on ptmx";
const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>"; const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>";
...@@ -19,6 +22,10 @@ int main(int argc, char *argv[]) ...@@ -19,6 +22,10 @@ int main(int argc, char *argv[])
char buf[sizeof(teststr)]; char buf[sizeof(teststr)];
int master, slave1, slave2, ret; int master, slave1, slave2, ret;
char *slavename; char *slavename;
struct stat st;
uid_t new_uid = 33333;
gid_t new_gid = 44444;
test_init(argc, argv); test_init(argc, argv);
...@@ -44,11 +51,28 @@ int main(int argc, char *argv[]) ...@@ -44,11 +51,28 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
if (fchown(slave1, new_uid, new_gid)) {
pr_perror("Can't set uid/gid on %s", slavename);
return 1;
}
test_daemon(); test_daemon();
test_waitsig(); test_waitsig();
signal(SIGHUP, SIG_IGN); signal(SIGHUP, SIG_IGN);
if (fstat(slave1, &st)) {
pr_perror("Can't fetch stat on %s", slavename);
return 1;
}
if (st.st_uid != new_uid || st.st_gid != new_gid) {
fail("UID/GID mismatch (got %d/%d but %d/%d expected)",
(int)st.st_uid, (int)st.st_gid,
(int)new_uid, (int)new_gid);
return 1;
}
ret = write(master, teststr, sizeof(teststr) - 1); ret = write(master, teststr, sizeof(teststr) - 1);
if (ret != sizeof(teststr) - 1) { if (ret != sizeof(teststr) - 1) {
pr_perror("write(master) failed"); pr_perror("write(master) failed");
......
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