From 0c07d360f68e5075ac03ae061f0598d654a0e009 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 3 Sep 2014 09:13:21 -0600 Subject: [PATCH] command: test umask support Add testsuite coverage for the recent commit 0e1a1a8. * tests/commandhelper.c (main): Output umask. * tests/commandtest.c (test15): Also test umask. (mymain): Add test. * tests/commanddata/*.log: Update expected output. Signed-off-by: Eric Blake --- tests/commanddata/test10.log | 1 + tests/commanddata/test11.log | 1 + tests/commanddata/test12.log | 1 + tests/commanddata/test13.log | 1 + tests/commanddata/test14.log | 1 + tests/commanddata/test15.log | 1 + tests/commanddata/test2.log | 1 + tests/commanddata/test20.log | 1 + tests/commanddata/test21.log | 1 + tests/commanddata/test24.log | 1 + tests/commanddata/test3.log | 1 + tests/commanddata/test4.log | 1 + tests/commanddata/test5.log | 1 + tests/commanddata/test6.log | 1 + tests/commanddata/test7.log | 1 + tests/commanddata/test8.log | 1 + tests/commanddata/test9.log | 1 + tests/commandhelper.c | 3 +++ tests/commandtest.c | 3 +++ 19 files changed, 23 insertions(+) diff --git a/tests/commanddata/test10.log b/tests/commanddata/test10.log index e1d60927d1..6b22786532 100644 --- a/tests/commanddata/test10.log +++ b/tests/commanddata/test10.log @@ -12,3 +12,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test11.log b/tests/commanddata/test11.log index e1d60927d1..6b22786532 100644 --- a/tests/commanddata/test11.log +++ b/tests/commanddata/test11.log @@ -12,3 +12,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test12.log b/tests/commanddata/test12.log index 1b59206352..703e6dae91 100644 --- a/tests/commanddata/test12.log +++ b/tests/commanddata/test12.log @@ -10,3 +10,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test13.log b/tests/commanddata/test13.log index 1b59206352..703e6dae91 100644 --- a/tests/commanddata/test13.log +++ b/tests/commanddata/test13.log @@ -10,3 +10,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test14.log b/tests/commanddata/test14.log index 1b59206352..703e6dae91 100644 --- a/tests/commanddata/test14.log +++ b/tests/commanddata/test14.log @@ -10,3 +10,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test15.log b/tests/commanddata/test15.log index f439a85dfd..edb2fc3fac 100644 --- a/tests/commanddata/test15.log +++ b/tests/commanddata/test15.log @@ -10,3 +10,4 @@ FD:1 FD:2 DAEMON:no CWD:.../commanddata +UMASK:0002 diff --git a/tests/commanddata/test2.log b/tests/commanddata/test2.log index 1b59206352..703e6dae91 100644 --- a/tests/commanddata/test2.log +++ b/tests/commanddata/test2.log @@ -10,3 +10,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test20.log b/tests/commanddata/test20.log index 7d48121f30..a0475e6f4e 100644 --- a/tests/commanddata/test20.log +++ b/tests/commanddata/test20.log @@ -11,3 +11,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test21.log b/tests/commanddata/test21.log index 1b59206352..703e6dae91 100644 --- a/tests/commanddata/test21.log +++ b/tests/commanddata/test21.log @@ -10,3 +10,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test24.log b/tests/commanddata/test24.log index 8670952cad..38cbb5451b 100644 --- a/tests/commanddata/test24.log +++ b/tests/commanddata/test24.log @@ -5,3 +5,4 @@ FD:3 FD:4 DAEMON:yes CWD:/ +UMASK:0022 diff --git a/tests/commanddata/test3.log b/tests/commanddata/test3.log index c6da25345c..f44400bc82 100644 --- a/tests/commanddata/test3.log +++ b/tests/commanddata/test3.log @@ -12,3 +12,4 @@ FD:5 FD:7 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test4.log b/tests/commanddata/test4.log index 1876685a68..6cd20959d3 100644 --- a/tests/commanddata/test4.log +++ b/tests/commanddata/test4.log @@ -10,3 +10,4 @@ FD:1 FD:2 DAEMON:yes CWD:/ +UMASK:0022 diff --git a/tests/commanddata/test5.log b/tests/commanddata/test5.log index f745c3f558..f801dca886 100644 --- a/tests/commanddata/test5.log +++ b/tests/commanddata/test5.log @@ -8,3 +8,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test6.log b/tests/commanddata/test6.log index 5394428162..1476995794 100644 --- a/tests/commanddata/test6.log +++ b/tests/commanddata/test6.log @@ -4,3 +4,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test7.log b/tests/commanddata/test7.log index cdfe445e3b..e30efe7b6c 100644 --- a/tests/commanddata/test7.log +++ b/tests/commanddata/test7.log @@ -9,3 +9,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test8.log b/tests/commanddata/test8.log index 87874fde0a..897bf6e5b9 100644 --- a/tests/commanddata/test8.log +++ b/tests/commanddata/test8.log @@ -5,3 +5,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commanddata/test9.log b/tests/commanddata/test9.log index 3a93c19ea4..e9e1611528 100644 --- a/tests/commanddata/test9.log +++ b/tests/commanddata/test9.log @@ -18,3 +18,4 @@ FD:1 FD:2 DAEMON:no CWD:/tmp +UMASK:0022 diff --git a/tests/commandhelper.c b/tests/commandhelper.c index 796b89d8b0..03fe50625a 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "internal.h" #include "virutil.h" @@ -121,6 +122,8 @@ int main(int argc, char **argv) { fprintf(log, "CWD:%s\n", cwd); VIR_FREE(cwd); + fprintf(log, "UMASK:%04o\n", umask(0)); + VIR_FORCE_FCLOSE(log); if (argc > 1 && STREQ(argv[1], "--close-stdin")) { diff --git a/tests/commandtest.c b/tests/commandtest.c index 5f52a0085d..6400ea283f 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -617,6 +617,7 @@ static int test15(const void *unused ATTRIBUTE_UNUSED) if (virAsprintf(&cwd, "%s/commanddata", abs_srcdir) < 0) goto cleanup; virCommandSetWorkingDirectory(cmd, cwd); + virCommandSetUmask(cmd, 002); if (virCommandRun(cmd, NULL) < 0) { virErrorPtr err = virGetLastError(); @@ -1133,6 +1134,8 @@ mymain(void) if (chdir("/tmp") < 0) return EXIT_FAILURE; + umask(022); + setpgid(0, 0); ignore_value(setsid());