Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:permissions attribute and umask #8

Closed
mcarpenter opened this issue May 5, 2011 · 2 comments
Closed

:permissions attribute and umask #8

mcarpenter opened this issue May 5, 2011 · 2 comments

Comments

@mcarpenter
Copy link
Contributor

I'm trying to use :permissions with #mkdir but the results
are affected by umask and I can't see a way to set that via the API.

Client:

  • ubuntu 10.10
  • ruby 1.8.7 (stock ubuntu)
  • net/ssh 2.1.4
  • net/sftp 2.0.5

(net/sftp, net/ssh installed by rubygems, ubuntu stock libnet-ssh-ruby
and libnet-sftp-ruby packages not installed)

Server:

  • local or remote ubuntu or solaris, stock sshd
  • umask 027

Minimal test:

Net::SFTP.start( 'localhost', ENV['USER'] ) do |sftp|
  sftp.mkdir!( '/tmp/mydir', :permissions => 0560 )
end

Results:

0560 as above, gives:
dr-xr----- 2 martin martin 4096 2011-05-05 06:07 /tmp/mydir
(0540)

0666 gives:
drw-r----- 2 martin martin 4096 2011-05-05 06:09 /tmp/mydir
(0640)

0777 gives:
drwxr-x--- 2 martin martin 4096 2011-05-05 06:10 /tmp/mydir
(0750)

@mcarpenter
Copy link
Contributor Author

I'm going to close my own issue. I don't particularly like it, but it's not the fault of net-sftp.

The call to #mkdir! issues an SSH_FXP_MKDIR packet. Upon receipt of this the sftp-server (I checked OpenSSH source) performs a mkdir(2). The mode parameter to that system call is interpreted in the context of the sftp-server's umask (settable system wide with the -u flag to OpenSSH's sftp-server).

This is in contrast to userland command mkdir(1), which ignores umask (and which one uses directly more often than mkdir(2)...). Workaround: #setstat can set file permissions explicitly (analogous to chmod(2)) after directory creation.

@delano
Copy link
Collaborator

delano commented Jun 22, 2011

Thanks for the follow up on the issue by the way. And my apologies for the delay in replying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants