Operating System - HP-UX
1830931 Members
2387 Online
110017 Solutions
New Discussion

how to su non-interactive in trusted mode

 
C W_1
Occasional Contributor

how to su non-interactive in trusted mode

HPUX 11.11, converted to trusted mode, need to run some scripts that "su - username" and execute application startups. Now in trusted mode su wants a password, even though I am root.

How can I get around this?
2 REPLIES 2
Jeff_Traigle
Honored Contributor

Re: how to su non-interactive in trusted mode

Well, I tried duplicating your issue on 11.00 and 11.11 with no luck... su worked just like it does in untrusted mode. Of course, I was just using the default settings once I converted it to trusted.
--
Jeff Traigle
Muthukumar_5
Honored Contributor

Re: how to su non-interactive in trusted mode

You can do it with simple scripting or programming as,

mv your original /usr/bin/su to /usr/bin/suorg

Make your new script or program to ask passwd for su actions and call moved binary of /usr/bin/su for operation.

Make your binary or c program with the name as su and move it to /usr/bin/su so that it will be called when ever you use su.

And change the permission of binary or script so that others can not access it.

Sample script:
---------------

#!/usr/bin/ksh
# command options
hypen=$1
username=$2
passwd=$3

# Your plain-text passwd
passwd="passwdtest"
printf "passwd: "
read pwd

# /usr/bin/su1 is the real su command
if [[ $pwd = $passwd ]]; then
if [[ "$username" = "" ]]; then
/usr/bin/su $hypen
else
/usr/bin/su $hypen $username
fi
fi

It will be not be used to execute commands with su. Changes needed to make your requirement.

Regards
Muthu
Easy to suggest when don't know about the problem!