--- ../submitted-exec_filename.diff.orig 2017-08-20 13:48:36.000000000 +0200 +++ ../submitted-exec_filename.diff.edited 2017-09-15 11:33:16.000000000 +0200 @@ -65,7 +65,7 @@ server-interfaces := hurd/msg faultexc --- a/hurd/hurd.h +++ b/hurd/hurd.h -@@ -245,12 +245,20 @@ extern FILE *fopenport (io_t port, const +@@ -241,12 +241,20 @@ extern FILE *fopenport (io_t port, const extern FILE *__fopenport (io_t port, const char *mode); @@ -189,16 +189,44 @@ +#endif --- a/sysdeps/mach/hurd/execve.c +++ b/sysdeps/mach/hurd/execve.c -@@ -31,7 +31,8 @@ __execve (const char *file_name, char *c +@@ -18,24 +18,33 @@ + #include + #include + #include ++#include + +-/* Replace the current process, executing FILE_NAME with arguments ARGV and +- environment ENVP. ARGV and ENVP are terminated by NULL pointers. */ ++/* Replace the current process, executing ABS_PATH, a canonicalized ++ absolute path name of FILE_NAME, with arguments ARGV and ++ environment ENVP. ARGV and ENVP are terminated by NULL ++ pointers. */ + int + __execve (const char *file_name, char *const argv[], char *const envp[]) + { + error_t err; +- file_t file = __file_name_lookup (file_name, O_EXEC, 0); + ++ char *abs_path = realpath (file_name, NULL); ++ if (abs_path == NULL) ++ return -1; ++ ++ file_t file = __file_name_lookup (abs_path, O_EXEC, 0); + if (file == MACH_PORT_NULL) 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); ++ abs_path, argv, envp); /* Oh well. Might as well be tidy. */ __mach_port_deallocate (__mach_task_self (), file); + ++ free (abs_path); + return __hurd_fail (err); + } + --- a/sysdeps/mach/hurd/fexecve.c +++ b/sysdeps/mach/hurd/fexecve.c @@ -25,8 +25,9 @@ @@ -227,7 +255,7 @@ { pid_t new_pid; char *path, *p, *name; -+ const char *filename; ++ const char *filename, *abs_path = NULL; size_t len; size_t pathlen; short int flags; @@ -254,16 +282,24 @@ except that all errors will be detected here (in the parent process) and return proper errno codes rather than the child dying with 127. -@@ -546,7 +548,7 @@ __spawni (pid_t *pid, const char *file, +@@ -545,8 +547,14 @@ __spawni (pid_t *pid, const char *file, + etc) can be observed before what errors. */ if ((xflags & SPAWN_XFLAGS_USE_PATH) == 0 || strchr (file, '/') != NULL) - /* The FILE parameter is actually a path. */ +- /* The FILE parameter is actually a path. */ - err = child_lookup (file, O_EXEC, 0, &execfile); -+ err = child_lookup (filename = file, O_EXEC, 0, &execfile); ++ { ++ /* The FILE parameter is actually a path. */ ++ abs_path = realpath (file, NULL); ++ if (abs_path == NULL) ++ goto out; ++ filename = abs_path; ++ err = child_lookup (filename, O_EXEC, 0, &execfile); ++ } else { /* We have to search for FILE on the path. */ -@@ -573,20 +575,18 @@ __spawni (pid_t *pid, const char *file, +@@ -573,20 +581,18 @@ __spawni (pid_t *pid, const char *file, p = path; do { @@ -287,7 +323,7 @@ switch (err) { case EACCES: -@@ -623,14 +623,27 @@ __spawni (pid_t *pid, const char *file, +@@ -623,14 +629,27 @@ __spawni (pid_t *pid, const char *file, inline error_t exec (file_t file) { @@ -323,3 +359,11 @@ } /* Now we are out of things that can fail before the file_exec RPC, +@@ -749,6 +768,7 @@ __spawni (pid_t *pid, const char *file, + _hurd_port_free (dtable_cells[i], &ulink_dtable[i], dtable[i]); + } + ++ free (abs_path); + if (err) + /* This hack canonicalizes the error code that we return. */ + err = (__hurd_fail (err), errno);