* [LTP] [PATCH] syscalls/chdir01: Add umask before mkdir
@ 2021-03-17 7:26 Zhao Gongyi
2021-03-30 13:06 ` Petr Vorel
0 siblings, 1 reply; 4+ messages in thread
From: Zhao Gongyi @ 2021-03-17 7:26 UTC (permalink / raw)
To: ltp
When uid is nobody, umask is not 022, the test process might
has not permmission to access the file which created by SAFE_MKDIR
with mode 0755.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
testcases/kernel/syscalls/chdir/chdir01.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/testcases/kernel/syscalls/chdir/chdir01.c b/testcases/kernel/syscalls/chdir/chdir01.c
index 60165a6cb..a378b260c 100644
--- a/testcases/kernel/syscalls/chdir/chdir01.c
+++ b/testcases/kernel/syscalls/chdir/chdir01.c
@@ -13,6 +13,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
@@ -55,6 +56,14 @@ static void setup(void)
sprintf(workdir, "%s/%s", cwd, MNTPOINT);
free(cwd);
SAFE_CHDIR(workdir);
+
+ /*
+ * When uid is nobody, umask is not 022, the test process might
+ * has not permmission to access the file which created by SAFE_MKDIR
+ * with mode 0755.
+ */
+ umask(022);
+
SAFE_MKDIR(DIR_NAME, 0755);
SAFE_MKDIR(BLOCKED_NAME, 0644);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH] syscalls/chdir01: Add umask before mkdir
@ 2021-03-30 13:17 zhaogongyi
2021-03-30 16:53 ` Petr Vorel
0 siblings, 1 reply; 4+ messages in thread
From: zhaogongyi @ 2021-03-30 13:17 UTC (permalink / raw)
To: ltp
Hi Petr,
Umask is always 022 in many system env. In this testcase, if umask is not 022, for example, umask is 0077, test would fail because the file mode is affected by umask.
Thanks!
Best Regards,
Gongyi
>
> > When uid is nobody, umask is not 022, the test process might
> Not sure if I understand "When uid is nobody, umask is not 022", umask
> setup depends usually on the system. I wonder which system has different
> setup for nobody.
>
> BTW later was posted another solution, see my comments there.
>
> Kind regards,
> Petr
>
> [2]
> https://patchwork.ozlabs.org/project/ltp/patch/20210322091512.103266
> -1-xieziyao@huawei.com/
>
> > has not permmission to access the file which created by SAFE_MKDIR
> > with mode 0755.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] syscalls/chdir01: Add umask before mkdir
2021-03-30 13:17 zhaogongyi
@ 2021-03-30 16:53 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2021-03-30 16:53 UTC (permalink / raw)
To: ltp
Hi Gongyi,
> Umask is always 022 in many system env. In this testcase, if umask is not 022,
> for example, umask is 0077, test would fail because the file mode is affected
> by umask.
Thanks a lot for a giving example. I tested only 0066.
I'm sorry I accepted the Ziyao version as it had better description, reverted
back changes and will work on any mode in SAFE_MKDIR(). I put your Reported-by:
tag.
I'll also send one more fix for exfat.
Kind regards,
Petr
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-30 16:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-17 7:26 [LTP] [PATCH] syscalls/chdir01: Add umask before mkdir Zhao Gongyi
2021-03-30 13:06 ` Petr Vorel
-- strict thread matches above, loose matches on Subject: below --
2021-03-30 13:17 zhaogongyi
2021-03-30 16:53 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox