mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-28 12:36:47 +00:00
test: pty01 -- Add custom uid/gid
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
parent
4f99370cb8
commit
eb22658ea4
2 changed files with 26 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#define _XOPEN_SOURCE 500
|
||||
#define _DEFAULT_SOURCE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "zdtmtst.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
|
@ -9,6 +10,8 @@
|
|||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "zdtmtst.h"
|
||||
|
||||
const char *test_doc = "Check two pts on ptmx";
|
||||
const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>";
|
||||
|
||||
|
|
@ -19,6 +22,10 @@ int main(int argc, char *argv[])
|
|||
char buf[sizeof(teststr)];
|
||||
int master, slave1, slave2, ret;
|
||||
char *slavename;
|
||||
struct stat st;
|
||||
|
||||
uid_t new_uid = 33333;
|
||||
gid_t new_gid = 44444;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
|
|
@ -44,11 +51,28 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (fchown(slave1, new_uid, new_gid)) {
|
||||
pr_perror("Can't set uid/gid on %s", slavename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
test_daemon();
|
||||
test_waitsig();
|
||||
|
||||
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);
|
||||
if (ret != sizeof(teststr) - 1) {
|
||||
pr_perror("write(master) failed");
|
||||
|
|
|
|||
1
test/zdtm/static/pty01.desc
Normal file
1
test/zdtm/static/pty01.desc
Normal file
|
|
@ -0,0 +1 @@
|
|||
{'flags': 'suid'}
|
||||
Loading…
Add table
Add a link
Reference in a new issue