[asterisk-bugs] [Asterisk 0010772]: safe_asterisk incorrectly invokes /bin/sh instead of /bin/bash

noreply at bugs.digium.com noreply at bugs.digium.com
Fri Sep 21 08:45:27 CDT 2007


The following issue has been REOPENED. 
====================================================================== 
http://bugs.digium.com/view.php?id=10772 
====================================================================== 
Reported By:                culrich
Assigned To:                russell
====================================================================== 
Project:                    Asterisk
Issue ID:                   10772
Category:                   Core-General
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     feedback
Asterisk Version:           1.4.11  
SVN Branch (only for SVN checkouts, not tarball releases): N/A  
SVN Revision (number only!): 81744 
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             09-20-2007 14:14 CDT
Last Modified:              09-21-2007 08:45 CDT
====================================================================== 
Summary:                    safe_asterisk incorrectly invokes /bin/sh instead of
/bin/bash
Description: 
The /contrib/script/safe_asterisk script invocation line refers to /bin/sh.
/bin/sh should only be invoked for a script that is compatible with the
original Bourne shell, which safe_asterisk is not. It contains shell
language constructs that are valid only in the Bourne Again shell, which is
commonly invoked as /bin/bash.

On most Linux distributions, this is a not a problem since /bin/sh is
usually a symbolic link to /bin/bash. On other systems like FreeBSD and
Ubuntu, /bin/sh is an actual Bourne shell, not /bin/bash. This script fails
on these systems and because shell scripts are notoriously bad at error
reporting, the error message on failure is not helpful at determining the
cause of the failure.

The proper fix to this is to either change the shell invocation line to
invoke /bin/bash or modify the script to conform to Bourne shell syntax.

There may be other shell scripts in the Asterisk distribution with this
issue, but safe_asterisk is the only one that I have noticed thus far.
====================================================================== 

---------------------------------------------------------------------- 
 culrich - 09-21-07 08:45  
---------------------------------------------------------------------- 
(I hope this isn't poor etiquette to click the "Reopen" button for this
when the issue is fixed, but I'd like to respond to Corydon76's note 70861
and could not find any other way to do so. It appears that I cannot add a
note to a bug once it is closed, even if I am the reporter. Corydon76 can
do so by virtue of being an administrator.)

It would be nice to detect the proper shell executable automatically.
However, this would be far from a foolproof endeavour. The best option
would be to rewrite the script using only POSIX-compliant syntax. In any
event, this script didn't work on FreeBSD before. Now it at least works on
Ubuntu.

As far as I can tell, the assertion that bash is not installed on Ubuntu
is incorrect. On all of the Ubuntu machines that I've set up, bash is
installed and is the primary login shell for users. But it is not the
target of the /bin/sh symlink because they've substituted a much faster
shell named dash for startup scripts and other POSIX-compliant scripts. The
Ubuntu developers posted a well-argued rationale for this, but I'm unable
to locate it at the moment. 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
09-21-07 08:45  culrich        Status                   closed => feedback  
09-21-07 08:45  culrich        Resolution               fixed => reopened   
09-21-07 08:45  culrich        Note Added: 0070909                          
======================================================================




More information about the asterisk-bugs mailing list