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 <eblake@redhat.com>
This commit is contained in:
Eric Blake 2014-09-03 09:13:21 -06:00
parent e9f6937454
commit 0c07d360f6
19 changed files with 23 additions and 0 deletions

View File

@ -12,3 +12,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -12,3 +12,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -10,3 +10,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -10,3 +10,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -10,3 +10,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -10,3 +10,4 @@ FD:1
FD:2
DAEMON:no
CWD:.../commanddata
UMASK:0002

View File

@ -10,3 +10,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -11,3 +11,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -10,3 +10,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -5,3 +5,4 @@ FD:3
FD:4
DAEMON:yes
CWD:/
UMASK:0022

View File

@ -12,3 +12,4 @@ FD:5
FD:7
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -10,3 +10,4 @@ FD:1
FD:2
DAEMON:yes
CWD:/
UMASK:0022

View File

@ -8,3 +8,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -4,3 +4,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -9,3 +9,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -5,3 +5,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -18,3 +18,4 @@ FD:1
FD:2
DAEMON:no
CWD:/tmp
UMASK:0022

View File

@ -25,6 +25,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <sys/stat.h>
#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")) {

View File

@ -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());