net-sftp 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. data/CHANGELOG.rdoc +23 -0
  2. data/Manifest +55 -0
  3. data/README.rdoc +96 -0
  4. data/Rakefile +30 -0
  5. data/lib/net/sftp.rb +53 -38
  6. data/lib/net/sftp/constants.rb +187 -0
  7. data/lib/net/sftp/errors.rb +34 -20
  8. data/lib/net/sftp/operations/dir.rb +93 -0
  9. data/lib/net/sftp/operations/download.rb +364 -0
  10. data/lib/net/sftp/operations/file.rb +176 -0
  11. data/lib/net/sftp/operations/file_factory.rb +60 -0
  12. data/lib/net/sftp/operations/upload.rb +387 -0
  13. data/lib/net/sftp/packet.rb +21 -0
  14. data/lib/net/sftp/protocol.rb +32 -0
  15. data/lib/net/sftp/protocol/01/attributes.rb +265 -96
  16. data/lib/net/sftp/protocol/01/base.rb +268 -0
  17. data/lib/net/sftp/protocol/01/name.rb +43 -0
  18. data/lib/net/sftp/protocol/02/base.rb +31 -0
  19. data/lib/net/sftp/protocol/03/base.rb +35 -0
  20. data/lib/net/sftp/protocol/04/attributes.rb +120 -195
  21. data/lib/net/sftp/protocol/04/base.rb +94 -0
  22. data/lib/net/sftp/protocol/04/name.rb +67 -0
  23. data/lib/net/sftp/protocol/05/base.rb +66 -0
  24. data/lib/net/sftp/protocol/06/attributes.rb +107 -0
  25. data/lib/net/sftp/protocol/06/base.rb +63 -0
  26. data/lib/net/sftp/protocol/base.rb +50 -0
  27. data/lib/net/sftp/request.rb +91 -0
  28. data/lib/net/sftp/response.rb +76 -0
  29. data/lib/net/sftp/session.rb +914 -238
  30. data/lib/net/sftp/version.rb +14 -21
  31. data/net-sftp.gemspec +60 -0
  32. data/setup.rb +1331 -0
  33. data/test/common.rb +173 -0
  34. data/test/protocol/01/test_attributes.rb +97 -0
  35. data/test/protocol/01/test_base.rb +210 -0
  36. data/test/protocol/01/test_name.rb +27 -0
  37. data/test/protocol/02/test_base.rb +26 -0
  38. data/test/protocol/03/test_base.rb +27 -0
  39. data/test/protocol/04/test_attributes.rb +148 -0
  40. data/test/protocol/04/test_base.rb +74 -0
  41. data/test/protocol/04/test_name.rb +49 -0
  42. data/test/protocol/05/test_base.rb +62 -0
  43. data/test/protocol/06/test_attributes.rb +124 -0
  44. data/test/protocol/06/test_base.rb +51 -0
  45. data/test/protocol/test_base.rb +42 -0
  46. data/test/test_all.rb +3 -0
  47. data/test/test_dir.rb +47 -0
  48. data/test/test_download.rb +252 -0
  49. data/test/test_file.rb +159 -0
  50. data/test/test_file_factory.rb +48 -0
  51. data/test/test_packet.rb +9 -0
  52. data/test/test_protocol.rb +17 -0
  53. data/test/test_request.rb +71 -0
  54. data/test/test_response.rb +53 -0
  55. data/test/test_session.rb +741 -0
  56. data/test/test_upload.rb +219 -0
  57. metadata +59 -111
  58. data/doc/LICENSE-BSD +0 -27
  59. data/doc/LICENSE-GPL +0 -280
  60. data/doc/LICENSE-RUBY +0 -56
  61. data/doc/faq/faq.html +0 -298
  62. data/doc/faq/faq.rb +0 -154
  63. data/doc/faq/faq.yml +0 -183
  64. data/examples/asynchronous.rb +0 -57
  65. data/examples/get-put.rb +0 -45
  66. data/examples/sftp-open-uri.rb +0 -30
  67. data/examples/ssh-service.rb +0 -30
  68. data/examples/synchronous.rb +0 -131
  69. data/lib/net/sftp/operations/abstract.rb +0 -108
  70. data/lib/net/sftp/operations/close.rb +0 -31
  71. data/lib/net/sftp/operations/errors.rb +0 -76
  72. data/lib/net/sftp/operations/fsetstat.rb +0 -36
  73. data/lib/net/sftp/operations/fstat.rb +0 -32
  74. data/lib/net/sftp/operations/lstat.rb +0 -31
  75. data/lib/net/sftp/operations/mkdir.rb +0 -33
  76. data/lib/net/sftp/operations/open.rb +0 -32
  77. data/lib/net/sftp/operations/opendir.rb +0 -32
  78. data/lib/net/sftp/operations/read.rb +0 -88
  79. data/lib/net/sftp/operations/readdir.rb +0 -55
  80. data/lib/net/sftp/operations/realpath.rb +0 -37
  81. data/lib/net/sftp/operations/remove.rb +0 -31
  82. data/lib/net/sftp/operations/rename.rb +0 -32
  83. data/lib/net/sftp/operations/rmdir.rb +0 -31
  84. data/lib/net/sftp/operations/services.rb +0 -42
  85. data/lib/net/sftp/operations/setstat.rb +0 -33
  86. data/lib/net/sftp/operations/stat.rb +0 -31
  87. data/lib/net/sftp/operations/write.rb +0 -63
  88. data/lib/net/sftp/protocol/01/impl.rb +0 -251
  89. data/lib/net/sftp/protocol/01/packet-assistant.rb +0 -82
  90. data/lib/net/sftp/protocol/01/services.rb +0 -47
  91. data/lib/net/sftp/protocol/02/impl.rb +0 -39
  92. data/lib/net/sftp/protocol/02/packet-assistant.rb +0 -32
  93. data/lib/net/sftp/protocol/02/services.rb +0 -44
  94. data/lib/net/sftp/protocol/03/impl.rb +0 -42
  95. data/lib/net/sftp/protocol/03/packet-assistant.rb +0 -35
  96. data/lib/net/sftp/protocol/03/services.rb +0 -44
  97. data/lib/net/sftp/protocol/04/impl.rb +0 -86
  98. data/lib/net/sftp/protocol/04/packet-assistant.rb +0 -45
  99. data/lib/net/sftp/protocol/04/services.rb +0 -44
  100. data/lib/net/sftp/protocol/05/impl.rb +0 -90
  101. data/lib/net/sftp/protocol/05/packet-assistant.rb +0 -34
  102. data/lib/net/sftp/protocol/05/services.rb +0 -44
  103. data/lib/net/sftp/protocol/constants.rb +0 -60
  104. data/lib/net/sftp/protocol/driver.rb +0 -235
  105. data/lib/net/sftp/protocol/packet-assistant.rb +0 -84
  106. data/lib/net/sftp/protocol/services.rb +0 -55
  107. data/lib/uri/open-sftp.rb +0 -54
  108. data/lib/uri/sftp.rb +0 -42
  109. data/test/ALL-TESTS.rb +0 -23
  110. data/test/operations/tc_abstract.rb +0 -124
  111. data/test/operations/tc_close.rb +0 -40
  112. data/test/operations/tc_fsetstat.rb +0 -48
  113. data/test/operations/tc_fstat.rb +0 -40
  114. data/test/operations/tc_lstat.rb +0 -40
  115. data/test/operations/tc_mkdir.rb +0 -48
  116. data/test/operations/tc_open.rb +0 -42
  117. data/test/operations/tc_opendir.rb +0 -40
  118. data/test/operations/tc_read.rb +0 -103
  119. data/test/operations/tc_readdir.rb +0 -88
  120. data/test/operations/tc_realpath.rb +0 -54
  121. data/test/operations/tc_remove.rb +0 -40
  122. data/test/operations/tc_rmdir.rb +0 -40
  123. data/test/operations/tc_setstat.rb +0 -48
  124. data/test/operations/tc_stat.rb +0 -40
  125. data/test/operations/tc_write.rb +0 -91
  126. data/test/protocol/01/tc_attributes.rb +0 -138
  127. data/test/protocol/01/tc_impl.rb +0 -294
  128. data/test/protocol/01/tc_packet_assistant.rb +0 -81
  129. data/test/protocol/02/tc_impl.rb +0 -41
  130. data/test/protocol/02/tc_packet_assistant.rb +0 -31
  131. data/test/protocol/03/tc_impl.rb +0 -48
  132. data/test/protocol/03/tc_packet_assistant.rb +0 -34
  133. data/test/protocol/04/tc_attributes.rb +0 -174
  134. data/test/protocol/04/tc_impl.rb +0 -91
  135. data/test/protocol/04/tc_packet_assistant.rb +0 -38
  136. data/test/protocol/05/tc_impl.rb +0 -61
  137. data/test/protocol/05/tc_packet_assistant.rb +0 -32
  138. data/test/protocol/tc_driver.rb +0 -219
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,23 @@
1
+ === 2.0.0 / 1 May 2008
2
+
3
+ * Make Net::SSH::Connection::Session#sftp accept an argument determining whether or not to block while the SFTP subsystem initializes (defaults to true) [Jamis Buck]
4
+
5
+ * Allow Session#connect to be useful even in the open/opening states by invoking or queuing the callback block [Jamis Buck]
6
+
7
+ * Allow custom properties to be set on upload/download initiation via the :properties option [Jamis Buck]
8
+
9
+ * Custom properties on Download instances [Jamis Buck]
10
+
11
+ * Add #abort! method to Upload and Download operations [Jamis Buck]
12
+
13
+ * More complete support for file-type detection in protocol versions 1-3 [Jamis Buck]
14
+
15
+
16
+ === 2.0 Preview Release 2 (1.99.1) / 10 Apr 2008
17
+
18
+ * Custom properties on Upload instances [Jamis Buck]
19
+
20
+
21
+ === 2.0 Preview Release 1 (1.99.0) / 22 Mar 2008
22
+
23
+ * Rewritten! (Never, ever, do this at home.) New and improved API.
data/Manifest ADDED
@@ -0,0 +1,55 @@
1
+ CHANGELOG.rdoc
2
+ lib/net/sftp/constants.rb
3
+ lib/net/sftp/errors.rb
4
+ lib/net/sftp/operations/dir.rb
5
+ lib/net/sftp/operations/download.rb
6
+ lib/net/sftp/operations/file.rb
7
+ lib/net/sftp/operations/file_factory.rb
8
+ lib/net/sftp/operations/upload.rb
9
+ lib/net/sftp/packet.rb
10
+ lib/net/sftp/protocol/01/attributes.rb
11
+ lib/net/sftp/protocol/01/base.rb
12
+ lib/net/sftp/protocol/01/name.rb
13
+ lib/net/sftp/protocol/02/base.rb
14
+ lib/net/sftp/protocol/03/base.rb
15
+ lib/net/sftp/protocol/04/attributes.rb
16
+ lib/net/sftp/protocol/04/base.rb
17
+ lib/net/sftp/protocol/04/name.rb
18
+ lib/net/sftp/protocol/05/base.rb
19
+ lib/net/sftp/protocol/06/attributes.rb
20
+ lib/net/sftp/protocol/06/base.rb
21
+ lib/net/sftp/protocol/base.rb
22
+ lib/net/sftp/protocol.rb
23
+ lib/net/sftp/request.rb
24
+ lib/net/sftp/response.rb
25
+ lib/net/sftp/session.rb
26
+ lib/net/sftp/version.rb
27
+ lib/net/sftp.rb
28
+ Rakefile
29
+ README.rdoc
30
+ setup.rb
31
+ test/common.rb
32
+ test/protocol/01/test_attributes.rb
33
+ test/protocol/01/test_base.rb
34
+ test/protocol/01/test_name.rb
35
+ test/protocol/02/test_base.rb
36
+ test/protocol/03/test_base.rb
37
+ test/protocol/04/test_attributes.rb
38
+ test/protocol/04/test_base.rb
39
+ test/protocol/04/test_name.rb
40
+ test/protocol/05/test_base.rb
41
+ test/protocol/06/test_attributes.rb
42
+ test/protocol/06/test_base.rb
43
+ test/protocol/test_base.rb
44
+ test/test_all.rb
45
+ test/test_dir.rb
46
+ test/test_download.rb
47
+ test/test_file.rb
48
+ test/test_file_factory.rb
49
+ test/test_packet.rb
50
+ test/test_protocol.rb
51
+ test/test_request.rb
52
+ test/test_response.rb
53
+ test/test_session.rb
54
+ test/test_upload.rb
55
+ Manifest
data/README.rdoc ADDED
@@ -0,0 +1,96 @@
1
+ = Net::SFTP
2
+
3
+ * http://net-ssh.rubyforge.org/sftp
4
+
5
+ == DESCRIPTION:
6
+
7
+ Net::SFTP is a pure-Ruby implementation of the SFTP protocol (specifically, versions 1 through 6 of the SFTP protocol). Note that this is the "Secure File Transfer Protocol", typically run over an SSH connection, and has nothing to do with the FTP protocol.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Transfer files or even entire directory trees to or from a remote host via SFTP
12
+ * Completely supports all six protocol versions
13
+ * Asynchronous and synchronous operation
14
+ * Read and write files using an IO-like interface
15
+
16
+ == SYNOPSIS:
17
+
18
+ In a nutshell:
19
+
20
+ require 'net/sftp'
21
+
22
+ Net::SFTP.start('host', 'username', :password => 'password') do |sftp|
23
+ # upload a file or directory to the remote host
24
+ sftp.upload!("/path/to/local", "/path/to/remote")
25
+
26
+ # download a file or directory from the remote host
27
+ sftp.download!("/path/to/remote", "/path/to/local")
28
+
29
+ # grab data off the remote host directly to a buffer
30
+ data = sftp.download!("/path/to/remote")
31
+
32
+ # open and write to a pseudo-IO for a remote file
33
+ sftp.file.open("/path/to/remote", "w") do |f|
34
+ f.puts "Hello, world!\n"
35
+ end
36
+
37
+ # open and read from a pseudo-IO for a remote file
38
+ sftp.file.open("/path/to/remote", "r") do |f|
39
+ puts f.gets
40
+ end
41
+
42
+ # create a directory
43
+ sftp.mkdir! "/path/to/directory"
44
+
45
+ # list the entries in a directory
46
+ sftp.dir.foreach("/path/to/directory") do |entry|
47
+ puts entry.longname
48
+ end
49
+ end
50
+
51
+ For the full documentation, start with Net::SFTP::Session. Also see Net::SFTP::Operations::Upload, Net::SFTP::Operations::Download, Net::SFTP::Operations::FileFactory, Net::SFTP::Operations::File, and Net::SFTP::Operations::Dir.
52
+
53
+ == REQUIREMENTS:
54
+
55
+ * Net::SSH 2
56
+
57
+ If you wish to run the tests, you'll need:
58
+
59
+ * Echoe (if you want to use the Rakefile)
60
+ * Mocha
61
+
62
+ == INSTALL:
63
+
64
+ * gem install net-sftp (might need sudo privileges)
65
+
66
+ Or, if you prefer to do it the hard way (sans Rubygems):
67
+
68
+ * tar xzf net-ssh-*.tgz
69
+ * cd net-ssh-*
70
+ * ruby setup.rb config
71
+ * ruby setup.rb install (might need sudo privileges)
72
+
73
+ == LICENSE:
74
+
75
+ (The MIT License)
76
+
77
+ Copyright (c) 2008 Jamis Buck <jamis@37signals.com>
78
+
79
+ Permission is hereby granted, free of charge, to any person obtaining
80
+ a copy of this software and associated documentation files (the
81
+ 'Software'), to deal in the Software without restriction, including
82
+ without limitation the rights to use, copy, modify, merge, publish,
83
+ distribute, sublicense, and/or sell copies of the Software, and to
84
+ permit persons to whom the Software is furnished to do so, subject to
85
+ the following conditions:
86
+
87
+ The above copyright notice and this permission notice shall be
88
+ included in all copies or substantial portions of the Software.
89
+
90
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
91
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
92
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
93
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
94
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
95
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
96
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ $LOAD_PATH.unshift "../net-ssh/lib"
2
+ require './lib/net/sftp/version'
3
+
4
+ begin
5
+ require 'echoe'
6
+ rescue LoadError
7
+ abort "You'll need to have `echoe' installed to use Net::SFTP's Rakefile"
8
+ end
9
+
10
+ version = Net::SFTP::Version::STRING.dup
11
+ if ENV['SNAPSHOT'].to_i == 1
12
+ version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
13
+ end
14
+
15
+ Echoe.new('net-sftp', version) do |p|
16
+ p.project = "net-ssh"
17
+ p.changelog = "CHANGELOG.rdoc"
18
+
19
+ p.author = "Jamis Buck"
20
+ p.email = "jamis@jamisbuck.org"
21
+ p.summary = "A pure Ruby implementation of the SFTP client protocol"
22
+ p.url = "http://net-ssh.rubyforge.org/sftp"
23
+
24
+ p.dependencies = ["net-ssh >=1.99.1"]
25
+
26
+ p.need_zip = true
27
+ p.include_rakefile = true
28
+
29
+ p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc)/
30
+ end
data/lib/net/sftp.rb CHANGED
@@ -1,45 +1,60 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- begin
18
- require 'rubygems'
19
- gem "net-ssh", "< 1.99.0"
20
- rescue LoadError
21
- end
22
-
23
1
  require 'net/ssh'
