[Bug 2123] New: does not seem to support sftp protocol version 5 rename flag for overwriting files

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Mon Jul 1 20:01:20 EST 2013


https://bugzilla.mindrot.org/show_bug.cgi?id=2123

            Bug ID: 2123
           Summary: does not seem to support sftp protocol version 5
                    rename flag for overwriting files
           Product: Portable OpenSSH
           Version: 6.2p1
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: sftp-server
          Assignee: unassigned-bugs at mindrot.org
          Reporter: ms at teamix.de

Due to http://bugs.debian.org/714606 I seek an alternative to
ruby-net-ssh ssh.exec("mv old new") the authorized key file for our
distkeys SSH key distribution tool that I currently packages for Debian
(see there bug #712787).

I thought about using ruby-net-sftp rename! function as follows:

@sftp.rename!( newauthkeyfile, @authkeyfile, 0x0001 )


But I do get:

./distkeys -K somekey.pub -H somehost remove

Host: somehost
Connecting to host somehost (user: someuser, port: someport)...
Opening SFTP session...
Key somekey removed.
Creating a backup to .ssh/authorized_keys-2013-07-01.bak if not already
done today...
Uploading keys to .ssh/authorized_keys-new...
File does exist and has correct size, moving to .ssh/authorized_keys...
.ssh/authorized_keys-new
.ssh/authorized_keys
/usr/lib/ruby/vendor_ruby/net/sftp/session.rb:846:in `wait_for':
Net::SFTP::StatusException (4, "failure") (Net::SFTP::StatusException)
        from /usr/lib/ruby/vendor_ruby/net/sftp/session.rb:590:in
`rename!'
        from ./distkeys:210:in `block in commit'
        from /usr/lib/ruby/vendor_ruby/net/sftp/request.rb:87:in `call'
        from /usr/lib/ruby/vendor_ruby/net/sftp/request.rb:87:in
`respond_to'
        from /usr/lib/ruby/vendor_ruby/net/sftp/session.rb:948:in
`dispatch_request'
        from /usr/lib/ruby/vendor_ruby/net/sftp/session.rb:911:in
`when_channel_polled'
        from
/usr/lib/ruby/vendor_ruby/net/ssh/connection/channel.rb:311:in `call'
        from
/usr/lib/ruby/vendor_ruby/net/ssh/connection/channel.rb:311:in
`process'
        from
/usr/lib/ruby/vendor_ruby/net/ssh/connection/session.rb:214:in `block
in preprocess'
        from
/usr/lib/ruby/vendor_ruby/net/ssh/connection/session.rb:214:in `each'
        from
/usr/lib/ruby/vendor_ruby/net/ssh/connection/session.rb:214:in
`preprocess'
        from
/usr/lib/ruby/vendor_ruby/net/ssh/connection/session.rb:197:in
`process'
        from
/usr/lib/ruby/vendor_ruby/net/ssh/connection/session.rb:161:in `block
in loop'
        from
/usr/lib/ruby/vendor_ruby/net/ssh/connection/session.rb:161:in `loop'
        from
/usr/lib/ruby/vendor_ruby/net/ssh/connection/session.rb:161:in `loop'
        from /usr/lib/ruby/vendor_ruby/net/sftp/session.rb:802:in
`loop'
        from /usr/lib/ruby/vendor_ruby/net/sftp/request.rb:72:in `wait'
        from /usr/lib/ruby/vendor_ruby/net/sftp/session.rb:842:in
`wait_for'
        from /usr/lib/ruby/vendor_ruby/net/sftp/session.rb:320:in
`lstat!'
        from ./distkeys:200:in `commit'
        from ./distkeys:589:in `handle_host'
        from ./distkeys:681:in `block in handle_gwhost'
        from ./distkeys:664:in `each'
        from ./distkeys:664:in `handle_gwhost'
        from ./distkeys:696:in `loop'
        from ./distkeys:801:in `<main>'


If I prepend an

@sftp.remove!( @authkeyfile )

the file rename works. But I'd like to avoid having the race condition.

Ideally I like to use flags 0x0001 for overwrite and 0x0002 for
rewriting atomically for better security.

But according to ruby-net-sftp docs these require SFTP protocol version
5:

http://net-ssh.rubyforge.org/sftp/v2/api/

sftp client manpage as of openssh-client 6.0p1-4 (same on server) only
refers to protocol versions 1 and 2, but I am not sure whether this
refers to SSH or SFTP protocol version.

After trying to use SFTP to workaround the initial issue with
ruby-net-ssh I will now try ruby-net-scp for both file upload and
rename.

Thanks,
Martin

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list