From 3cccf0a9107d585173e527550bbc45253624ca2e Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 17 Apr 2022 10:41:17 -0700
Subject: Don’t assume openat
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Use openat only on platforms with O_PATH.
This ports to OS X 10.9 and earlier.
Problem reported by Keith David Bershatsky in:
https://lists.gnu.org/r/emacs-devel/2022-04/msg00805.html
* lib-src/emacsclient.c (local_sockname): Use open, not openat.
* src/sysdep.c (sys_openat): New static function,
which uses openat only if O_PATH is defined.
(emacs_openat): Use it instead of openat.
(emacs_openat_noquit): Remove.
(emacs_open_noquit): Reimplement as per the old emacs_openat_noquit,
but use plain 'open'.
---
 lib-src/emacsclient.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

(limited to 'lib-src')

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 57a5eff3bf6..217a38bc07f 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1412,8 +1412,7 @@ local_sockname (int s, char sockname[socknamesize], int tmpdirlen,
   char *emacsdirend = sockname + tmpdirlen + suffixlen -
     strlen(server_name) - 1;
   *emacsdirend = '\0';
-  int dir = openat (AT_FDCWD, sockname,
-		    O_PATH | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
+  int dir = open (sockname, O_PATH | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
   *emacsdirend = '/';
   if (dir < 0)
     return errno;
-- 
cgit v1.2.3