Operating System - HP-UX
1834931 Members
2479 Online
110071 Solutions
New Discussion

Re: su command in "SUID" script

 
SOLVED
Go to solution
Troyan Krastev
Regular Advisor

su command in "SUID" script

Hi All HP Admins,

When I try to execute su command from a shell script with SetUserID bit set it asks for the password. Is it posible to avoid it?
The script:
---------------------------
$ cat prog.sh
#!/usr/bin/sh

set -x
id
su oracle -c "pwd"
---------------------------
The permissions:
$ ll
total 2
-r-sr-xr-x 1 root sys 48 Jul 1 14:29 prog.sh
---------------------------
The execution:
$ ./prog.sh
+ id
uid=250(patrol) gid=200(sybadm) euid=0(root)
+ su oracle -c pwd
Password:
su: Sorry
---------------------------
I don't need the "Password:" prompt!!!!

Thanks,
Troy.
5 REPLIES 5
Hai Nguyen_1
Honored Contributor

Re: su command in "SUID" script

Troy,

From my understanding, only root can bypass password when running the su command.

Hai
A. Clay Stephenson
Acclaimed Contributor

Re: su command in "SUID" script

Whether you need it or not, you are going to get it unless you are root.

You mightr consider sudo or writing a setuid wrapper in C.
If it ain't broke, I can fix that.
Arockia Jegan
Trusted Contributor
Solution

Re: su command in "SUID" script

You can use sudo for this issue. If you don't have sudo software use the following link to download it,


http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/sudo-1.6.6/
Nick Wickens
Respected Contributor

Re: su command in "SUID" script

I always get lost with sticky bits but do you not have to have the owner of prog.sh set to oracle rather than root for this to work. This seems to be setting the effective user to root whenever you run prog.sh when you want the user to be oracle ?? .

I use Sudo for a number of such tasks but even with sudo I am still getting the user to enter a password to verify and I am not sure you can stop this.
Hats ? We don't need no stinkin' hats !!
Arockia Jegan
Trusted Contributor

Re: su command in "SUID" script

Nic,

Did you try with NOPASSWD entry in sudoers file? That will help you to skip the passwd when you use sudo...