<div dir="ltr"><div>From: Yicheng Qin &lt;<a href="mailto:yichengq@google.com">yichengq@google.com</a>&gt;</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><br></div><div>Mountpoints test unlinks and makes new /dev/null inside. But</div><div>it may happen that the default umask is not 0, e.g., 022. This means that</div>
<div>/dev/null created directly cannot be written 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 &lt;<a href="mailto:yichengq@google.com">yichengq@google.com</a>&gt;</div>
<div>---</div><div> test/zdtm/live/static/mountpoints.c | 12 +++++++++++-</div><div> 1 file changed, 11 insertions(+), 1 deletion(-)</div><div><br></div><div>diff --git a/test/zdtm/live/static/mountpoints.c b/test/zdtm/live/static/mountpoints.c</div>
<div>index 1109711..ee75f9b 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> </div><div> again:</div><div>        fs_cnt = 0;</div><div>@@ -121,7 +122,16 @@ done:</div>
<div>        }</div><div> </div><div>        unlink(&quot;/dev/null&quot;);</div><div>-       mknod(&quot;/dev/null&quot;, 0777 | S_IFCHR, makedev(1, 3));</div><div>+       /*</div><div>+        * Clear umask first, create readable &amp; 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(&quot;/dev/null&quot;, S_IRWXU | S_IRWXG | S_IRWXO | S_IFCHR,</div><div>+               makedev(1, 3));</div><div>+       umask(old_mask);</div>
<div> </div><div>        setup_outfile();</div><div> </div><div>-- </div><div>1.8.3</div></div>