Openmoko Bug #1622: bash -c crashes without $PWD

Openmoko Public Trac bugs at docs.openmoko.org
Thu Jul 17 08:17:29 CEST 2008


#1622: bash -c crashes without $PWD
-----------------------------+----------------------------------------------
 Reporter:  hah              |       Owner:  openmoko-kernel                              
     Type:  defect           |      Status:  new                                          
 Priority:  normal           |   Milestone:                                               
Component:  System Software  |     Version:                                               
 Severity:  normal           |    Keywords:  bash segfault crash PWD ssh scp default shell
 Blocking:                   |   Blockedby:                                               
-----------------------------+----------------------------------------------
 '''Description of the bug:'''
 Bash segfaults when it is invoked with -c and the environment variable PWD
 is not set.

 '''Demonstration of the problem:'''
 In /bin/sh (busybox):
 {{{
 ~ # bash --version
 GNU bash, version 3.2.33(1)-release (arm-angstrom-linux-gnueabi)
 Copyright (C) 2007 Free Software Foundation, Inc.
 ~ # bash -c 'echo hi'
 hi
 ~ # unset PWD
 ~ # bash -c 'echo hi'
 Segmentation fault (core dumped)
 }}}

 '''One practical implication:'''
 When using /bin/bash as the default shell (configured in /etc/passwd), ssh
 works fine, but scp and "ssh <host> <remote-command>" fails.
 The ssh daemon does not seem to set $PWD, and scp and "ssh <host> <remote-
 command>" presumably cause "bash -c <command>" to be invoked.

 '''Quick-fix script "/bin/bash-fixed":'''
 {{{
 #!/bin/sh
 export PWD
 exec /bin/bash "$@"
 }}}

-- 
Ticket URL: <https://docs.openmoko.org/trac/ticket/1622>
docs.openmoko.org <http://docs.openmoko.org/trac/>
openmoko trac


More information about the buglog mailing list