]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Tests: Create files with mode 0666, not 0777 (bug 33171)
authorFlorian Weimer <fweimer@redhat.com>
Mon, 1 Sep 2025 13:05:16 +0000 (15:05 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 1 Sep 2025 13:12:28 +0000 (15:12 +0200)
Mode 0777 should be used for directories only because it results
in executable entries (after typical umasks are applied).

Reviewed-by: Arjun Shankar <arjun@redhat.com>
io/tst-ftw-lnk.c
posix/tst-spawn-chdir.c
stdio-common/tst-setvbuf2.c
stdlib/test-canon.c
support/shell-container.c
support/test-container.c

index 88f1926814ce0f2b0c106695a0b721ebeb0cc017..4538f35a3a66b71c547541fc9e125ea1482737ef 100644 (file)
@@ -217,7 +217,7 @@ do_test (void)
     FAIL_EXIT1 ("symlink link1-bad failed");
   if (symlink ("link2-tgt", "link2-ok") < 0)
     FAIL_EXIT1 ("symlink link2-ok failed");
-  if (open ("link2-tgt", O_RDWR|O_CREAT, 0777) < 0)
+  if (open ("link2-tgt", O_RDWR|O_CREAT, 0666) < 0)
     FAIL_EXIT1 ("create of link2-tgt failed");
 
   /* Now we run the tests.  */
index b97cd3a2d6a4d134caee531cd1c347f2be87e761..1b1323fd6a700843db9aa2ac1479f8d36db4ed8d 100644 (file)
@@ -156,13 +156,13 @@ do_test (void)
           TEST_COMPARE (posix_spawn_file_actions_addopen
                         (&actions, 3, /* Arbitrary unused descriptor.  */
                          "probe-file",
-                         O_WRONLY | O_CREAT | O_EXCL, 0777), 0);
+                         O_WRONLY | O_CREAT | O_EXCL, 0666), 0);
           TEST_COMPARE (posix_spawn_file_actions_addclose (&actions, 3), 0);
           /* Run the actual in iteration_directory.  */
           add_chdir (&actions, "..", do_fchdir, 5);
           TEST_COMPARE (posix_spawn_file_actions_addopen
                         (&actions, STDOUT_FILENO, "output-file",
-                         O_WRONLY | O_CREAT | O_EXCL, 0777), 0);
+                         O_WRONLY | O_CREAT | O_EXCL, 0666), 0);
 
           /* Check that posix_spawn_file_actions_addchdir_np made a copy
              of the path.  */
index 84d8b43a5811b4be257ab65dfa30cc610270b76a..d791b19eb0b146cb0a823d1ae813adceaf7289c3 100644 (file)
@@ -265,7 +265,7 @@ writer_thread_proc (void *closure)
   debug;
 
   if (td->fname)
-    td->fd = xopen (td->fname, O_WRONLY, 0777);
+    td->fd = xopen (td->fname, O_WRONLY, 0666);
   fd = td->fd;
 
   while (1)
@@ -292,7 +292,7 @@ reader_thread_proc (void *closure)
   debug;
 
   if (td->fname)
-    td->fd = xopen (td->fname, O_RDONLY, 0777);
+    td->fd = xopen (td->fname, O_RDONLY, 0666);
   fd = td->fd;
 
   while (1)
@@ -538,7 +538,7 @@ open_test_stream (enum test_source_case f, enum test_stream_case s)
       break;
 
     case test_stream_fdopen_w:
-      fd = xopen (fname, O_WRONLY|O_CREAT|O_TRUNC, 0777);
+      fd = xopen (fname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
       fp = fdopen (fd, "w");
       break;
 
@@ -1030,4 +1030,3 @@ do_test (void)
 
 # include <support/test-driver.c>
 #endif
-
index 51b0af1773a5fd17760b5ee0bd0b7ecdbb152cbf..51ac60d412a06bf9dfe0208d172b0e0a65cdf8bd 100644 (file)
@@ -165,7 +165,7 @@ do_test (int argc, char ** argv)
 
   int has_dir = mkdir ("doesExist", 0777) == 0;
 
-  int fd = has_dir ? creat ("doesExist/someFile", 0777) : -1;
+  int fd = has_dir ? creat ("doesExist/someFile", 0666) : -1;
 
   for (i = 0; i < (int) (sizeof (tests) / sizeof (tests[0])); ++i)
     {
index dcf53add07af4e9734cb4fd272ab108d605804bc..06f3212488fc934317cabd74caf62171a78ea585 100644 (file)
@@ -237,25 +237,25 @@ run_command_array (char **argv)
     {
       if (strcmp (argv[i], "<") == 0 && argv[i + 1])
        {
-         new_stdin = open (argv[i + 1], O_WRONLY|O_CREAT|O_TRUNC, 0777);
+         new_stdin = open (argv[i + 1], O_WRONLY|O_CREAT|O_TRUNC, 0666);
          ++i;
          continue;
        }
       if (strcmp (argv[i], ">") == 0 && argv[i + 1])
        {
-         new_stdout = open (argv[i + 1], O_WRONLY|O_CREAT|O_TRUNC, 0777);
+         new_stdout = open (argv[i + 1], O_WRONLY|O_CREAT|O_TRUNC, 0666);
          ++i;
          continue;
        }
       if (strcmp (argv[i], ">>") == 0 && argv[i + 1])
        {
-         new_stdout = open (argv[i + 1], O_WRONLY|O_CREAT|O_APPEND, 0777);
+         new_stdout = open (argv[i + 1], O_WRONLY|O_CREAT|O_APPEND, 0666);
          ++i;
          continue;
        }
       if (strcmp (argv[i], "2>") == 0 && argv[i + 1])
        {
-         new_stderr = open (argv[i + 1], O_WRONLY|O_CREAT|O_TRUNC, 0777);
+         new_stderr = open (argv[i + 1], O_WRONLY|O_CREAT|O_TRUNC, 0666);
          ++i;
          continue;
        }
index 1c40ab377fe4fb95a67f79b5fede09adb2c6940a..ae643d307ec71b5e905e7aa80ef1a46db046762d 100644 (file)
@@ -273,7 +273,7 @@ devmount (const char *new_root_path, const char *which)
 {
   int fd;
   fd = open (concat (new_root_path, "/dev/", which, NULL),
-            O_CREAT | O_TRUNC | O_RDWR, 0777);
+            O_CREAT | O_TRUNC | O_RDWR, 0666);
   xclose (fd);
 
   trymount (concat ("/dev/", which, NULL),