CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Setting setuid/setgid permission using mkdir

 



blahyn8
New User

Oct 7, 2009, 8:45 AM

Post #1 of 3 (1283 views)
Setting setuid/setgid permission using mkdir Can't Post

I was trying to set the setgid bit for a new directory using perl's mkdir subroutine. It didn't work so I created a script to find out more about mkdir:

umask 7;

# both set sticky bit
mkdir ("blah1", oct(1755));
mkdir ("blah2", 01755);

# does nothing
mkdir ("blah3", 02755);
mkdir ("blah4", oct(2755));
mkdir ("blah5", oct(4755));
mkdir ("blah6", 04755);

The permissions that result are:

drwxr-x--T 2 tdc_user 80 2009-10-07 10:30 blah1/
drwxr-x--T 2 tdc_user 80 2009-10-07 10:30 blah2/
drwxr-x--- 2 tdc_user 80 2009-10-07 10:30 blah3/
drwxr-x--- 2 tdc_user 80 2009-10-07 10:30 blah4/
drwxr-x--- 2 tdc_user 80 2009-10-07 10:30 blah5/
drwxr-x--- 2 tdc_user 80 2009-10-07 10:30 blah6/

Does anybody know if it's possible to set the setgid bit at the same time as creating the directory using mkdir?


shawnhcorey
Enthusiast


Oct 7, 2009, 9:34 AM

Post #2 of 3 (1282 views)
Re: [blahyn8] Setting setuid/setgid permission using mkdir [In reply to] Can't Post

Do you run the program as root? Only root can setuid and setgid.

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


blahyn8
New User

Oct 7, 2009, 2:34 PM

Post #3 of 3 (1275 views)
Re: [shawnhcorey] Setting setuid/setgid permission using mkdir [In reply to] Can't Post

but i can set the setgid bit by doing a chmod right after mkdir in the script. why doesn't mkdir allow me to set the setgid bit?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives