开发者

How to use Perl chmod to add Set Group ID on a directory?

I can use the Perl ch开发者_运维百科mod function to set the permission bits, for example:

chmod S_IRWXU|S_IRWXG|S_IROTH, $the_dir;

How do I add Set Group ID to the directory in the above command?


Don't know what the S_xxx alias is for the set group id bit, but it's value is (octal) 02000. So one of

chmod 02000|S_IRWXU|S_IRWXG|S_IROTH, $the_dir;

chmod 02774, $the_dir;

will probably work.

Edit: Now I do know what the appropriate S_xxx constant is named: it's S_ISGID.

$ perl -MFcntl -e 'printf "0%o", Fcntl::S_ISGID()'
02000


You can't use chmod to do that. Use chown and set the uid to -1, i.e.

chown -1, $groupid, $the_dir;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