setarch: use a login shell; fixes #12066.

* This also updates /etc/profile to detect whether our
  parent process is a shell, and changes the banner
  message accordingly.
* Also, pipe errors to /dev/null, in case grep is not
  installed; this allows us to not require grep as a
  dependency, and let the banner message do the right
  thing.
This commit is contained in:
Jessica Hamilton 2015-06-10 15:54:59 +12:00
parent ea54368ece
commit 0975f16f7c
2 changed files with 10 additions and 4 deletions

View File

@ -3,7 +3,12 @@
# Place user customizations in /.profile
#
echo -e "\nWelcome to the Haiku shell.\n"
ps |& grep -e $PPID |& grep -e $SHELL |& grep -q -e $PPID > /dev/null 2>&1
if [ $? -eq 1 ] ; then
echo -e "\nWelcome to the Haiku shell.\n"
else
echo -e "\nSwitching to architecture `getarch`\n"
fi
export USER=`id -un`
export GROUP=`id -gn`

View File

@ -237,13 +237,14 @@ main(int argc, const char* const* argv)
}
// if no command is given, get the user's shell
const char* shellCommand[2];
const char* shellCommand[3];
if (commandArgs == NULL) {
struct passwd* pwd = getpwuid(geteuid());
shellCommand[0] = pwd != NULL ? pwd->pw_shell : "/bin/sh";
shellCommand[1] = NULL;
shellCommand[1] = "-l";
shellCommand[2] = NULL;
commandArgs = shellCommand;
commandArgCount = 1;
commandArgCount = 2;
}
// exec the command