Operating System - HP-UX
1833019 Members
2107 Online
110049 Solutions
New Discussion

Unix 10.20 seems to ignore setgid (set-group-id) bit.

 
SOLVED
Go to solution
Paul Hamilton
New Member

Unix 10.20 seems to ignore setgid (set-group-id) bit.

Am using chmod to set the group-id bit on a shell file. The bit was apparently set, but in testing the shell the effective group was evidently NOT set since permission was denied on a file accessable to the target group. I discovered a possible patch (PHNE_21029 --> PHNE_10030) but am not sure if this is the solution or I need to look elsewhere.
Nihil in sacculo quod non fuerit in capite. (There is nothing in the pocket which was not first in the head) -- Tesla
5 REPLIES 5
Andreas Voss
Honored Contributor
Solution

Re: Unix 10.20 seems to ignore setgid (set-group-id) bit.

Hi,

if you use suid or sgid bit to shell scripts the script has to start with e.g.:
#!/sbin/sh
at the fist line so that the OS can recognize the 'magic number' #!

Regards

Andrew
John Palmer
Honored Contributor

Re: Unix 10.20 seems to ignore setgid (set-group-id) bit.

As far as I am aware, setuid and setgid have never worked with scripts in 10.20. I have always had to write a simple C program to achieve this.

It does work with scripts however in 11.00
John Palmer
Honored Contributor

Re: Unix 10.20 seems to ignore setgid (set-group-id) bit.

Paul,

My memory is faulty. It was prior to 10.20 that it didn't work not 11.00.

Yes Andrew is correct you must have a valid shell header

Regards,
John
Anthony deRito
Respected Contributor

Re: Unix 10.20 seems to ignore setgid (set-group-id) bit.

setuid and setgid do work on shell scripts but there is a catch. If your shell script contains commands which must be run as root, the bits will not work when run as a regular user. You have to write a simple C program as John has indicated with a call to the root only binary. You would then compile it and then chmod 4777 and chown root on the C program it and it will work.

Document ID A1322471 explains this as well.

Tony
Paul Hamilton
New Member

Re: Unix 10.20 seems to ignore setgid (set-group-id) bit.

Andreas and John -
Tried your suggestion... it works!
Thanks for your help. Saved a lot of time.

Anthony -
I will eventually be using command which must run as root -- thanks for the caveat.

Paul
Nihil in sacculo quod non fuerit in capite. (There is nothing in the pocket which was not first in the head) -- Tesla