about summary refs log tree commit diff
path: root/hurd
diff options
context:
space:
mode:
Diffstat (limited to 'hurd')
-rw-r--r--hurd/Versions4
-rw-r--r--hurd/hurd.h13
-rw-r--r--hurd/hurdexec.c52
3 files changed, 58 insertions, 11 deletions
diff --git a/hurd/Versions b/hurd/Versions
index 77f5b4271e..b059405a50 100644
--- a/hurd/Versions
+++ b/hurd/Versions
@@ -129,6 +129,10 @@ libc {
     # functions used in macros & inline functions
     __errno_location;
   }
+  GLIBC_2.27 {
+    # "quasi-internal" functions
+    _hurd_exec_paths;
+  }
 
   HURD_CTHREADS_0.3 {
     # weak refs to libthreads functions that libc calls iff libthreads in use
diff --git a/hurd/hurd.h b/hurd/hurd.h
index a3d534a35a..7cf23b5598 100644
--- a/hurd/hurd.h
+++ b/hurd/hurd.h
@@ -240,12 +240,21 @@ extern FILE *fopenport (io_t port, const char *mode);
 extern FILE *__fopenport (io_t port, const char *mode);
 
 
-/* Execute a file, replacing TASK's current program image.  */
+/* Deprecated: use _hurd_exec_paths instead.  */
 
 extern error_t _hurd_exec (task_t task,
 			   file_t file,
 			   char *const argv[],
-			   char *const envp[]);
+			   char *const envp[]) __attribute_deprecated__;
+
+/* Execute a file, replacing TASK's current program image.  */
+
+extern error_t _hurd_exec_paths (task_t task,
+				 file_t file,
+				 const char *path,
+				 const char *abspath,
+				 char *const argv[],
+				 char *const envp[]);
 
 
 /* Inform the proc server we have exited with STATUS, and kill the
diff --git a/hurd/hurdexec.c b/hurd/hurdexec.c
index 6fa9cf5c1d..027fa5a3ee 100644
--- a/hurd/hurdexec.c
+++ b/hurd/hurdexec.c
@@ -30,11 +30,30 @@
 
 /* Overlay TASK, executing FILE with arguments ARGV and environment ENVP.
    If TASK == mach_task_self (), some ports are dealloc'd by the exec server.
-   ARGV and ENVP are terminated by NULL pointers.  */
+   ARGV and ENVP are terminated by NULL pointers.
+   Deprecated: use _hurd_exec_paths instead.  */
 error_t
 _hurd_exec (task_t task, file_t file,
 	    char *const argv[], char *const envp[])
 {
+  return _hurd_exec_paths (task, file, NULL, NULL, argv, envp);
+}
+
+link_warning (_hurd_exec,
+	      "_hurd_exec is deprecated, use _hurd_exec_paths instead");
+
+/* Overlay TASK, executing FILE with arguments ARGV and environment ENVP.
+   If TASK == mach_task_self (), some ports are dealloc'd by the exec server.
+   ARGV and ENVP are terminated by NULL pointers.  PATH is the relative path to
+   FILE and ABSPATH is the absolute path to FILE. Passing NULL, though possible,
+   should be avoided, since then the exec server may not know the path to
+   FILE if FILE is a script, and will then pass /dev/fd/N to the
+   interpreter.  */
+error_t
+_hurd_exec_paths (task_t task, file_t file,
+		   const char *path, const char *abspath,
+		   char *const argv[], char *const envp[])
+{
   error_t err;
   char *args, *env;
   size_t argslen, envlen;
@@ -216,7 +235,7 @@ _hurd_exec (task_t task, file_t file,
       /* We have euid != svuid or egid != svgid.  POSIX.1 says that exec
 	 sets svuid = euid and svgid = egid.  So we must get a new auth
 	 port and reauthenticate everything with it.  We'll pass the new
-	 ports in file_exec instead of our own ports.  */
+	 ports in file_exec_paths instead of our own ports.  */
 
       auth_t newauth;
 
@@ -360,13 +379,28 @@ _hurd_exec (task_t task, file_t file,
       if (__sigismember (&_hurdsig_traced, SIGKILL))
 	flags |= EXEC_SIGTRAP;
 #endif
-      err = __file_exec (file, task, flags,
-			 args, argslen, env, envlen,
-			 dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize,
-			 ports, MACH_MSG_TYPE_COPY_SEND, _hurd_nports,
-			 ints, INIT_INT_MAX,
-			 please_dealloc, pdp - please_dealloc,
-			 &_hurd_msgport, task == __mach_task_self () ? 1 : 0);
+      err = __file_exec_paths (file, task, flags,
+			       path ? path : "",
+			       abspath ? abspath : "",
+			       args, argslen, env, envlen,
+			       dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize,
+			       ports, MACH_MSG_TYPE_COPY_SEND,
+			       _hurd_nports,
+			       ints, INIT_INT_MAX,
+			       please_dealloc, pdp - please_dealloc,
+			       &_hurd_msgport,
+			       task == __mach_task_self () ? 1 : 0);
+      /* Fall back for backwards compatibility.  This can just be removed
+         when __file_exec goes away.  */
+      if (err == MIG_BAD_ID)
+	err = __file_exec (file, task, flags,
+			   args, argslen, env, envlen,
+			   dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize,
+			   ports, MACH_MSG_TYPE_COPY_SEND, _hurd_nports,
+			   ints, INIT_INT_MAX,
+			   please_dealloc, pdp - please_dealloc,
+			   &_hurd_msgport,
+			   task == __mach_task_self () ? 1 : 0);
     }
 
   /* Release references to the standard ports.  */