<pre style='margin:0'>
Christopher Nielsen (mascguy) pushed a commit to branch master
in repository macports-legacy-support.
</pre>
<p><a href="https://github.com/macports/macports-legacy-support/commit/c440f888d35e4486b0ae6ff5cd715b9d1df56d3c">https://github.com/macports/macports-legacy-support/commit/c440f888d35e4486b0ae6ff5cd715b9d1df56d3c</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new c440f88 Fix dirent.h clang-devel build failure on 10.9 with 10.10 SDK, and 10.4 build failure
</span>c440f88 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit c440f888d35e4486b0ae6ff5cd715b9d1df56d3c
</span>Author: raf <raf@raf.org>
AuthorDate: Sun Oct 1 16:31:36 2023 +1100
<span style='display:block; white-space:pre;color:#404040;'> Fix dirent.h clang-devel build failure on 10.9 with 10.10 SDK, and 10.4 build failure
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Co-authored-by: Tavian Barnes <tavianator@tavianator.com>
</span>---
Makefile | 2 +-
README.md | 5 +-
include/dirent.h | 93 ++-------------------------
src/fdopendir.c | 144 +++++-------------------------------------
test/do_test_faccessat_setuid | 60 +++++++++++-------
test/test_faccessat.c | 4 +-
6 files changed, 61 insertions(+), 247 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/Makefile b/Makefile
</span><span style='display:block; white-space:pre;color:#808080;'>index f7d19c9..0d98463 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/Makefile
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/Makefile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -303,7 +303,7 @@ test_faccessat_setuid: test/test_faccessat
</span> @test/do_test_faccessat_setuid "$(BUILDDLIBPATH)"
test_faccessat_setuid_msg:
<span style='display:block; white-space:pre;background:#ffe0e0;'>- @echo 'Run "sudo make test_faccessat_setuid" to test faccessat properly'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ @echo 'Run "sudo make test_faccessat_setuid" to test faccessat properly (Not on 10.4)'
</span>
$(TESTRUNS): $(TESTRUNPREFIX)%: $(TESTNAMEPREFIX)%
$<
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/README.md b/README.md
</span><span style='display:block; white-space:pre;color:#808080;'>index e0c8c23..34744fe 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/README.md
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/README.md
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -41,10 +41,7 @@ Wrapped headers and replaced functions are:
</span> </tr>
<tr>
<td><code>dirent.h</code></td>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- <td>Adds <code>fdopendir</code> function, and wraps <code>opendir</code>,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- <code>readdir</code>, <code>readdir_r</code>, <code>rewinddir</code>,
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- <code>seekdir</code>, <code>telldir</code>, <code>dirfd</code>, and
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- <code>closedir</code>, to support <code>fdopendir</code></td>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ <td>Adds <code>fdopendir</code> function.
</span> <td>OSX10.9</td>
</tr>
<tr>
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/include/dirent.h b/include/dirent.h
</span><span style='display:block; white-space:pre;color:#808080;'>index a363a9d..884911f 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/include/dirent.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/include/dirent.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,7 +1,6 @@
</span>
/*
* Copyright (c) 2019
<span style='display:block; white-space:pre;background:#ffe0e0;'>- * Copyright (C) 2023 raf <raf@raf.org>, Tavian Barnes <tavianator@tavianator.com>
</span> *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -22,102 +21,18 @@
</span> /* MP support header */
#include "MacportsLegacySupport.h"
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Alter function names declared by <dirent.h> to get them out of the way */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Note: These renamed names are non-functional */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#if __MP_LEGACY_SUPPORT_FDOPENDIR__
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define opendir __mpls_renamed_libc_opendir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define closedir __mpls_renamed_libc_closedir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define readdir __mpls_renamed_libc_readdir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define readdir_r __mpls_renamed_libc_readdir_r
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define rewinddir __mpls_renamed_libc_rewinddir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define seekdir __mpls_renamed_libc_seekdir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define telldir __mpls_renamed_libc_telldir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> /* Include the primary system dirent.h */
#include_next <dirent.h>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Remove the above macros to make way for the declarations below */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#if __MP_LEGACY_SUPPORT_FDOPENDIR__
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#undef opendir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#undef closedir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#undef readdir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#undef readdir_r
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#undef rewinddir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#undef seekdir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#undef telldir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#ifndef __MPLS_ALIAS
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# define __MPLS_ALIAS(sym) __DARWIN_ALIAS(sym)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Fallback to __DARWIN_ALIAS if the other variants are not defined (?) */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Note: I don't know if this makes sense */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#ifndef __MPLS_ALIAS_I
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# ifdef __DARWIN_ALIAS_I
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# define __MPLS_ALIAS_I(sym) __DARWIN_ALIAS_I(sym)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# else
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# define __MPLS_ALIAS_I(sym) __DARWIN_ALIAS(sym)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# endif
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#ifndef __MPLS_INODE64
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# ifdef __DARWIN_INODE64
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# define __MPLS_INODE64(sym) __DARWIN_INODE64(sym)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# else
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# define __MPLS_INODE64(sym) __DARWIN_ALIAS(sym)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-# endif
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Declare alternative names for the underlying functions for use by the wrappers */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Note: Each __MPLS_ALIAS* macro must match the corresponding __DARWIN_ALIAS* in system <dirent.h> */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-DIR *__mpls_libc_opendir(const char *name) __MPLS_ALIAS_I(opendir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-int __mpls_libc_closedir(DIR *dir) __MPLS_ALIAS(closedir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-struct dirent *__mpls_libc_readdir(DIR *dir) __MPLS_INODE64(readdir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-int __mpls_libc_readdir_r(DIR *dir, struct dirent *entry, struct dirent **result) __MPLS_INODE64(readdir_r);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-void __mpls_libc_rewinddir(DIR *dir) __MPLS_ALIAS_I(rewinddir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-void __mpls_libc_seekdir(DIR *dir, long loc) __MPLS_ALIAS_I(seekdir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-long __mpls_libc_telldir(DIR *dir) __MPLS_ALIAS_I(telldir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#endif
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> /* fdopendir */
#if __MP_LEGACY_SUPPORT_FDOPENDIR__
<span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Wrapper struct for DIR */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-typedef struct __MPLS_DIR __MPLS_DIR;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-struct __MPLS_DIR {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- DIR *__mpls_dir;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- int __mpls_dirfd;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-};
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define DIR __MPLS_DIR
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> __MP__BEGIN_DECLS
<span style='display:block; white-space:pre;background:#ffe0e0;'>-extern DIR *fdopendir(int fd) __MPLS_ALIAS_I(fdopendir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Wrapper functions to support fdopendir */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-extern DIR *__mpls_opendir(const char *name);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-extern int __mpls_closedir(DIR *dir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-extern struct dirent *__mpls_readdir(DIR *dir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-extern int __mpls_readdir_r(DIR *dir, struct dirent *entry, struct dirent **result);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-extern void __mpls_rewinddir(DIR *dir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-extern void __mpls_seekdir(DIR *dir, long loc);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-extern long __mpls_telldir(DIR *dir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-extern int __mpls_dirfd(DIR *dir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/* Define the standard names to refer to LegacySupport's wrappers (via asm renaming) */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-DIR *opendir(const char *name) __asm("___mpls_opendir");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-int closedir(DIR *dir) __asm("___mpls_closedir");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-struct dirent *readdir(DIR *dir) __asm("___mpls_readdir");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result) __asm("___mpls_readdir_r");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-void rewinddir(DIR *dir) __asm("___mpls_rewinddir");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-void seekdir(DIR *dir, long loc) __asm("___mpls_seekdir");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-long telldir(DIR *dir) __asm("___mpls_telldir");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#ifndef __MP_LEGACY_SUPPORT_NO_DIRFD_MACRO
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#undef dirfd
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#define dirfd(dir) __mpls_dirfd(dir)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef __DARWIN_ALIAS_I
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+extern DIR *fdopendir(int fd) __DARWIN_ALIAS(fdopendir);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+extern DIR *fdopendir(int fd) __DARWIN_ALIAS_I(fdopendir);
</span> #endif
__MP__END_DECLS
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/fdopendir.c b/src/fdopendir.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 508670e..79cd8ac 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/fdopendir.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/fdopendir.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -22,26 +22,16 @@
</span>
#include "common-priv.h"
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#define __MP_LEGACY_SUPPORT_NO_DIRFD_MACRO
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <stdlib.h>
</span> #include <dirent.h>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <sys/errno.h>
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-#undef DIR
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span>
/*
* Implementation behavior largely follows these man page descriptions:
*
* https://www.freebsd.org/cgi/man.cgi?query=fdopendir&sektion=3
* https://linux.die.net/man/3/fdopendir
<span style='display:block; white-space:pre;background:#ffe0e0;'>- *
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * On success, this function returns allocated memory that must be
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * deallocated by __mpls_closedir() (see closedir() macro in <dirent.h>).
</span> */
<span style='display:block; white-space:pre;background:#ffe0e0;'>-__MPLS_DIR *fdopendir(int dirfd) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+DIR *fdopendir(int dirfd) {
</span>
/* Check dirfd here (for macos-10.4, see _ATCALL() and best_fchdir()) */
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -50,133 +40,31 @@ __MPLS_DIR *fdopendir(int dirfd) {
</span> return 0;
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- /* Open the supplied directory safely */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- DIR *dir = _ATCALL(dirfd, ".", NULL, __mpls_libc_opendir("."));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!dir)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- /* Wrap it and return it (with the supplied directory file descriptor) */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- __MPLS_DIR *mplsdir = malloc(sizeof(*mplsdir));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!mplsdir) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- (void)__mpls_libc_closedir(dir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- errno = ENOMEM;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- mplsdir->__mpls_dir = dir;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- mplsdir->__mpls_dirfd = dirfd;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return mplsdir;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/*
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Wrapped version of opendir() for fdopendir() compatibility
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- *
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * On success, this function returns allocated memory that must be
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * deallocated by __mpls_closedir() (see closedir() macro in <dirent.h>).
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-__MPLS_DIR *__mpls_opendir(const char *name) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* Open given directory fd safely for iteration via readdir */
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- DIR *dir = __mpls_libc_opendir(name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ DIR *dir = _ATCALL(dirfd, ".", NULL, opendir("."));
</span> if (!dir)
return 0;
<span style='display:block; white-space:pre;background:#ffe0e0;'>- __MPLS_DIR *mplsdir = malloc(sizeof(*mplsdir));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!mplsdir) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- (void)__mpls_libc_closedir(dir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- errno = ENOMEM;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- mplsdir->__mpls_dir = dir;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- mplsdir->__mpls_dirfd = -1;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return mplsdir;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/*
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Wrapped version of closedir() for fdopendir() compatibility (see
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * closedir() macro in <dirent.h>).
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- *
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * This function deallocates memory that was allocated by fdopendir() or
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * __mpls_opendir().
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-int __mpls_closedir(__MPLS_DIR *mplsdir) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (!mplsdir) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- errno = EBADF;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return -1;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- int rc = __mpls_libc_closedir(mplsdir->__mpls_dir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (mplsdir->__mpls_dirfd != -1)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- PROTECT_ERRNO(close(mplsdir->__mpls_dirfd));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- free(mplsdir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return rc;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/*
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Wrapped version of readdir() for fdopendir() compatibility.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-struct dirent *__mpls_readdir(__MPLS_DIR *mplsdir) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return __mpls_libc_readdir(mplsdir->__mpls_dir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/*
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Wrapped version of readdir_r() for fdopendir() compatibility.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-int __mpls_readdir_r(__MPLS_DIR *mplsdir, struct dirent *entry, struct dirent **result) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return __mpls_libc_readdir_r(mplsdir->__mpls_dir, entry, result);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/*
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Wrapped version of rewinddir() for fdopendir() compatibility.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-void __mpls_rewinddir(__MPLS_DIR *mplsdir) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- __mpls_libc_rewinddir(mplsdir->__mpls_dir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/*
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Wrapped version of seekdir() for fdopendir() compatibility.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- */
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-void __mpls_seekdir(__MPLS_DIR *mplsdir, long loc) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- __mpls_libc_seekdir(mplsdir->__mpls_dir, loc);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/*
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Wrapped version of telldir() for fdopendir() compatibility.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* Replace underlying fd with equivalent given fd (closed by closedir) */
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-long __mpls_telldir(__MPLS_DIR *mplsdir) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return __mpls_libc_telldir(mplsdir->__mpls_dir);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-/*
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * Wrapped version of dirfd() for fdopendir() compatibility because dirfd()
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- * itself is already a macro (see dirfd() macro in <dirent.h>).
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ == 1040
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (void)close(dir->dd_fd);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dir->dd_fd = dirfd;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (void)close(dir->__dd_fd);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dir->__dd_fd = dirfd;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ #endif
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-int __mpls_dirfd(__MPLS_DIR *mplsdir) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* Rewind to the start of the directory (in case it's not there already) */
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- /* Return the supplied directory file descriptor if there was one */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ rewinddir(dir);
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if (mplsdir->__mpls_dirfd != -1)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return mplsdir->__mpls_dirfd;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* Close given fd on exec (just in case not already done) */
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- /* Otherwise call the underlying dirfd() macro */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (void)fcntl(dirfd, F_SETFD, FD_CLOEXEC);
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return dirfd(mplsdir->__mpls_dir);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return dir;
</span> }
#endif /* __MP_LEGACY_SUPPORT_FDOPENDIR__ */
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/test/do_test_faccessat_setuid b/test/do_test_faccessat_setuid
</span><span style='display:block; white-space:pre;color:#808080;'>index e978ce8..c2d9ebc 100755
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/test/do_test_faccessat_setuid
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/test/do_test_faccessat_setuid
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -16,6 +16,9 @@
</span>
# When run as root, test faccessat() properly
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# Note: On 10.4, this doesn't work because setreuid/setregid are incorrect.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# They set effective uid/gid, but not real uid/gid.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> if [ "$(whoami)" != root ]
then
echo 'Run "sudo make test_faccessat_setuid" to test faccessat properly'
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -60,24 +63,32 @@ clean()
</span> rm -rf $s $t
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-get_group()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+get_group() # Get the user's primary group name
</span> {
echo $(id $1 | sed -E 's/^.*gid=-?[0-9]+\(//; s/\).*$//')
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-get_supp_group()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+get_supp_group() # Get the user's first supplementary group name, if any
</span> {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- echo $(id $1 | sed -E 's/^.*groups=-?[0-9]+\([^)]+\),-?[0-9]+\(//; s/\).*$//')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ echo $(id $1 | sed -E '
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s/^uid=-?[0-9]+\([^)]+\) //;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s/^gid=-?[0-9]+\([^)]+\) //;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s/^groups=-?[0-9]+\([^)]+\)//;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s/^,//;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s/,.*$//;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s/^-?[0-9]+\(//;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s/\)$//
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ')
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>-uucp_group=$(get_group _uucp)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+daemon_group=$(get_group daemon)
</span> nobody_group=$(get_group nobody)
nobody_supp_group=$(get_supp_group nobody)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-# Run normal test as setuid _uucp (to test AT_EACCESS)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# Run normal test as setuid daemon (to test AT_EACCESS)
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-echo setuid _uucp
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-setup _uucp $uucp_group 4755
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+echo setuid daemon
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+setup daemon $daemon_group 4755
</span> check sudo -u nobody $s
clean
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -91,20 +102,20 @@ clean
</span> # Test different numbers of leading dirs and leading dirs with different
# permissions (to test leading executable check)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-setup _uucp $uucp_group 4755
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-setid _uucp $uucp_group 644 $t/f touch
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-setid _uucp $uucp_group 755 $t/d1 mkdir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-setid _uucp $uucp_group 000 $t/d2 mkdir
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-setid _uucp $uucp_group 644 $t/d1/f touch
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-setid _uucp $uucp_group 644 $t/d2/f touch
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+setup daemon $daemon_group 4755
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+setid daemon $daemon_group 644 $t/f touch
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+setid daemon $daemon_group 755 $t/d1 mkdir
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+setid daemon $daemon_group 000 $t/d2 mkdir
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+setid daemon $daemon_group 644 $t/d1/f touch
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+setid daemon $daemon_group 644 $t/d2/f touch
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-echo leading dirs ruid=nobody euid=_uucp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+echo leading dirs ruid=nobody euid=daemon
</span> check sudo -u nobody $s test test/ \
$t $t/ $t/f \
$t/d1 $t/d1/ $t/d1/f \
$t/d2 $t/d2/ $t/d2/f
<span style='display:block; white-space:pre;background:#ffe0e0;'>-echo leading dirs ruid=root euid=_uucp
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+echo leading dirs ruid=root euid=daemon
</span> check $s test test/ \
$t $t/ $t/f \
$t/d1 $t/d1/ $t/d1/f \
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -152,32 +163,35 @@ checkperms nobody $nobody_group 755
</span> # (to test when uid/gid don't match)
echo perm diff user
<span style='display:block; white-space:pre;background:#ffe0e0;'>-checkperms _uucp $uucp_group 755
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+checkperms daemon $daemon_group 755
</span>
# Test lots of permissions without setuid/setgid with different user's files
# but the same group (to test when uid doesn't match but gid does match)
echo perm same group
<span style='display:block; white-space:pre;background:#ffe0e0;'>-checkperms _uucp $nobody_group 755
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+checkperms daemon $nobody_group 755
</span>
# Test lots of permissions without setuid/setgid with different user's files
# but same supplementary group (to test when uid/gid don't match but a
# supplementary group matches)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-echo perm same supp group
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-checkperms _uucp $nobody_supp_group 755
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+if [ -n "$nobody_supp_group" ]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+then
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ echo perm same supp group
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ checkperms daemon $nobody_supp_group 755
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+fi
</span>
# Test lots of permissions with setuid with different user's files
# (to test setuid)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-echo perm setuid _uucp
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-checkperms _uucp $uucp_group 4755
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+echo perm setuid daemon
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+checkperms daemon $daemon_group 4755
</span>
# Test lots of permissions with setgid with different user's files
# (to test setgid)
<span style='display:block; white-space:pre;background:#ffe0e0;'>-echo perm setgid _uucp
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-checkperms _uucp $uucp_group 2755
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+echo perm setgid daemon
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+checkperms daemon $daemon_group 2755
</span>
exit $fail
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/test/test_faccessat.c b/test/test_faccessat.c
</span><span style='display:block; white-space:pre;color:#808080;'>index a923163..19c9dd9 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/test/test_faccessat.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/test/test_faccessat.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -351,8 +351,8 @@ int main(int ac, char **av)
</span> if (check_pathname_rc == -1)
TEST(check_pathname_errno == EFAULT, "check pathname errno wrong (should be EFAULT)", check_pathname_errno)
TEST(check_dirfd_rc == -1, "check dirfd failed", 0)
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if (check_dirfd_rc == -1)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- TEST(check_dirfd_errno == EBADF, "check dirfd errno wrong (should be EBADF)", check_dirfd_errno)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (check_dirfd_rc == -1) // On 10.14 this is EBADF. On 10.4 it's ENOENT
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ TEST(check_dirfd_errno == EBADF || check_dirfd_errno == ENOENT, "check dirfd errno wrong (should be EBADF or ENOENT)", check_dirfd_errno)
</span> TEST(check_mode_rc == -1, "check mode failed", 0) // Apple doesn't check this argument - failure is ENOENT/EPERM
//if (check_mode_rc == -1)
// TEST(check_mode_errno == EINVAL, "check mode errno wrong (should be EINVAL)", check_mode_errno)
</pre><pre style='margin:0'>
</pre>