problems with chmod
#!/usr/bin/perl -w use strict; my $dir = "cody"; mkdir("$dir",0770); i am running this in my home directory on a linux machine, so i have full rights. when i run this however, the permissions on the directory are: drwxr-x---2 cmenzes cmenzes 1024 Jul 7 10:39 cody/ which translates to 0750. i am thinking that this limit may have to do with my shell umask setting which is at 022, but i am not certain why it is taking precedence over the perl setting. if i change my second argument in my mkdir statement to 0660 or 0444, the proper permissions are set. the only pattern that i see is that i *can* explicitly set the permissions in a mkdir statement if they are more restrictive than my umask. otherwise the perms default to my umask. i know i can get past this by following the mkdir statement with a chmod, but i just wanted to verify that my logic on this one is correct.
Re: problems with chmod
On Sat, Jul 07, 2001 at 10:48:14AM -0500, [EMAIL PROTECTED] wrote: > #!/usr/bin/perl -w > > use strict; > > my $dir = "cody"; > mkdir("$dir",0770); > > > i am running this in my home directory on a linux machine, so i have full > rights. when i run this however, the permissions on the directory are: > > drwxr-x---2 cmenzes cmenzes 1024 Jul 7 10:39 cody/ > > which translates to 0750. i am thinking that this limit may have to do > with my shell umask setting which is at 022, but i am not certain why it > is taking precedence over the perl setting. if i change my second argument > in my mkdir statement to 0660 or 0444, the proper permissions are set. the > only pattern that i see is that i *can* explicitly set the permissions in > a mkdir statement if they are more restrictive than my umask. otherwise > the perms default to my umask. > i know i can get past this by following the mkdir statement with a chmod, > but i just wanted to verify that my logic on this one is correct. The second parameter to mkdir is just a mask, it's not the permission settings for the new directory. See perldoc -f mkdir for more information. Walt
Re: problems with chmod
You should do some error checking... #!/usr/bin/perl -w use strict; use Getcwd; my $dir = "cody"; mkdir("$dir",0770) or warn("Could not mkdir $dir in ".getcwd.": $!\n"); This will tell you why or how something might be going wrong and what your pwd is. Also, you should check the parent directory in which you are trying to make this directory for directory permissions (seteuid) which can cause the directory to be created the same as the parent directory. You should also see if you have a umask set. If so, this could cause the directory to default to a certain mode at first that might cause caveats with Perl (doubt it but just brain storming here). At 10:48 AM 7/7/2001 -0500, [EMAIL PROTECTED] wrote: >#!/usr/bin/perl -w > >use strict; > >my $dir = "cody"; >mkdir("$dir",0770); > > >i am running this in my home directory on a linux machine, so i have full >rights. when i run this however, the permissions on the directory are: > >drwxr-x---2 cmenzes cmenzes 1024 Jul 7 10:39 cody/ > >which translates to 0750. i am thinking that this limit may have to do >with my shell umask setting which is at 022, but i am not certain why it >is taking precedence over the perl setting. if i change my second argument >in my mkdir statement to 0660 or 0444, the proper permissions are set. the >only pattern that i see is that i *can* explicitly set the permissions in >a mkdir statement if they are more restrictive than my umask. otherwise >the perms default to my umask. >i know i can get past this by following the mkdir statement with a chmod, >but i just wanted to verify that my logic on this one is correct. - Jim -~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- http://www.perlmonks.org/index.pl?node_id=67861&lastnode_id=67861 -BEGIN PERL GEEK CODE BLOCK- --BEGIN GEEK CODE BLOCK-- Version: 0.01 Version: 3.12 P++>*@$c?P6?R+++>@$M GIT/CM/J d++(--) s++:++ a- >$O!MA->E!> PU-->+++BDC(+) UB$L$S$ $C-@D!>(-)$S@$X?WP+>MO!>+++ P++(+)>+ L+++()>+$ !E* +PP+++>n-CO?PO!o >G W++(+++) N+ o !K w--- PS---(-)@ PE >*(!)$A-->@$Ee---(-)Ev++uL++>*@$uB+ Y+>+++ PGP t+(+++)>+++@ 5- X++ R@ >*@$uS+>*@$uH+uo+w-@$m! tv+ b? DI-(+++) D+++(++) G() --END PERL GEEK CODE BLOCK-- --END GEEK CODE BLOCK--
Re: problems with chmod
> > This will tell you why or how something might be going wrong and what your > pwd is. Also, you should check the parent directory in which you are > trying to make this directory for directory permissions (seteuid) which can > cause the directory to be created the same as the parent directory. You > should also see if you have a umask set. If so, this could cause the > directory to default to a certain mode at first that might cause caveats > with Perl (doubt it but just brain storming here). > For now, i am just using this script to do a mkdir, so its a pretty isolated environment. The directory is successfully being made and the directory is my home dir, so no setuid bits are set or any unusual downward affecting permissions. My umask is set to 022. Someone else mentioned that perldoc -f mkdir would be of some help. The page does indicate that the second argument for mkdir is a mask rather than actual bits being set, but I am not certain exactly how this mask works. It doesnt appear to work like umask as far as i can tell. Again, the only pattern I am seeing is that the second argument can't set perms that exceed your current umask. In other words, my umask is 022, so mkdir wont let me create a directory with any permissions greater than 755, however 775 cant be done, however 711 can. Does that sound like normal response?