24
2
  require 'net/sftp/session'
25
3
 
26
- module Net ; module SFTP
4
+ module Net
27
5
 
28
- # A convenience method for starting a standalone SFTP session. It will
29
- # start up an SSH session using the given arguments (see the documentation
30
- # for Net::SSH::Session for details), and will then start a new SFTP session
31
- # with the SSH session. If a block is given, it will be passed to the SFTP
32
- # session.
33
- def start( *args, &block )
34
- session = Net::SSH.start( *args )
35
- Net::SFTP::Session.new( session, &block )
36
- ensure
37
- session.close if session && block_given?
38
- end
39
- module_function :start
6
+ # Net::SFTP is a pure-Ruby module for programmatically interacting with a
7
+ # remote host via the SFTP protocol (that's SFTP as in "Secure File Transfer
8
+ # Protocol" produced by the Secure Shell Working Group, not "Secure FTP"
9
+ # and certainly not "Simple FTP").
10
+ #
11
+ # See Net::SFTP#start for an introduction to the library. Also, see
12
+ # Net::SFTP::Session for further documentation.
13
+ module SFTP
14
+ # A convenience method for starting a standalone SFTP session. It will
15
+ # start up an SSH session using the given arguments (see the documentation
16
+ # for Net::SSH::Session for details), and will then start a new SFTP session
17
+ # with the SSH session. This will block until the new SFTP is fully open
18
+ # and initialized before returning it.
19
+ #
20
+ # sftp = Net::SFTP.start("localhost", "user")
21
+ # sftp.upload! "/local/file.tgz", "/remote/file.tgz"
22
+ #
23
+ # If a block is given, it will be passed to the SFTP session and will be
24
+ # called once the SFTP session is fully open and initialized. When the
25
+ # block terminates, the new SSH session will automatically be closed.
26
+ #
27
+ # Net::SFTP.start("localhost", "user") do |sftp|
28
+ # sftp.upload! "/local/file.tgz", "/remote/file.tgz"
29
+ # end
30
+ def self.start(host, user, options={}, &block)
31
+ session = Net::SSH.start(host, user, options)
32
+ sftp = Net::SFTP::Session.new(session, &block).connect!
40
33
 
