--- shell.c 2005-09-04 19:32:08.000000000 -0700 +++ /var/tmp/shell.c 2006-10-11 14:13:54.000000000 -0700 @@ -43,6 +43,10 @@ # include <unistd.h> #endif +#if defined(__APPLE__) +#include <get_compat.h> +#endif /* __APPLE__ */ + #include "bashintl.h" #define NEED_SH_SETLINEBUF_DECL /* used in externs.h */ @@ -315,6 +319,9 @@ _cygwin32_check_tmp () } #endif /* __CYGWIN__ */ +#ifdef __APPLE__ +static int tiger_mode = 0; +#endif /* __APPLE__ */ #if defined (NO_MAIN_ENV_ARG) /* systems without third argument to main() */ int @@ -354,7 +361,16 @@ main (argc, argv, env) code = setjmp (top_level); if (code) exit (2); - +#if defined(__APPLE__) + if (!COMPAT_MODE("bin/sh", "Unix2003")) { +#if defined(STRICT_POSIX) + execv("/bin/bash", argv); + exit (2); +#else /* !STRICT_POSIX */ + tiger_mode = 1; /* act like Tiger wrt setuid and #!/bin/sh */ +#endif /* STRICT_POSIX */ + } +#endif /* __APPLE__ */ #if defined (USING_BASH_MALLOC) && defined (DEBUG) && !defined (DISABLE_MALLOC_WRAPPERS) # if 1 malloc_set_register (1); @@ -459,10 +475,13 @@ main (argc, argv, env) if (dump_translatable_strings) read_but_dont_execute = 1; - +#ifdef __APPLE__ + if (running_setuid && privileged_mode == 0 && (tiger_mode ? (act_like_sh == 0) : 1)) + disable_priv_mode (); +#else /* !__APPLE__ */ if (running_setuid && privileged_mode == 0) disable_priv_mode (); - +#endif /* __APPLE__ */ /* Need to get the argument to a -c option processed in the above loop. The next arg is a command to execute, and the following args are $0...$n respectively. */ @@ -1037,6 +1056,10 @@ run_startup_files () } /* Interactive shell or `-su' shell. */ + { int posixly_correct = 0; /* Solaris 10 sources /etc/profile and + * $HOME/profile in /usr/xpg4/bin/sh + * if argv[0][0] == '-' */ + if (posixly_correct == 0) /* bash, sh */ { if (login_shell && sourced_login++ == 0) @@ -1080,7 +1103,7 @@ run_startup_files () if (interactive_shell && privileged_mode == 0 && sourced_env++ == 0) execute_env_file (get_string_value ("ENV")); } - + } #if defined (JOB_CONTROL) set_job_control (old_job_control); #endif