Permissions at creating directory

K

Kless

Why a new directory is ignoring my permissions?

Dir.mkdir('foo', 711)

It's created with 755, the permissions by deafult of my system. My
umask is to 0022.
 
M

Michael Monaghan

[Note: parts of this message were removed to make it a legal post.]

Instead of 711, try 0711.

~mm
 
B

Brian Candler

Kless said:
Why a new directory is ignoring my permissions?

Dir.mkdir('foo', 711)

It's created with 755, the permissions by deafult of my system. My
umask is to 0022.

So what's "your system"? (i.e. OS and Ruby version)

It Works For Me [TM]. This is Ubuntu Dapper with its default Ruby:

irb(main):001:0> RUBY_VERSION
=> "1.8.4"
irb(main):002:0> "%o" % File.umask
=> "22"
irb(main):003:0> Dir.mkdir "foo1"
=> 0
irb(main):004:0> `ls -ld foo1`
=> "drwxr-xr-x 2 candlerb candlerb 4096 2008-10-15 09:31 foo1\n"
irb(main):005:0> Dir.mkdir "foo2", 0700
=> 0
irb(main):006:0> `ls -ld foo2`
=> "drwx------ 2 candlerb candlerb 4096 2008-10-15 09:31 foo2\n"
irb(main):007:0>

but I get the same with 1.8.6p114 built from source under Ubuntu Hardy.

What happens if you try to chmod the directory after creating it? What
filesystem are you trying to create this directory in?

If you have a Linux box but are creating files in a mounted MS-DOS
filesystem (typically the case for a memory stick) then you'll get the
same Unix mode bits for everything, as the filesystem doesn't store
them.

HTH,

Brian.
 
K

Kless

Kless said:
Why a new directory is ignoring my permissions?
Dir.mkdir('foo', 711)
It's created with 755, the permissions by deafult of my system. My
umask is to 0022.

So what's "your system"? (i.e. OS and Ruby version)

It Works For Me [TM]. This is Ubuntu Dapper with its default Ruby:

irb(main):001:0> RUBY_VERSION
=> "1.8.4"
irb(main):002:0> "%o" % File.umask
=> "22"
irb(main):003:0> Dir.mkdir "foo1"
=> 0
irb(main):004:0> `ls -ld foo1`
=> "drwxr-xr-x 2 candlerb candlerb 4096 2008-10-15 09:31 foo1\n"
irb(main):005:0> Dir.mkdir "foo2", 0700
=> 0
irb(main):006:0> `ls -ld foo2`
=> "drwx------ 2 candlerb candlerb 4096 2008-10-15 09:31 foo2\n"
irb(main):007:0>

but I get the same with 1.8.6p114 built from source under Ubuntu Hardy.

What happens if you try to chmod the directory after creating it? What
filesystem are you trying to create this directory in?

If you have a Linux box but are creating files in a mounted MS-DOS
filesystem (typically the case for a memory stick) then you'll get the
same Unix mode bits for everything, as the filesystem doesn't store
them.

HTH,

Brian.

Thanks! You gave me the idea.

The problem is that I'm trying to create a subdirectory, anything as
'./foo/bar'. If it's tryed in irb, it gives a failure.

But I was calling it since a JRuby program where it's created
correctly except for the mode.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top