41
- end ; end
34
+ sftp.loop if block_given?
35
+
36
+ sftp
37
+ ensure
38
+ session.close if session && block_given?
39
+ end
40
+ end
42
41
 
43
- Net::SSH.register_service( :sftp ) do |c,p|
44
- Net::SFTP::Session.new( c[:session] )
45
42
  end
43
+
44
+ class Net::SSH::Connection::Session
45
+ # A convenience method for starting up a new SFTP connection on the current
46
+ # SSH session. Blocks until the SFTP session is fully open, and then
47
+ # returns the SFTP session.
48
+ #
49
+ # Net::SSH.start("localhost", "user", "password") do |ssh|
50
+ # ssh.sftp.upload!("/local/file.tgz", "/remote/file.tgz")
51
+ # ssh.exec! "cd /some/path && tar xf /remote/file.tgz && rm /remote/file.tgz"
52
+ # end
53
+ def sftp(wait=true)
54
+ @sftp ||= begin
55
+ sftp = Net::SFTP::Session.new(self)
56
+ sftp.connect! if wait
57
+ sftp
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,187 @@
1
+ module Net module SFTP
2
+
3
+ # The packet types and other general constants used by the SFTP protocol.
4
+ # See the specification for the SFTP protocol for a full discussion of their
5
+ # meaning and usage.
6
+ module Constants
7
+
8
+ # The various packet types supported by SFTP protocol versions 1 through 6.
9
+ # The FXP_EXTENDED and FXP_EXTENDED_REPLY packet types are not currently
10
+ # understood by Net::SFTP.
11
+ module PacketTypes
12
+ FXP_INIT = 1
13
+ FXP_VERSION = 2
14
+
15
+ FXP_OPEN = 3
16
+ FXP_CLOSE = 4
17
+ FXP_READ = 5
18
+ FXP_WRITE = 6
19
+ FXP_LSTAT = 7
20
+ FXP_FSTAT = 8
21
+ FXP_SETSTAT = 9
22
+ FXP_FSETSTAT = 10
23
+ FXP_OPENDIR = 11
24
+ FXP_READDIR = 12
25
+ FXP_REMOVE = 13
26
+ FXP_MKDIR = 14
27
+ FXP_RMDIR = 15
28
+ FXP_REALPATH = 16
29
+ FXP_STAT = 17
30
+ FXP_RENAME = 18
31
+ FXP_READLINK = 19
32
+ FXP_SYMLINK = 20
33
+ FXP_LINK = 21
34
+ FXP_BLOCK = 22
35
+ FXP_UNBLOCK = 23
36
+
37
+ FXP_STATUS = 101
38
+ FXP_HANDLE = 102
39
+ FXP_DATA = 103
40
+ FXP_NAME = 104
41
+ FXP_ATTRS = 105
42
+
43
+ FXP_EXTENDED = 200
44
+ FXP_EXTENDED_REPLY = 201
45
+ end
46
+
47
+ # Beginning in version 5 of the protocol, Net::SFTP::Session#rename accepts
48
+ # an optional +flags+ argument that must be either 0 or a combination of
49
+ # these constants.
50
+ module RenameFlags
51
+ OVERWRITE = 0x00000001
52
+ ATOMIC = 0x00000002
53
+ NATIVE = 0x00000004
54
+ end
55
+
56
+ # When an FXP_STATUS packet is received from the server, the +code+ will
57
+ # be one of the following constants.
58
+ module StatusCodes
59
+ FX_OK = 0
60
+ FX_EOF = 1
61
+ FX_NO_SUCH_FILE = 2
62
+ FX_PERMISSION_DENIED = 3
63
+ FX_FAILURE = 4
64
+ FX_BAD_MESSAGE = 5
65
+ FX_NO_CONNECTION = 6
66
+ FX_CONNECTION_LOST = 7
67
+ FX_OP_UNSUPPORTED = 8
68
+ FX_INVALID_HANDLE = 9
69
+ FX_NO_SUCH_PATH = 10
70
+ FX_FILE_ALREADY_EXISTS = 11
71
+ FX_WRITE_PROTECT = 12
72
+ FX_NO_MEDIA = 13
73
+ FX_NO_SPACE_ON_FILESYSTEM = 14
74
+ FX_QUOTA_EXCEEDED = 15
75
+ FX_UNKNOWN_PRINCIPLE = 16
76
+ FX_LOCK_CONFlICT = 17
77
+ FX_DIR_NOT_EMPTY = 18
78
+ FX_NOT_A_DIRECTORY = 19
79
+ FX_INVALID_FILENAME = 20
80
+ FX_LINK_LOOP = 21
81
+ end
82
+
83
+ # The Net::SFTP::Session#open operation is one of the worst casualties of
84
+ # the revisions between SFTP protocol versions. The flags change considerably
85
+ # between version 1 and version 6. Net::SFTP tries to shield programmers
86
+ # from the differences, so you'll almost never need to use these flags
87
+ # directly, but if you ever need to specify some flag that isn't exposed
88
+ # by the higher-level API, these are the ones that are available to you.
89
+ module OpenFlags
90
+ # These are the flags that are understood by versions 1-4 of the the
91
+ # open operation.
92
+ module FV1
93
+ READ = 0x00000001
94
+ WRITE = 0x00000002
95
+ APPEND = 0x00000004
96
+ CREAT = 0x00000008
97
+ TRUNC = 0x00000010
98
+ EXCL = 0x00000020
99
+ end
100
+
101
+ # Version 5 of the open operation totally discarded the flags understood
102
+ # by versions 1-4, and replaced them with these.
103
+ module FV5
104
+ CREATE_NEW = 0x00000000
105
+ CREATE_TRUNCATE = 0x00000001
106
+ OPEN_EXISTING = 0x00000002
107
+ OPEN_OR_CREATE = 0x00000003
108
+ TRUNCATE_EXISTING = 0x00000004
109
+
110
+ APPEND_DATA = 0x00000008
111
+ APPEND_DATA_ATOMIC = 0x00000010
112
+ TEXT_MODE = 0x00000020
113
+ READ_LOCK = 0x00000040
114
+ WRITE_LOCK = 0x00000080
115
+ DELETE_LOCK = 0x00000100
116
+ end
117
+
118
+ # Version 6 of the open operation added these flags, in addition to the
119
+ # flags understood by version 5.
120
+ module FV6
121
+ ADVISORY_LOCK = 0x00000200
122
+ NOFOLLOW = 0x00000400
123
+ DELETE_ON_CLOSE = 0x00000800
124
+ ACCESS_AUDIT_ALARM_INFO = 0x00001000
125
+ ACCESS_BACKUP = 0x00002000
126
+ BACKUP_STREAM = 0x00004000
127
+ OVERRIDE_OWNER = 0x00008000
128
+ end
129
+ end
130
+
131
+ # The Net::SFTP::Session#block operation, implemented in version 6 of
132
+ # the protocol, understands these constants for the +mask+ parameter.
133
+ module LockTypes
134
+ READ = OpenFlags::FV5::READ_LOCK
135
+ WRITE = OpenFlags::FV5::WRITE_LOCK
136
+ DELETE = OpenFlags::FV5::DELETE_LOCK
137
+ ADVISORY = OpenFlags::FV6::ADVISORY_LOCK
138
+ end
139
+
140
+ module ACE
141
+ # Access control entry types, used from version 4 of the protocol,
142
+ # onward. See Net::SFTP::Protocol::V04::Attributes::ACL.
143
+ module Type
144
+ ACCESS_ALLOWED = 0x00000000
145
+ ACCESS_DENIED = 0x00000001
146
+ SYSTEM_AUDIT = 0x00000002
147
+ SYSTEM_ALARM = 0x00000003
148
+ end
149
+
150
+ # Access control entry flags, used from version 4 of the protocol,
151
+ # onward. See Net::SFTP::Protocol::V04::Attributes::ACL.
152
+ module Flag
153
+ FILE_INHERIT = 0x00000001
154
+ DIRECTORY_INHERIT = 0x00000002
155
+ NO_PROPAGATE_INHERIT = 0x00000004
156
+ INHERIT_ONLY = 0x00000008
157
+ SUCCESSFUL_ACCESS = 0x00000010
158
+ FAILED_ACCESS = 0x00000020
159
+ IDENTIFIER_GROUP = 0x00000040
160
+ end
161
+
162
+ # Access control entry masks, used from version 4 of the protocol,
163
+ # onward. See Net::SFTP::Protocol::V04::Attributes::ACL.
164
+ module Mask
165
+ READ_DATA = 0x00000001
166
+ LIST_DIRECTORY = 0x00000001
167
+ WRITE_DATA = 0x00000002
168
+ ADD_FILE = 0x00000002
169
+ APPEND_DATA = 0x00000004
170
+ ADD_SUBDIRECTORY = 0x00000004
171
+ READ_NAMED_ATTRS = 0x00000008
172
+ WRITE_NAMED_ATTRS = 0x00000010
173
+ EXECUTE = 0x00000020
174
+ DELETE_CHILD = 0x00000040
175
+ READ_ATTRIBUTES = 0x00000080
176
+ WRITE_ATTRIBUTES = 0x00000100
177
+ DELETE = 0x00010000
178
+ READ_ACL = 0x00020000
179
+ WRITE_ACL = 0x00040000
180
+ WRITE_OWNER = 0x00080000
181
+ SYNCHRONIZE = 0x00100000
182
+ end
183
+ end
184
+
185
+ end
186
+
187
+ end end