From 50864274db86625fd06f2f93feac0fe5ef1f5ef4 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Tue, 7 Feb 2017 11:43:31 +0300 Subject: [PATCH] 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 Signed-off-by: Pavel Emelyanov --- test/zdtm/static/Makefile | 3 +++ test/zdtm/static/pty-console.c | 1 + test/zdtm/static/pty-console.desc | 1 + test/zdtm/static/pty01.c | 14 ++++++++++++++ 4 files changed, 19 insertions(+) create mode 120000 test/zdtm/static/pty-console.c create mode 100644 test/zdtm/static/pty-console.desc diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile index e93edf150..11d6d9500 100644 --- a/test/zdtm/static/Makefile +++ b/test/zdtm/static/Makefile @@ -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) diff --git a/test/zdtm/static/pty-console.c b/test/zdtm/static/pty-console.c new file mode 120000 index 000000000..de7990f8d --- /dev/null +++ b/test/zdtm/static/pty-console.c @@ -0,0 +1 @@ +pty01.c \ No newline at end of file diff --git a/test/zdtm/static/pty-console.desc b/test/zdtm/static/pty-console.desc new file mode 100644 index 000000000..fba5e8749 --- /dev/null +++ b/test/zdtm/static/pty-console.desc @@ -0,0 +1 @@ +{'flags': 'suid', 'flavor' : 'ns uns'} diff --git a/test/zdtm/static/pty01.c b/test/zdtm/static/pty01.c index fdf10b988..29b20601f 100644 --- a/test/zdtm/static/pty01.c +++ b/test/zdtm/static/pty01.c @@ -9,6 +9,7 @@ #include #include #include +#include #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;