git-fexecve
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Tue, 5 Jan 2021 05:47:42 +0000 (05:47 +0000)
committerAurelien Jarno <aurel32@debian.org>
Tue, 5 Jan 2021 05:47:42 +0000 (05:47 +0000)
Committed for glibc 2.32

commit 6544999083437dabdadcec18185a1b2169b9637a
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Thu May 28 23:28:07 2020 +0000

    hurd: Fix fexecve

    * sysdeps/mach/hurd/fexecve.c (fexecve): Re-lookup fd with O_EXEC before
    calling _hurd_exec_paths.

Gbp-Pq: Topic hurd-i386
Gbp-Pq: Name git-fexecve.diff

sysdeps/mach/hurd/fexecve.c

index 2b24e46fbff0375c61979f42af2d4ce30f4b1619..c6a00ebf1e97a9089a26f49e776fb404b21fcc4b 100644 (file)
 int
 fexecve (int fd, char *const argv[], char *const envp[])
 {
-  error_t err = HURD_DPORT_USE (fd, _hurd_exec_paths (__mach_task_self (),
-                                                     port, NULL, NULL,
-                                                     argv, envp));
+  file_t file;
+  error_t err;
+  enum retry_type doretry;
+  char retryname[1024];
+
+  err = HURD_DPORT_USE (fd,
+      __dir_lookup (port, "", O_EXEC, 0, &doretry, retryname, &file));
+
+  if (! err && (doretry != FS_RETRY_NORMAL || retryname[0] != '\0'))
+    err = EGRATUITOUS;
+  if (err)
+    return __hurd_fail(err);
+
+  err = _hurd_exec_paths (__mach_task_self (), file, NULL, NULL, argv, envp);
   if (! err)
     err = EGRATUITOUS;
+
+  __mach_port_deallocate (__mach_task_self (), file);
   return __hurd_fail (err);
 }