From de2aa73d68291a72a3109b17ffa3d907a0b64c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20B=C3=A9rat?= Date: Wed, 8 Jan 2025 17:15:50 +0100 Subject: [PATCH] Backport mkdirat mode test Resolves: RHEL-56743 --- glibc-RHEL-56743.patch | 79 ++++++++++++++++++++++++++++++++++++++++++ glibc.spec | 2 ++ 2 files changed, 81 insertions(+) create mode 100644 glibc-RHEL-56743.patch diff --git a/glibc-RHEL-56743.patch b/glibc-RHEL-56743.patch new file mode 100644 index 0000000..e7b1bda --- /dev/null +++ b/glibc-RHEL-56743.patch @@ -0,0 +1,79 @@ +commit 55cd51d971b84fbb2cc0fe8140cc8581f98582c7 +Author: Joseph Myers +Date: Thu Aug 22 11:25:14 2024 +0000 + + Test mkdirat use of mode argument + + The test io/tst-mkdirat doesn't verify the permissions on the created + directory (thus, doesn't verify at all anything about how mkdirat uses + the mode argument). Add checks of this to the existing test. + + Tested for x86_64. + +diff --git a/io/tst-mkdirat.c b/io/tst-mkdirat.c +index 605e51ef1e966b42..b97bc3ca6d0cdf23 100644 +--- a/io/tst-mkdirat.c ++++ b/io/tst-mkdirat.c +@@ -53,6 +53,10 @@ prepare (void) + static int + do_test (void) + { ++ /* Find the current umask. */ ++ mode_t mask = umask (022); ++ umask (mask); ++ + /* fdopendir takes over the descriptor, make a copy. */ + int dupfd = dup (dir_fd); + if (dupfd == -1) +@@ -107,6 +111,13 @@ do_test (void) + puts ("mkdirat did not create a directory"); + return 1; + } ++ if ((st1.st_mode & 01777) != (~mask & 0777)) ++ { ++ printf ("mkdirat created directory with wrong mode %o, expected %o\n", ++ (unsigned int) (st1.st_mode & 01777), ++ (unsigned int) (~mask & 0777)); ++ return 1; ++ } + + dupfd = dup (dir_fd); + if (dupfd == -1) +@@ -156,6 +167,37 @@ do_test (void) + return 1; + } + ++ /* Test again with a different mode. */ ++ umask (0); ++ e = mkdirat (dir_fd, "some-dir", 01755); ++ umask (mask); ++ if (e == -1) ++ { ++ puts ("directory creation (different mode) failed"); ++ return 1; ++ } ++ if (fstatat64 (dir_fd, "some-dir", &st1, 0) != 0) ++ { ++ puts ("fstat64 (different mode) failed"); ++ return 1; ++ } ++ if (!S_ISDIR (st1.st_mode)) ++ { ++ puts ("mkdirat (different mode) did not create a directory"); ++ return 1; ++ } ++ if ((st1.st_mode & 01777) != 01755) ++ { ++ printf ("mkdirat (different mode) created directory with wrong mode %o\n", ++ (unsigned int) (st1.st_mode & 01777)); ++ return 1; ++ } ++ if (unlinkat (dir_fd, "some-dir", AT_REMOVEDIR) != 0) ++ { ++ puts ("unlinkat (different mode) failed"); ++ return 1; ++ } ++ + close (dir_fd); + + return 0; diff --git a/glibc.spec b/glibc.spec index 1bee253..cbd9806 100644 --- a/glibc.spec +++ b/glibc.spec @@ -1036,6 +1036,7 @@ Patch728: glibc-RHEL-65356-2.patch Patch729: glibc-RHEL-38225-1.patch Patch730: glibc-RHEL-38225-2.patch Patch731: glibc-RHEL-54250.patch +Patch732: glibc-RHEL-56743.patch ############################################################################## # Continued list of core "glibc" package information: @@ -3034,6 +3035,7 @@ update_gconv_modules_cache () references. (RHEL-65356) - Backport verbosity patches for glibc math (RHEL-38225) - Backport getdelim test coverage improvements (RHEL-54250) +- Backport mkdirat mode test (RHEL-56743) * Thu Dec 19 2024 DJ Delorie - 2.34-148 - Increase ungetc test coverage, guarantee single char pushback (RHEL-46738)