Hello Alex, Shawn, and Nora, @Nora, thanks for the bug report. On 7/28/21 10:20 PM, Alejandro Colomar wrote: > From: Shawn Landden <shawn@xxxxxxx> > > The absolute pathname is available in the Linux-specific > auxiliary-vector feature. @Shawn But this isn't true, as far as I can see. See the following: [[ $ cat auxv.c #include <link.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> extern char **environ; int main(int argc, char *argv[]) { char **p; /* Walk through the array of pointers in environ */ for (p = environ; *p != NULL; p++) continue; /* The auxiliary vector sits just above environ */ p++; /* Step past NULL pointer at end of 'environ' */ printf("auxvec %12p\n", (void *) p); ElfW(auxv_t) *auxv = (ElfW(auxv_t) *) p; while (auxv->a_type != 0) { switch (auxv->a_type) { case AT_PLATFORM: /* String identifying hardware platform */ printf("AT_PLATFORM: 0x%llx (string: %s)\n", (long long) auxv->a_un.a_val, (char *) auxv->a_un.a_val); break; case AT_SECURE: /* Was secure-execution mode triggered for dynamic linker? See ld.so(8). */ printf("AT_SECURE: %lld\n", (long long) auxv->a_un.a_val); break; case AT_EXECFN: /* Pathname used to execute program */ printf("AT_EXECFN: 0x%llx (string: %s)\n", (long long) auxv->a_un.a_val, (char *) auxv->a_un.a_val); break; default: /* We ignore other types of entries in auxiliary vector */ break; } auxv++; } exit(EXIT_SUCCESS); } $ ./auxv auxvec 0x7ffd5c6eb708 AT_SECURE: 0 AT_EXECFN: 0x7ffd5c6ecff1 (string: ./auxv) AT_PLATFORM: 0x7ffd5c6eb859 (string: x86_64) ]] > > Reported-by: Nora Platiel <nplatiel@xxxxxx> > Signed-off-by: Shawn Landden <shawn@xxxxxxx> > Reviewed-by: Nora Platiel <nplatiel@xxxxxx> > Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx> > --- > man2/execve.2 | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/man2/execve.2 b/man2/execve.2 > index c18ca5412..7fe12ab42 100644 > --- a/man2/execve.2 > +++ b/man2/execve.2 > @@ -346,7 +346,9 @@ will be invoked with the following arguments: > .PP > where > .I pathname > -is the absolute pathname of the file specified as the first argument of > +is the absolute pathname of the file specified (may be relative to > +.BR getcwd (3) > +of the caller) as the first argument of > .BR execve (), I find the "(may be relative...)" piece confusing. It's simpler just to s/absolute pathname/pathname/, and that's the change I made. > and > .I arg... > @@ -356,6 +358,11 @@ argument of > .BR execve (), > starting at > .IR argv[1] . > +The absolute pathname of the script is also available > +in the same auxiliary vector the environment and argument variables are in, as > +.BR AT_EXECFN . > +See > +.BR getauxval (3). > Note that there is no way to get the > .IR argv[0] > that was passed to the I applied the patch below. Cheers, Michael diff --git a/man2/execve.2 b/man2/execve.2 index 435a6b363..4eaf1967e 100644 --- a/man2/execve.2 +++ b/man2/execve.2 @@ -346,7 +346,7 @@ will be invoked with the following arguments: .PP where .I pathname -is the absolute pathname of the file specified as the first argument of +is the pathname of the file specified as the first argument of .BR execve (), and .I arg... -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/