Products Resources Support About Us

Bash not finding externally linked files

Just started testing bash out and ran across an issue where if a file is externally linked ie ln -e ONETSTAT /bin/netsat bash fails to find the file

CARROS1:/home/carros1: >netstat
-bash: netstat: command not found
CARROS1:/home/carros1: >ls -la /bin | grep -i netstat
erwxrwxrwx 1 TCPIPST OMVSGRP 8 Jul 23 2013 netstat -> ONETSTAT
lrwxrwxrwx 1 TCPIPST OMVSGRP 29 Jul 23 2013 onetstat -> …/usr/lpp/tcpip/bin/onetstat

onetstat works

now if I create a symbolic like in say $HOME/bin
lrwxrwxrwx 1 PSC050 OMVSGRP 12 Aug 2 12:12 netstat -> /bin/netstat

this it find but does not run
CARROS1:/home/carros1/bin: >./netstat
Killed

it is killed instead

on the console I have this
BPXP028I SPAWN OR EXEC ERROR FOR FILE PATH ./netstat DEVICE ID 169 957
INODE 22892. THE ASSOCIATED MVS MEMBER NAME IS ONETSTAT.

SYS1.SEZALOAD which is where ONETSTAT resides is LINKLIST’d and in LPA. So it should be finding it
If I add a STEPLIP in OMVS to SYS1.SEZALOAD it works fine.

I do not have this behavior with /bin/sh or /bin/tcsh

does anyone else have this behavior?
I’d like to find out if this is a bug in bash or in our environement

Sandra

I was able to reproduce this problem here at Rocket (using /bin/netstat, which, as in your case, is an external link to ONETSTAT). I can invoke netstat using both /bin/sh and /bin/tcsh.

For others looking into this, here are some useful links:

The last of those explains why the symbolic link doesn’t work - the link needs to have an owning UID of 0. However, that doesn’t explain the “command not found” from bash (the problem actually being reported).

SO - I would say that it looks like a problem with bash, not a problem with your environment.

I think I know the root cause. The man page for “ln” (see above) contains this statement:

exec() does a stat() on the passed filename. stat() does the search, not exec(). If the filename is an external link, then stat() fails with a unique reason code which causes exec() to read the external link.

I confirmed that, in fact, stat() fails for an external link. bash checks the path to a command before it tries to exec it to make sure it is executable, using stat(). bash would have to be modified to look for the specific reason code from stat() and ignore it to get it to follow external links.

Enhancement ticket USSP-476 opened to add support for z/OS external links

Thank you both for taking such a quick look at this and a quick action of getting it added to support.

Have you posted a fix for this yet?
I’ve aliased netstat=onetstat,
ping=oping
but would appreciate a fix for it