mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
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:
parent
e9f6937454
commit
0c07d360f6
@ -12,3 +12,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -12,3 +12,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -10,3 +10,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -10,3 +10,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -10,3 +10,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -10,3 +10,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:.../commanddata
|
||||
UMASK:0002
|
||||
|
@ -10,3 +10,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -11,3 +11,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -10,3 +10,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -5,3 +5,4 @@ FD:3
|
||||
FD:4
|
||||
DAEMON:yes
|
||||
CWD:/
|
||||
UMASK:0022
|
||||
|
@ -12,3 +12,4 @@ FD:5
|
||||
FD:7
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -10,3 +10,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:yes
|
||||
CWD:/
|
||||
UMASK:0022
|
||||
|
@ -8,3 +8,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -4,3 +4,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -9,3 +9,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -5,3 +5,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -18,3 +18,4 @@ FD:1
|
||||
FD:2
|
||||
DAEMON:no
|
||||
CWD:/tmp
|
||||
UMASK:0022
|
||||
|
@ -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")) {
|
||||
|
@ -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());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user