Home
TeamSite
chmod sticky bit
System
Is there a way to user Perl's internal chmod to set the sticky bit instead of shelling out to chmod? I did check the docs but couldn't find it.
It sure would be nice if the UI mkbr/mkwa operations had a sticky checbox and iwmkbr/iwmkwa had a command line param to do this automatically.
Find more posts tagged with
Comments
Adam Stoller
Hmm - I just did a quick search and found this:
http://sial.org/code/perl/scripts/modefix.pl
and
http://www.perl.com/language/ppt/src/chmod/SymbolicMode.pm
- which
seem
to indicate some manner of being able to deal with this issue - but I'd take it with a grain of salt as I'm not sure if these really work and/or if they are dependent on something else.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Migrateduser
This is one of the reasons I hate Perl - I can't see a comment like this slipping into the Sun Java docs:
# It looks like permission are 4 groups of 3 bits, groups for user,
# group and others, and a group for the special flags, but they are
# really 3 groups of 4 bits. Or maybe not.
(and this appears to have been written by the programmer that implemented chmod in Perl!) I think I am safer shelling out.
Valentine
chmod oct(1xxx), $file
you can read "man chmod", which will give you beloved sun docs
Migrateduser
Thanks. I did check man chmod and I understand how to set sticky bit with the CLT. According to perldoc chmod, using oct is not best practice (although I have no clue why):
$mode = '0644'; chmod oct($mode), 'foo'; # this is better
$mode = 0644; chmod $mode, 'foo'; # this is best
Is using oct the only way to set the sticky bit?
Valentine
You can always call /usr/bin/chmod with proper parameters.
Personally, I find octal permissions more convenient, but this is a personal preference.
Adam Stoller
That sets the 't' sticky bit not the g+s sticky bit (perhaps more accurately referred to as the set-user-or-group-id-on-execution bit) - however, I think you were close - it looks like:
chmod(oct(2xxx), $file);
works as desired (for some reason I thought I recalled that g+s didn't have a numerical equivalent [unix bug] - but apparently I mis-recalled)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Migrateduser
Good catch, thanks.
Valentine
)
sticky bit is 1xxx
setgid is 2xxx
setuid is 4xxx
Adam Stoller
Thanks - I realize that now - we've been using the term "sticky" because when applied to a directory it effectively makes the group permissions on the directory "stick" to the entries created within - but apparently that's the wrong term and hence the confusion.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Migrateduser
Sorry, my mistake in the original post.
Interestingly, stickybit.com seems to have expired recently in case anyone is interested.
gzevin
I never call it sticky - it's wrong!
it's set GID - bit
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
skip11
john wrote:
>(and this appears to have been written by the programmer that implemented chmod in Perl!) I think I am safer shelling out.
In reference to IW's statement about max gropus per user you could shell out for a different OS
RB