Menu

bash - and where are we with shell script file protection

2012-07-19
2012-07-19
  • Josef Stadelmann

    just wonder how it should behave on OpenVMS
    .
    bash$ cd /CATALINA_HOME/bin
    bash$ ls -l .sh
    -rwxr-x--- 1 APACHE$W 128 12128 Jul 19 15:10 catalina.sh
    -rwxr-x--- 1 APACHE$W 128 841 Jul 19 15:10 digest.sh
    -rwxr-x--- 1 APACHE$W 128 3008 Jul 19 15:10 setclasspath.sh
    -rwxr-x--- 1 APACHE$W 128 780 Jul 19 15:10 shutdown.sh
    -rwxr-x--- 1 APACHE$W 128 1173 Jul 19 15:10 startup.sh
    -rwxr-x--- 1 APACHE$W 128 2545 Jul 19 15:10 tool-wrapper.sh
    -rwxr-x--- 1 APACHE$W 128 784 Jul 19 15:10 version.sh
    .
    bash$ /bin/sh version.sh
    Cannot find ./catalina.sh
    This file is needed to run this program
    .
    bash$ exit
    exit
    IA64-2>set file/prot=(w:re)
    .sh
    bash$ ls -l *.sh
    -rwxr-xr-x 1 APACHE$W 128 12128 Jul 19 15:11 catalina.sh
    -rwxr-xr-x 1 APACHE$W 128 841 Jul 19 15:11 digest.sh
    -rwxr-xr-x 1 APACHE$W 128 3008 Jul 19 15:11 setclasspath.sh
    -rwxr-xr-x 1 APACHE$W 128 780 Jul 19 15:11 shutdown.sh
    -rwxr-xr-x 1 APACHE$W 128 1173 Jul 19 15:11 startup.sh
    -rwxr-xr-x 1 APACHE$W 128 2545 Jul 19 15:11 tool-wrapper.sh
    -rwxr-xr-x 1 APACHE$W 128 784 Jul 19 15:11 version.sh
    .
    bash$ /bin/sh ./version.sh
    ./catalina.sh: tty: command not found
    Using CATALINA_BASE: /dka3/apache/jakarta/tomcat
    Using CATALINA_HOME: /dka3/apache/jakarta/tomcat
    Using CATALINA_TMPDIR: /dka3/apache/jakarta/tomcat/temp
    Using JRE_HOME: /DKA3/java_60
    0: /DKA3/java_60/bin/java
    1: -classpath
    2: /dka3/apache/jakarta/tomcat/server/lib/catalina.jar
    3: org.apache.catalina.util.ServerInfo
    Server version: Apache Tomcat/5.5.26
    Server built: Jan 28 2008 01:35:23
    Server number: 5.5.26.0
    OS Name: OpenVMS
    OS Version: V8.4
    Architecture: ia64
    JVM Version: 1.6.0-2.p1
    JVM Vendor: "Hewlett-Packard Company"
    ./version.sh: ./catalina.sh: illegal seek
    bash$
    .
    .
    The simple answeer is; sh files often dont run because they have the wrong worl protection!
    EVEN WHEN YOU START BASH AND HAVE THE FOLLOWINg PRIOR PRIVS SET:
    Process privileges:
    BYPASS may bypass all object access controls
    NETMBX may create network device
    SYSNAM may insert in system logical name table
    TMPMBX may create temporary mailbox
    .
    as a develop under a user account, it is teddious to remeber this all time!
    .
    just an example to remind !
    That is to say: as a VMS user with BYPASS privs set I would never expect that BASH and affiliates like /bin/sh.exe will only work properly if the file protection is set to w:rx, which is for many installed product not the case.
    .
    Josef
    .
    BTW how can I select courier font to present my code7computer output?

     

    Last edit: Josef Stadelmann 2012-07-19
  • John Malmberg

    John Malmberg - 2012-07-19

    [Updated]

    This system uses the Markdown syntax which is described in the Formatting Help button. See the section on code highlighting. If all else fails, you can fall back to HTML. For example, previously in order to make this reply format properly, I have to add HTML breaks. Apparently sourceforge has fixed that, so now I need to remove those breaks.

    Bash specifically checks the protection mask to see if a user has execute access to the file as the way it is designed to run on Unix. Unix requires that scripts specifically be marked executable.

    You should not need to put /bin/sh before a script as all that does is run an extra copy of bash in a subprocess, which is far more costly on VMS than it is on Unix.

    Are you running the GNV bash built by HP, or the newer update to 4.2.39 that is available for download via FTP at encompasserve.org/gnv

    With the updated bash, the image is GNV\$BASH.EXE and the bash,sh are aliases. The image is installed shared, which should speed up the applications. The installation should remove teh older images.

    I and others are continuing to work on porting bash-4.2.current and documenting the progress in the GNV-DEVELOP mailing list in the GNV project.

     

    Last edit: John Malmberg 2013-03-01

Log in to post a comment.