Skip to main content

Bash not finding externally linked files

  • August 2, 2016
  • 8 replies
  • 1 view

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

8 replies

  • 0 replies
  • August 2, 2016

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.


  • 0 replies
  • August 2, 2016

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.


  • 0 replies
  • August 3, 2016

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


  • 0 replies
  • August 3, 2016

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

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


  • 0 replies
  • October 5, 2016

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


  • New Participant
  • 4 replies
  • October 30, 2020

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

Hello,
I know I'm resurrecting an old thread, but I can't seem to find any answers and I'm encountering the exact same issue as the OP. I've just installed bash 4.3.46(51)-release in my z/OS 2.3 environment. Everything is working fine except for the openMVS tcpip utilities, such as netstat. I also can create a link to netstat and put the SEZALOAD expressly in the $STEPLIB envar, like the OP. Was there ever a resolution to this problem? Was USSP-476 accepted as an enhancement and worked on? Are there any other workarounds for this issue rather than creating the links and adding to the STEPLIB envar?
Thanks!
Andrew

------------------------------
Andrew Arentsen
Acuity Insurance
------------------------------

Sergey Rezepin
Forum|alt.badge.img+1
  • Rocketeer
  • 73 replies
  • November 2, 2020
Hello,
I know I'm resurrecting an old thread, but I can't seem to find any answers and I'm encountering the exact same issue as the OP. I've just installed bash 4.3.46(51)-release in my z/OS 2.3 environment. Everything is working fine except for the openMVS tcpip utilities, such as netstat. I also can create a link to netstat and put the SEZALOAD expressly in the $STEPLIB envar, like the OP. Was there ever a resolution to this problem? Was USSP-476 accepted as an enhancement and worked on? Are there any other workarounds for this issue rather than creating the links and adding to the STEPLIB envar?
Thanks!
Andrew

------------------------------
Andrew Arentsen
Acuity Insurance
------------------------------

Hi Andrew,

Unfortunately, it's not fixed yet.

As a workaround, you can add the alias for netstat in ~/.bashrc:

alias netstat='/bin/netstat'

or

alias netstat='/bin/onetstat'

Thanks.



------------------------------
Sergey Rezepin
Rocket Software
------------------------------

  • New Participant
  • 4 replies
  • November 4, 2020

Hi Andrew,

Unfortunately, it's not fixed yet.

As a workaround, you can add the alias for netstat in ~/.bashrc:

alias netstat='/bin/netstat'

or

alias netstat='/bin/onetstat'

Thanks.



------------------------------
Sergey Rezepin
Rocket Software
------------------------------
Thanks for the reply, Sergey. I've added the aliases in as a successful workaround.

Andrew

------------------------------
Andrew Arentsen
Acuity Insurance
------------------------------