Commit b20ee877 authored by Yicheng Qin's avatar Yicheng Qin Committed by Pavel Emelyanov

test/zdtm/mountpoints: clear the umask when creating

 /dev/null

Clear the umask when creating /dev/null and restore the umask
after the creation.
Mountpoints test unlinks and makes new /dev/null inside by mknod.
But in some linux, there is default umask, e.g., as 022. It means that
/dev/null created directly cannot be wrote by group and other users.
It is not reasonable because /dev/null should be accessable to all
users.
Signed-off-by: 's avatarYicheng Qin <yichengq@google.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent fe01c987
......@@ -20,6 +20,7 @@ static int test_fn(int argc, char **argv)
int fd, tmpfs_fd;
unsigned fs_cnt, fs_cnt_last = 0;
bool private = false;
mode_t old_mask;
again:
fs_cnt = 0;
......@@ -121,7 +122,15 @@ done:
}
unlink("/dev/null");
/*
* Clear umask first, create readable & writeable /dev/null,
* and change it back. This is done to ensure that file mode
* creation mask will not impede it to create file that grants
* read and write permission to all users.
*/
old_mask = umask(0);
mknod("/dev/null", 0777 | S_IFCHR, makedev(1, 3));
umask(old_mask);
setup_outfile();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment