>From 85033bc73229c2a17ff85d9003e5717e9c340aa4 Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Sat, 22 May 2010 18:26:29 +0200 Subject: [PATCH] Use the new __hurd_exec_file_name RPC This fixes problems when an script could env with /dev/fd/N in argv[0] because the exec server didn't know the file name. --- hurd/Versions | 1 + hurd/hurd.h | 10 +++++++++- hurd/hurdexec.c | 29 +++++++++++++++++++++-------- sysdeps/mach/hurd/execve.c | 3 ++- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/hurd/Versions b/hurd/Versions index 83c8ab1..81cd904 100644 --- a/hurd/Versions +++ b/hurd/Versions @@ -73,6 +73,7 @@ libc { _hurd_critical_section_unlock; _hurd_exception2signal; _hurd_exec; + _hurd_exec_file_name; _hurd_fd_get; _hurd_init; _hurd_intern_fd; diff --git a/hurd/hurd.h b/hurd/hurd.h index 642ea43..361fb0f 100644 --- a/hurd/hurd.h +++ b/hurd/hurd.h @@ -243,13 +243,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_file_name instead. */ extern error_t _hurd_exec (task_t task, file_t file, char *const argv[], char *const envp[]); +/* Execute a file, replacing TASK's current program image. */ + +extern error_t _hurd_exec_file_name (task_t task, + file_t file, + const char *filename, + char *const argv[], + char *const envp[]); + /* Inform the proc server we have exited with STATUS, and kill the task thoroughly. This function never returns, no matter what. */ diff --git a/hurd/hurdexec.c b/hurd/hurdexec.c index beae869..beb41de 100644 --- a/hurd/hurdexec.c +++ b/hurd/hurdexec.c @@ -32,11 +32,22 @@ /* 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_file_name instead. */ error_t _hurd_exec (task_t task, file_t file, char *const argv[], char *const envp[]) { + return _hurd_exec_file_name (task, file, NULL, argv, envp); +} + +/* 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. */ +error_t +_hurd_exec_file_name (task_t task, file_t file, const char *filename, + char *const argv[], char *const envp[]) +{ error_t err; char *args, *env; size_t argslen, envlen; @@ -362,13 +373,15 @@ _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_file_name (file, task, flags, + filename, filename ? strlen (filename) + 1 : 0, + 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. */ diff --git a/sysdeps/mach/hurd/execve.c b/sysdeps/mach/hurd/execve.c index 8af8b33..f21440f 100644 --- a/sysdeps/mach/hurd/execve.c +++ b/sysdeps/mach/hurd/execve.c @@ -35,7 +35,8 @@ __execve (file_name, argv, envp) return -1; /* Hopefully this will not return. */ - err = _hurd_exec (__mach_task_self (), file, argv, envp); + err = _hurd_exec_file_name (__mach_task_self (), file, + file_name, argv, envp); /* Oh well. Might as well be tidy. */ __mach_port_deallocate (__mach_task_self (), file); -- 1.7.1