>From 1ab4b589efdd9ba9a809ba6d0dd88fd0d3645b0d Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Wed, 19 May 2010 23:06:13 +0200 Subject: [PATCH 1/4] Extend check_hashbang with a filename argument If the new filename argument is not null, it's the file name and we don't need to guess it from argv[0] and $PATH. --- exec/exec.c | 2 +- exec/hashexec.c | 8 ++++++-- exec/priv.h | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/exec/exec.c b/exec/exec.c index 272b789..1ea4d92 100644 --- a/exec/exec.c +++ b/exec/exec.c @@ -1433,7 +1433,7 @@ do_exec (file_t file, { /* Check for a #! executable file. */ check_hashbang (&e, - file, oldtask, flags, + file, oldtask, flags, NULL, argv, argvlen, argv_copy, envp, envplen, envp_copy, dtable, dtablesize, dtable_copy, diff --git a/exec/hashexec.c b/exec/hashexec.c index 2aa3844..7a7b329 100644 --- a/exec/hashexec.c +++ b/exec/hashexec.c @@ -35,6 +35,7 @@ check_hashbang (struct execdata *e, file_t file, task_t oldtask, int flags, + char *filename, char *argv, u_int argvlen, boolean_t argv_copy, char *envp, u_int envplen, boolean_t envp_copy, mach_port_t *dtable, u_int dtablesize, boolean_t dtable_copy, @@ -225,7 +226,8 @@ check_hashbang (struct execdata *e, file_name = NULL; else if (! (flags & EXEC_SECURE)) { - /* Try to figure out the file's name. We guess that if ARGV[0] + /* Try to figure out the file's name. If FILENAME is not NULL, + then it's the file's name. Otherwise we guess that if ARGV[0] contains a slash, it might be the name of the file; and that if it contains no slash, looking for files named by ARGV[0] in the `PATH' environment variable might find it. */ @@ -278,7 +280,9 @@ check_hashbang (struct execdata *e, else name = argv; - if (strchr (name, '/') != NULL) + if (filename) + error = lookup (name = filename, 0, &name_file); + else if (strchr (name, '/') != NULL) error = lookup (name, 0, &name_file); else if ((error = hurd_catch_signal (sigmask (SIGBUS) | sigmask (SIGSEGV), diff --git a/exec/priv.h b/exec/priv.h index 7cee15e..fa41f7c 100644 --- a/exec/priv.h +++ b/exec/priv.h @@ -171,6 +171,7 @@ void check_hashbang (struct execdata *e, file_t file, task_t oldtask, int flags, + char *filename, char *argv, u_int argvlen, boolean_t argv_copy, char *envp, u_int envplen, boolean_t envp_copy, mach_port_t *dtable, u_int dtablesize, -- 1.7.1