Operating System - HP-UX
1824339 Members
3376 Online
109669 Solutions
New Discussion юеВ

SHLIB_PATH not getting inherited after su <username>

 
HARIHARAN N V
Occasional Advisor

SHLIB_PATH not getting inherited after su <username>

Hello,

I have the SHLIB_PATH environment variable exported in the current shell. When I do an su , I don't see the SHLIB_PATH environment variable getting inherited. However I'm able to other other user exported variables into the su'ed shell. I have observed this behavior on HP-UX 11i.

#
# export SHLIB_PATH=/usr/lib
# export MYPATH=/usr/lib
#
# echo $SHLIB_PATH
/usr/lib
# echo $MYPATH
/usr/lib
#
# su cics
$
$ echo $SHLIB_PATH

$ echo $MYPATH
/usr/lib
$

Could someone let me know if its a known bug in HP-UX 11i?

Thanks,
Hari


13 REPLIES 13
Martin Johnson
Honored Contributor

Re: SHLIB_PATH not getting inherited after su <username>

do " su - cics"


HTH
Marty
Sandip Ghosh
Honored Contributor

Re: SHLIB_PATH not getting inherited after su <username>

If you do su - cics, then only it will take the environment of cics. Otherwise it will hwve the old environment.

Sandip
Good Luck!!!
HARIHARAN N V
Occasional Advisor

Re: SHLIB_PATH not getting inherited after su <username>


Thanks for your responses.
However I wouldn't like to issue su - command, as I want the value of SHLIB_PATH to get inherited from the previous shell.

Any idea, why the SHLIB_PATH is not getting inherited with su command ???

Thanks,
Hari


Jeff Schussele
Honored Contributor

Re: SHLIB_PATH not getting inherited after su <username>

Hi Hariharan,

Do both users have the SAME shell?

Rgds,
Jeff


PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
MANOJ SRIVASTAVA
Honored Contributor

Re: SHLIB_PATH not getting inherited after su <username>

Hi Hari

if the user is having the default shell as c Shell it will not work , all you can do is either do a su -c and then check or change the default shell if possible.


Manoj Srivastava
HARIHARAN N V
Occasional Advisor

Re: SHLIB_PATH not getting inherited after su <username>


Jeff,
>> Do both users have the SAME shell?
Yes, both the users have the same shell. I tried with both Korn and Bourne shell.

Manoj,
>> default shell as c Shell it will not work
No, I am not using C shell.

>> su -c and then check
-c option is not being recognized. What is this -c option for ??

thanks for your responses,

-Hari
Jeff Schussele
Honored Contributor

Re: SHLIB_PATH not getting inherited after su <username>

Hi (again) Hari,

Try them both as POSIX shell - /usr/bin/sh.
See the following in the man pgs.

\Quote
If the - option is omitted, the new shell starts as if a subshell was invoked. Exceptions are as follows:

If the new user name is root, the path and prompt variables are reset:

PATH=/usr/bin:/usr/sbin:/sbin
PS1=#

The previously defined HOME and ENV environment variables are removed.

The rest of the environment is retained.
If the shell specified in /etc/passwd is /usr/bin/sh, su sets the value of parameter 0 in the new shell (referenced as $0) to su. If the - option of the su command is specified, su sets parameter 0 to -su.

If the shell specified in /etc/passwd is not /usr/bin/sh, su sets the value of parameter 0 in the new shell to shellname. If the - option of the su command is specified, su sets parameter 0 to -shellname. For example, if the Korn shell is invoked, the value of shellname will be either ksh or -ksh.

By comparison, the login command always sets parameter 0 to -shellname.
\Endquote

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
HARIHARAN N V
Occasional Advisor

Re: SHLIB_PATH not getting inherited after su <username>


FYI!

Similar to SHLIB_PATH, the LD_PRELOAD and LD_LIBRARY_PATH does not get inherited. Though the latter two environment variable might not disturb HP-UX OS, however I got these two mentions from the 'strings -a /bin/su' command!

Thanks,
hari
HARIHARAN N V
Occasional Advisor

Re: SHLIB_PATH not getting inherited after su <username>


I edited a copy of /bin/su binary file, and replaced
SHLIB_PATH occurence with XXLIB_PATH. After this change,
when I executed the copy mysu , I could see
the SHLIB_PATH inherited into the user ...
This indicates that su is intentionally avoiding the
SHLIB_PATH to the new shell. Any reason ? Does this throw
some light to anyone ?

There should be some obvious HP-UX restriction on the
usage of SHLIB_PATH/LD_PRELOAD/LD_LIBRARY_PATH environment
variables not getting inherited through su ...

Thanks again,
Hari
HARIHARAN N V
Occasional Advisor

Re: SHLIB_PATH not getting inherited after su <username>


Jeff,

I tried /usr/bin/sh too, but no luck!

Please see my previous update.

Thanks again,
Hari
HARIHARAN N V
Occasional Advisor

Re: SHLIB_PATH not getting inherited after su <username>

All,

Thanks for your time.

The following is the text I found:

"As for security reasons,
Variables that control how dynamic loading and binding is done can be used to subvert the program that su runs. To combat this the LD_*, SHLIB_PATH (HP-UX only), LIBPATH (AIX only), and _RLD_* environmental variables are removed from the environment passed on to all commands executed."

Hence SHLIB_PATH wasn't getting inherited into the su'ed shell.

Thanks and Regards,
Hari
Alex Glennie
Honored Contributor

Re: SHLIB_PATH not getting inherited after su <username>

fyi there is a service request out : JAGae31170 requesting that

the su(1) man page 11.i should be updated to state that SHLIB_PATH,LD_PRELOAD,LD_LIBRARY_PATH are not retained when using su : on 11.i

So it's expected if not documented behaviour.
HARIHARAN N V
Occasional Advisor

Re: SHLIB_PATH not getting inherited after su <username>

Thanks Alex, for the information.

-Hari