<div dir="ltr"><div>From: Yicheng Qin <<a href="mailto:yichengq@google.com">yichengq@google.com</a>></div><div>Subject: [PATCH] test/zdtm/mountpoints: clear the umask when creating</div><div> /dev/null</div><div><br>
</div><div>Clear the umask when creating /dev/null and restore the umask</div><div>after the creation.</div><div>Mountpoints test unlinks and makes new /dev/null inside by mknod.</div><div>But in some linux, there is default umask, e.g., as 022. It means that</div>
<div>/dev/null created directly cannot be wrote by group and other users.</div><div>It is not reasonable because /dev/null should be accessable to all</div><div>users.</div><div><br></div><div>Signed-off-by: Yicheng Qin <<a href="mailto:yichengq@google.com">yichengq@google.com</a>></div>
<div>---</div><div> test/zdtm/live/static/mountpoints.c | 9 +++++++++</div><div> 1 file changed, 9 insertions(+)</div><div><br></div><div>diff --git a/test/zdtm/live/static/mountpoints.c b/test/zdtm/live/static/mountpoints.c</div>
<div>index dde9de8..a1f8dea 100644</div><div>--- a/test/zdtm/live/static/mountpoints.c</div><div>+++ b/test/zdtm/live/static/mountpoints.c</div><div>@@ -20,6 +20,7 @@ static int test_fn(int argc, char **argv)</div><div> int fd, tmpfs_fd;</div>
<div> unsigned fs_cnt, fs_cnt_last = 0;</div><div> bool private = false;</div><div>+ mode_t old_mask;</div><div><br></div><div> again:</div><div> fs_cnt = 0;</div><div>@@ -108,7 +109,15 @@ done:</div>
<div> }</div><div><br></div><div> unlink("/dev/null");</div><div>+ /*</div><div>+ * Clear umask first, create readable & writeable /dev/null,</div><div>+ * and change it back. This is done to ensure that file mode</div>
<div>+ * creation mask will not impede it to create file that grants</div><div>+ * read and write permission to all users.</div><div>+ */</div><div>+ old_mask = umask(0);</div><div> mknod("/dev/null", 0777 | S_IFCHR, makedev(1, 3));</div>
<div>+ umask(old_mask);</div><div><br></div><div> setup_outfile();</div></div>