zdtm: check a case when a slave pty is mounted to somewhere

travis-ci: success for A few fixes to c/r a docker container with a console (rev3)
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Andrei Vagin 2017-02-07 11:43:31 +03:00
parent aa26237e51
commit 50864274db
4 changed files with 19 additions and 0 deletions

View file

@ -114,6 +114,7 @@ TST_NOFILE := \
rlimits00 \
pty00 \
pty01 \
pty-console \
pty02 \
pty03 \
pty04 \
@ -452,6 +453,8 @@ socket-tcp6-last-ack: override CFLAGS += -D ZDTM_TCP_LAST_ACK -D ZDTM_IPV6
socket-tcp6-closing: override CFLAGS += -D ZDTM_IPV6
socket-tcp6-unconn: override CFLAGS += -D ZDTM_IPV6
pty-console: override CFLAGS += -D ZDTM_DEV_CONSOLE
$(LIB): force
$(Q) $(MAKE) -C $(LIBDIR)

View file

@ -0,0 +1 @@
pty01.c

View file

@ -0,0 +1 @@
{'flags': 'suid', 'flavor' : 'ns uns'}

View file

@ -9,6 +9,7 @@
#include <string.h>
#include <termios.h>
#include <signal.h>
#include <sys/mount.h>
#include "zdtmtst.h"
@ -51,6 +52,19 @@ int main(int argc, char *argv[])
return 1;
}
#ifdef ZDTM_DEV_CONSOLE
{
int fd;
fd = open("/dev/console", O_CREAT | O_RDONLY, 0755);
if (fd < 0)
return -1;
close(fd);
if (mount(slavename, "/dev/console", NULL, MS_BIND, NULL))
return -1;
}
#endif
if (fchown(slave1, new_uid, new_gid)) {
pr_perror("Can't set uid/gid on %s", slavename);
return 1;