]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Fix fexecve
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 28 May 2020 23:28:07 +0000 (23:28 +0000)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 28 May 2020 23:30:57 +0000 (23:30 +0000)
* sysdeps/mach/hurd/fexecve.c (fexecve): Re-lookup fd with O_EXEC before
calling _hurd_exec_paths.

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);
 }