From: Emilio Pozuelo Monfort <poch...@gmail.com> * configure.in: Check for _hurd_exec_file_name. * utils/fakeauth.c: Call _hurd_exec_file_name instead of _hurd_exec if it's available. * utils/rpctrace.c: Likewise. * utils/shd.c: Likewise.
Signed-off-by: Jeremie Koenig <j...@jk.fr.eu.org> --- configure.in | 4 ++-- utils/fakeauth.c | 9 +++++++-- utils/rpctrace.c | 6 +++++- utils/shd.c | 9 ++++++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/configure.in b/configure.in index 1cf4daa..ae43eaa 100644 --- a/configure.in +++ b/configure.in @@ -151,26 +151,26 @@ AC_CACHE_CHECK([for libio], # The versions of the symbols in libthreads have to match those in # libc.so. Since the symbols in a libc that includes libio will be # versioned differently from the ones in a libc that uses stdio, this # isn't easy to accomplish. Instead we leave things unversioned if # libio isn't found. if test $hurd_cv_libio = yes; then VERSIONING=$hurd_cv_ld_version_script_option else VERSIONING=no fi AC_SUBST(VERSIONING) -# Check if libc contains getgrouplist and/or uselocale. -AC_CHECK_FUNCS(getgrouplist uselocale) +# Check if libc contains these functions. +AC_CHECK_FUNCS(getgrouplist uselocale _hurd_exec_file_name) # From glibc HEAD, 2007-11-07. AC_CACHE_CHECK(for -fgnu89-inline, libc_cv_gnu89_inline, [dnl cat > conftest.c <<EOF int foo; #ifdef __GNUC_GNU_INLINE__ main () { return 0;} #else #error #endif EOF diff --git a/utils/fakeauth.c b/utils/fakeauth.c index 49fa7f1..1a735db 100644 --- a/utils/fakeauth.c +++ b/utils/fakeauth.c @@ -1,14 +1,14 @@ /* fakeauth -- proxy auth server to lie to users about what their IDs are - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License @@ -379,50 +379,55 @@ believe it has restricted them to different identities or no identity at all.\ /* Now we start faking ourselves out. This will immediately reauthenticate all our descriptors through our proxy auth port. The POSIXoid calls we make below will continue to use the fake port and pass it on to the child. */ if (setauth (authport)) error (2, errno, "Cannot switch to fake auth handle"); mach_port_deallocate (mach_task_self (), authport); /* We cannot use fork because it doesn't do the right thing with our send rights that point to our own receive rights, i.e. the new auth port. Since posix_spawn might be implemented with fork (prior to glibc 2.3), - we cannot use that simple interface either. We use _hurd_exec + we cannot use that simple interface either. We use _hurd_exec_file_name directly to effect what posix_spawn does in the simple case. */ { task_t newtask; process_t proc; file_t execfile = file_name_lookup (argv[argi], O_EXEC, 0); if (execfile == MACH_PORT_NULL) error (3, errno, "%s", argv[argi]); err = task_create (mach_task_self (), #ifdef KERN_INVALID_LEDGER NULL, 0, /* OSF Mach */ #endif 0, &newtask); if (err) error (3, err, "cannot create child task"); child = task2pid (newtask); if (child < 0) error (3, errno, "task2pid"); proc = getproc (); err = proc_child (proc, newtask); mach_port_deallocate (mach_task_self (), proc); if (err) error (3, err, "proc_child"); +#ifdef HAVE__HURD_EXEC_FILE_NAME + err = _hurd_exec_file_name (newtask, execfile, argv[argi], + &argv[argi], environ); +#else err = _hurd_exec (newtask, execfile, &argv[argi], environ); +#endif mach_port_deallocate (mach_task_self (), newtask); mach_port_deallocate (mach_task_self (), execfile); if (err) error (3, err, "cannot execute %s", argv[argi]); } if (waitpid (child, &status, 0) != child) error (4, errno, "waitpid on %d", child); if (WIFSIGNALED (status)) error (WTERMSIG (status) + 128, 0, "%s for child %d", strsignal (WTERMSIG (status)), child); diff --git a/utils/rpctrace.c b/utils/rpctrace.c index 996d4ba..30fa2b2 100644 --- a/utils/rpctrace.c +++ b/utils/rpctrace.c @@ -1,15 +1,15 @@ /* Trace RPCs sent to selected ports - Copyright (C) 1998, 1999, 2001, 2002, 2003, 2005, 2006, 2009, 2011 + Copyright (C) 1998, 1999, 2001, 2002, 2003, 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of the GNU Hurd. The GNU Hurd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. The GNU Hurd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -1060,25 +1060,29 @@ traced_spawn (char **argv, char **envp) /* Replace the task's kernel port with the wrapper. When this task calls `mach_task_self ()', it will get our wrapper send right instead of its own real task port. */ err = mach_port_insert_right (mach_task_self (), task_wrapper, task_wrapper, MACH_MSG_TYPE_MAKE_SEND); assert_perror (err); err = task_set_special_port (traced_task, TASK_KERNEL_PORT, task_wrapper); assert_perror (err); /* Now actually run the command they told us to trace. We do the exec on the actual task, so the RPCs to map in the program itself do not get traced. Could have an option to use TASK_WRAPPER here instead. */ +#ifdef HAVE__HURD_EXEC_FILE_NAME + err = _hurd_exec_file_name (traced_task, file, *argv, argv, envp); +#else err = _hurd_exec (traced_task, file, argv, envp); +#endif if (err) error (2, err, "cannot exec `%s'", argv[0]); /* We were keeping this send right alive so that the wrapper object cannot die and hence our TRACED_TASK ref cannot have been released. */ mach_port_deallocate (mach_task_self (), task_wrapper); return pid; } static void diff --git a/utils/shd.c b/utils/shd.c index 0587fa4..b05afb4 100644 --- a/utils/shd.c +++ b/utils/shd.c @@ -1,14 +1,14 @@ /* - Copyright (C) 1994,95,99,2002 Free Software Foundation + Copyright (C) 1994, 1995, 1999, 2002, 2010 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License @@ -150,33 +150,36 @@ run (char **argv, int fd0, int fd1) error (0, err, "proc_child"); if (pause_startup) { printf ("Pausing (child PID %d)...", pid); fflush (stdout); getchar (); } if (movefd (fd0, 0, &save0) || movefd (fd1, 1, &save1)) return -1; +#ifdef HAVE__HURD_EXEC_FILE_NAME + err = _hurd_exec_file_name (task, file, program, argv, environ); +#else err = _hurd_exec (task, file, argv, environ); - +#endif if (restorefd (fd0, 0, &save0) || restorefd (fd1, 1, &save1)) return -1; if (err) { - error (0, err, "_hurd_exec"); + error (0, err, "_hurd_exec_file_name"); err = task_terminate (task); if (err) error (0, err, "task_terminate"); } mach_port_deallocate (mach_task_self (), task); } mach_port_deallocate (mach_task_self (), file); errno = err; return pid; } -- 1.7.5.4