hrr_rb_sftp 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -0
  3. data/lib/hrr_rb_sftp.rb +79 -1
  4. data/lib/hrr_rb_sftp/loggable.rb +34 -0
  5. data/lib/hrr_rb_sftp/protocol.rb +39 -33
  6. data/lib/hrr_rb_sftp/protocol/common.rb +6 -3
  7. data/lib/hrr_rb_sftp/protocol/common/data_types.rb +19 -0
  8. data/lib/hrr_rb_sftp/protocol/common/data_types/byte.rb +40 -0
  9. data/lib/hrr_rb_sftp/protocol/common/data_types/extension_pair.rb +41 -0
  10. data/lib/hrr_rb_sftp/protocol/common/data_types/extension_pairs.rb +42 -0
  11. data/lib/hrr_rb_sftp/protocol/common/data_types/string.rb +42 -0
  12. data/lib/hrr_rb_sftp/protocol/common/data_types/uint32.rb +40 -0
  13. data/lib/hrr_rb_sftp/protocol/common/data_types/uint64.rb +40 -0
  14. data/lib/hrr_rb_sftp/protocol/common/packets.rb +16 -0
  15. data/lib/hrr_rb_sftp/protocol/common/packets/001_ssh_fxp_init.rb +27 -0
  16. data/lib/hrr_rb_sftp/protocol/common/packets/002_ssh_fxp_version.rb +28 -0
  17. data/lib/hrr_rb_sftp/protocol/common/packets/packet.rb +96 -0
  18. data/lib/hrr_rb_sftp/protocol/version1.rb +11 -3
  19. data/lib/hrr_rb_sftp/protocol/version1/data_types.rb +15 -0
  20. data/lib/hrr_rb_sftp/protocol/version1/data_types/attrs.rb +91 -0
  21. data/lib/hrr_rb_sftp/protocol/version1/packets.rb +72 -0
  22. data/lib/hrr_rb_sftp/protocol/version1/{packet → packets}/003_ssh_fxp_open.rb +94 -43
  23. data/lib/hrr_rb_sftp/protocol/version1/packets/004_ssh_fxp_close.rb +61 -0
  24. data/lib/hrr_rb_sftp/protocol/version1/packets/005_ssh_fxp_read.rb +72 -0
  25. data/lib/hrr_rb_sftp/protocol/version1/packets/006_ssh_fxp_write.rb +64 -0
  26. data/lib/hrr_rb_sftp/protocol/version1/{packet → packets}/007_ssh_fxp_lstat.rb +27 -9
  27. data/lib/hrr_rb_sftp/protocol/version1/{packet → packets}/008_ssh_fxp_fstat.rb +26 -9
  28. data/lib/hrr_rb_sftp/protocol/version1/packets/009_ssh_fxp_setstat.rb +92 -0
  29. data/lib/hrr_rb_sftp/protocol/version1/packets/010_ssh_fxp_fsetstat.rb +85 -0
  30. data/lib/hrr_rb_sftp/protocol/version1/{packet → packets}/011_ssh_fxp_opendir.rb +32 -11
  31. data/lib/hrr_rb_sftp/protocol/version1/{packet → packets}/012_ssh_fxp_readdir.rb +73 -49
  32. data/lib/hrr_rb_sftp/protocol/version1/{packet → packets}/013_ssh_fxp_remove.rb +27 -9
  33. data/lib/hrr_rb_sftp/protocol/version1/{packet → packets}/014_ssh_fxp_mkdir.rb +28 -10
  34. data/lib/hrr_rb_sftp/protocol/version1/{packet → packets}/015_ssh_fxp_rmdir.rb +32 -12
  35. data/lib/hrr_rb_sftp/protocol/version1/packets/016_ssh_fxp_realpath.rb +47 -0
  36. data/lib/hrr_rb_sftp/protocol/version1/{packet → packets}/017_ssh_fxp_stat.rb +27 -9
  37. data/lib/hrr_rb_sftp/protocol/version1/packets/101_ssh_fxp_status.rb +73 -0
  38. data/lib/hrr_rb_sftp/protocol/version1/packets/102_ssh_fxp_handle.rb +28 -0
  39. data/lib/hrr_rb_sftp/protocol/version1/packets/103_ssh_fxp_data.rb +28 -0
  40. data/lib/hrr_rb_sftp/protocol/version1/packets/104_ssh_fxp_name.rb +48 -0
  41. data/lib/hrr_rb_sftp/protocol/version1/packets/105_ssh_fxp_attrs.rb +28 -0
  42. data/lib/hrr_rb_sftp/protocol/version1/packets/packet.rb +57 -0
  43. data/lib/hrr_rb_sftp/protocol/version2.rb +11 -3
  44. data/lib/hrr_rb_sftp/protocol/version2/data_types.rb +13 -0
  45. data/lib/hrr_rb_sftp/protocol/version2/packets.rb +14 -0
  46. data/lib/hrr_rb_sftp/protocol/version2/packets/018_ssh_fxp_rename.rb +91 -0
  47. data/lib/hrr_rb_sftp/protocol/version3.rb +12 -3
  48. data/lib/hrr_rb_sftp/protocol/version3/data_types.rb +13 -0
  49. data/lib/hrr_rb_sftp/protocol/version3/extensions.rb +94 -0
  50. data/lib/hrr_rb_sftp/protocol/version3/extensions/extension.rb +58 -0
  51. data/lib/hrr_rb_sftp/protocol/version3/extensions/fsync_at_openssh_com.rb +59 -0
  52. data/lib/hrr_rb_sftp/protocol/version3/extensions/hardlink_at_openssh_com.rb +84 -0
  53. data/lib/hrr_rb_sftp/protocol/version3/extensions/lsetstat_at_openssh_com.rb +132 -0
  54. data/lib/hrr_rb_sftp/protocol/version3/extensions/posix_rename_at_openssh_com.rb +76 -0
  55. data/lib/hrr_rb_sftp/protocol/version3/packets.rb +19 -0
  56. data/lib/hrr_rb_sftp/protocol/version3/packets/014_ssh_fxp_mkdir.rb +75 -0
  57. data/lib/hrr_rb_sftp/protocol/version3/packets/019_ssh_fxp_readlink.rb +76 -0
  58. data/lib/hrr_rb_sftp/protocol/version3/packets/020_ssh_fxp_symlink.rb +76 -0
  59. data/lib/hrr_rb_sftp/protocol/version3/packets/101_ssh_fxp_status.rb +25 -0
  60. data/lib/hrr_rb_sftp/protocol/version3/packets/200_ssh_fxp_extended.rb +95 -0
  61. data/lib/hrr_rb_sftp/protocol/version3/packets/201_ssh_fxp_extended_reply.rb +60 -0
  62. data/lib/hrr_rb_sftp/receiver.rb +17 -2
  63. data/lib/hrr_rb_sftp/sender.rb +15 -1
  64. data/lib/hrr_rb_sftp/server.rb +43 -12
  65. data/lib/hrr_rb_sftp/version.rb +5 -1
  66. metadata +54 -47
  67. data/lib/hrr_rb_sftp/protocol/common/data_type.rb +0 -15
  68. data/lib/hrr_rb_sftp/protocol/common/data_type/byte.rb +0 -22
  69. data/lib/hrr_rb_sftp/protocol/common/data_type/extension_pair.rb +0 -23
  70. data/lib/hrr_rb_sftp/protocol/common/data_type/extension_pairs.rb +0 -24
  71. data/lib/hrr_rb_sftp/protocol/common/data_type/string.rb +0 -24
  72. data/lib/hrr_rb_sftp/protocol/common/data_type/uint32.rb +0 -22
  73. data/lib/hrr_rb_sftp/protocol/common/data_type/uint64.rb +0 -22
  74. data/lib/hrr_rb_sftp/protocol/common/packet.rb +0 -11
  75. data/lib/hrr_rb_sftp/protocol/common/packet/001_ssh_fxp_init.rb +0 -18
  76. data/lib/hrr_rb_sftp/protocol/common/packet/002_ssh_fxp_version.rb +0 -19
  77. data/lib/hrr_rb_sftp/protocol/common/packetable.rb +0 -72
  78. data/lib/hrr_rb_sftp/protocol/version1/data_type.rb +0 -11
  79. data/lib/hrr_rb_sftp/protocol/version1/data_type/attrs.rb +0 -54
  80. data/lib/hrr_rb_sftp/protocol/version1/packet.rb +0 -29
  81. data/lib/hrr_rb_sftp/protocol/version1/packet/004_ssh_fxp_close.rb +0 -44
  82. data/lib/hrr_rb_sftp/protocol/version1/packet/005_ssh_fxp_read.rb +0 -53
  83. data/lib/hrr_rb_sftp/protocol/version1/packet/006_ssh_fxp_write.rb +0 -46
  84. data/lib/hrr_rb_sftp/protocol/version1/packet/009_ssh_fxp_setstat.rb +0 -63
  85. data/lib/hrr_rb_sftp/protocol/version1/packet/010_ssh_fxp_fsetstat.rb +0 -48
  86. data/lib/hrr_rb_sftp/protocol/version1/packet/016_ssh_fxp_realpath.rb +0 -30
  87. data/lib/hrr_rb_sftp/protocol/version1/packet/101_ssh_fxp_status.rb +0 -29
  88. data/lib/hrr_rb_sftp/protocol/version1/packet/102_ssh_fxp_handle.rb +0 -19
  89. data/lib/hrr_rb_sftp/protocol/version1/packet/103_ssh_fxp_data.rb +0 -19
  90. data/lib/hrr_rb_sftp/protocol/version1/packet/104_ssh_fxp_name.rb +0 -33
  91. data/lib/hrr_rb_sftp/protocol/version1/packet/105_ssh_fxp_attrs.rb +0 -19
  92. data/lib/hrr_rb_sftp/protocol/version2/data_type.rb +0 -9
  93. data/lib/hrr_rb_sftp/protocol/version2/packet.rb +0 -11
  94. data/lib/hrr_rb_sftp/protocol/version2/packet/018_ssh_fxp_rename.rb +0 -70
  95. data/lib/hrr_rb_sftp/protocol/version3/data_type.rb +0 -9
  96. data/lib/hrr_rb_sftp/protocol/version3/packet.rb +0 -16
  97. data/lib/hrr_rb_sftp/protocol/version3/packet/014_ssh_fxp_mkdir.rb +0 -58
  98. data/lib/hrr_rb_sftp/protocol/version3/packet/019_ssh_fxp_readlink.rb +0 -57
  99. data/lib/hrr_rb_sftp/protocol/version3/packet/020_ssh_fxp_symlink.rb +0 -58
  100. data/lib/hrr_rb_sftp/protocol/version3/packet/101_ssh_fxp_status.rb +0 -31
  101. data/lib/hrr_rb_sftp/protocol/version3/packet/200_ssh_fxp_extended.rb +0 -34
  102. data/lib/hrr_rb_sftp/protocol/version3/packet/201_ssh_fxp_extended_reply.rb +0 -23
@@ -1,46 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version1
4
- module Packet
5
- class SSH_FXP_WRITE
6
- include Common::Packetable
7
-
8
- TYPE = 6
9
-
10
- FORMAT = [
11
- [DataType::Byte, :"type" ],
12
- [DataType::Uint32, :"request-id"],
13
- [DataType::String, :"handle" ],
14
- [DataType::Uint64, :"offset" ],
15
- [DataType::String, :"data" ],
16
- ]
17
-
18
- def respond_to request
19
- begin
20
- raise "Specified handle does not exist" unless @handles.has_key?(request[:"handle"])
21
- file = @handles[request[:"handle"]]
22
- file.pos = request[:"offset"]
23
- file.write request[:"data"]
24
- {
25
- :"type" => SSH_FXP_STATUS::TYPE,
26
- :"request-id" => request[:"request-id"],
27
- :"code" => SSH_FXP_STATUS::SSH_FX_OK,
28
- :"error message" => "Success",
29
- :"language tag" => "",
30
- }
31
- rescue => e
32
- log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
33
- {
34
- :"type" => SSH_FXP_STATUS::TYPE,
35
- :"request-id" => request[:"request-id"],
36
- :"code" => SSH_FXP_STATUS::SSH_FX_FAILURE,
37
- :"error message" => e.message,
38
- :"language tag" => "",
39
- }
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,63 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version1
4
- module Packet
5
- class SSH_FXP_SETSTAT
6
- include Common::Packetable
7
-
8
- TYPE = 9
9
-
10
- FORMAT = [
11
- [DataType::Byte, :"type" ],
12
- [DataType::Uint32, :"request-id"],
13
- [DataType::String, :"path" ],
14
- [DataType::Attrs, :"attrs" ],
15
- ]
16
-
17
- def respond_to request
18
- begin
19
- path = request[:"path"]
20
- attrs = request[:"attrs"]
21
- FileUtils.chmod(attrs[:"permissions"], path) if attrs.has_key?(:"permissions")
22
- File.utime(attrs[:"atime"], attrs[:"mtime"], path) if attrs.has_key?(:"atime") && attrs.has_key?(:"mtime")
23
- FileUtils.chown(attrs[:"uid"], attrs[:"gid"], path) if attrs.has_key?(:"uid") && attrs.has_key?(:"gid")
24
- File.truncate(path, attrs[:"size"]) if attrs.has_key?(:"size")
25
- {
26
- :"type" => SSH_FXP_STATUS::TYPE,
27
- :"request-id" => request[:"request-id"],
28
- :"code" => SSH_FXP_STATUS::SSH_FX_OK,
29
- :"error message" => "Success",
30
- :"language tag" => "",
31
- }
32
- rescue Errno::ENOENT
33
- {
34
- :"type" => SSH_FXP_STATUS::TYPE,
35
- :"request-id" => request[:"request-id"],
36
- :"code" => SSH_FXP_STATUS::SSH_FX_NO_SUCH_FILE,
37
- :"error message" => "No such file or directory",
38
- :"language tag" => "",
39
- }
40
- rescue Errno::EACCES
41
- {
42
- :"type" => SSH_FXP_STATUS::TYPE,
43
- :"request-id" => request[:"request-id"],
44
- :"code" => SSH_FXP_STATUS::SSH_FX_PERMISSION_DENIED,
45
- :"error message" => "Permission denied",
46
- :"language tag" => "",
47
- }
48
- rescue => e
49
- log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
50
- {
51
- :"type" => SSH_FXP_STATUS::TYPE,
52
- :"request-id" => request[:"request-id"],
53
- :"code" => SSH_FXP_STATUS::SSH_FX_FAILURE,
54
- :"error message" => e.message,
55
- :"language tag" => "",
56
- }
57
- end
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,48 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version1
4
- module Packet
5
- class SSH_FXP_FSETSTAT
6
- include Common::Packetable
7
-
8
- TYPE = 10
9
-
10
- FORMAT = [
11
- [DataType::Byte, :"type" ],
12
- [DataType::Uint32, :"request-id"],
13
- [DataType::String, :"handle" ],
14
- [DataType::Attrs, :"attrs" ],
15
- ]
16
-
17
- def respond_to request
18
- begin
19
- raise "Specified handle does not exist" unless @handles.has_key?(request[:"handle"])
20
- file = @handles[request[:"handle"]]
21
- attrs = request[:"attrs"]
22
- file.chmod(attrs[:"permissions"]) if attrs.has_key?(:"permissions")
23
- File.utime(attrs[:"atime"], attrs[:"mtime"], file.path) if attrs.has_key?(:"atime") && attrs.has_key?(:"mtime")
24
- file.chown(attrs[:"uid"], attrs[:"gid"]) if attrs.has_key?(:"uid") && attrs.has_key?(:"gid")
25
- file.truncate(attrs[:"size"]) if attrs.has_key?(:"size")
26
- {
27
- :"type" => SSH_FXP_STATUS::TYPE,
28
- :"request-id" => request[:"request-id"],
29
- :"code" => SSH_FXP_STATUS::SSH_FX_OK,
30
- :"error message" => "Success",
31
- :"language tag" => "",
32
- }
33
- rescue => e
34
- log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
35
- {
36
- :"type" => SSH_FXP_STATUS::TYPE,
37
- :"request-id" => request[:"request-id"],
38
- :"code" => SSH_FXP_STATUS::SSH_FX_FAILURE,
39
- :"error message" => e.message,
40
- :"language tag" => "",
41
- }
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,30 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version1
4
- module Packet
5
- class SSH_FXP_REALPATH
6
- include Common::Packetable
7
-
8
- TYPE = 16
9
-
10
- FORMAT = [
11
- [DataType::Byte, :"type" ],
12
- [DataType::Uint32, :"request-id"],
13
- [DataType::String, :"path" ],
14
- ]
15
-
16
- def respond_to request
17
- {
18
- :"type" => SSH_FXP_NAME::TYPE,
19
- :"request-id" => request[:"request-id"],
20
- :"count" => 1,
21
- :"filename[0]" => File.absolute_path(request[:"path"]),
22
- :"longname[0]" => File.absolute_path(request[:"path"]),
23
- :"attrs[0]" => {},
24
- }
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,29 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version1
4
- module Packet
5
- class SSH_FXP_STATUS
6
- include Common::Packetable
7
-
8
- TYPE = 101
9
-
10
- FORMAT = [
11
- [DataType::Byte, :"type" ],
12
- [DataType::Uint32, :"request-id"],
13
- [DataType::Uint32, :"code" ],
14
- ]
15
-
16
- SSH_FX_OK = 0
17
- SSH_FX_EOF = 1
18
- SSH_FX_NO_SUCH_FILE = 2
19
- SSH_FX_PERMISSION_DENIED = 3
20
- SSH_FX_FAILURE = 4
21
- SSH_FX_BAD_MESSAGE = 5
22
- SSH_FX_NO_CONNECTION = 6
23
- SSH_FX_CONNECTION_LOST = 7
24
- SSH_FX_OP_UNSUPPORTED = 8
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,19 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version1
4
- module Packet
5
- class SSH_FXP_HANDLE
6
- include Common::Packetable
7
-
8
- TYPE = 102
9
-
10
- FORMAT = [
11
- [DataType::Byte, :"type" ],
12
- [DataType::Uint32, :"request-id"],
13
- [DataType::String, :"handle" ],
14
- ]
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,19 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version1
4
- module Packet
5
- class SSH_FXP_DATA
6
- include Common::Packetable
7
-
8
- TYPE = 103
9
-
10
- FORMAT = [
11
- [DataType::Byte, :"type" ],
12
- [DataType::Uint32, :"request-id"],
13
- [DataType::String, :"data" ],
14
- ]
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,33 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version1
4
- module Packet
5
- class SSH_FXP_NAME
6
- include Common::Packetable
7
-
8
- TYPE = 104
9
-
10
- FORMAT = [
11
- [DataType::Byte, :"type" ],
12
- [DataType::Uint32, :"request-id"],
13
- [DataType::Uint32, :"count" ],
14
- ]
15
-
16
- PER_COUNT_FORMAT = Hash.new{ |hash, key|
17
- Array.new(key){ |i|
18
- [
19
- [DataType::String, :"filename[#{i}]"],
20
- [DataType::String, :"longname[#{i}]"],
21
- [DataType::Attrs, :"attrs[#{i}]" ],
22
- ]
23
- }.inject(:+)
24
- }
25
-
26
- CONDITIONAL_FORMAT = {
27
- :"count" => PER_COUNT_FORMAT,
28
- }
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,19 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version1
4
- module Packet
5
- class SSH_FXP_ATTRS
6
- include Common::Packetable
7
-
8
- TYPE = 105
9
-
10
- FORMAT = [
11
- [DataType::Byte, :"type" ],
12
- [DataType::Uint32, :"request-id"],
13
- [DataType::Attrs, :"attrs" ],
14
- ]
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version2
4
- module DataType
5
- include Version1::DataType
6
- end
7
- end
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version2
4
- module Packet
5
- include Version1::Packet
6
- end
7
- end
8
- end
9
- end
10
-
11
- require "hrr_rb_sftp/protocol/version2/packet/018_ssh_fxp_rename"
@@ -1,70 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version2
4
- module Packet
5
- class SSH_FXP_RENAME
6
- include Common::Packetable
7
-
8
- TYPE = 18
9
-
10
- FORMAT = [
11
- [DataType::Byte, :"type" ],
12
- [DataType::Uint32, :"request-id"],
13
- [DataType::String, :"oldpath" ],
14
- [DataType::String, :"newpath" ],
15
- ]
16
-
17
- def respond_to request
18
- oldpath = request[:"oldpath"]
19
- newpath = request[:"newpath"]
20
- if File.exist?(newpath)
21
- {
22
- :"type" => Packet::SSH_FXP_STATUS::TYPE,
23
- :"request-id" => request[:"request-id"],
24
- :"code" => Packet::SSH_FXP_STATUS::SSH_FX_FAILURE,
25
- :"error message" => "File exists",
26
- :"language tag" => "",
27
- }
28
- else
29
- begin
30
- File.rename(oldpath, newpath)
31
- {
32
- :"type" => Packet::SSH_FXP_STATUS::TYPE,
33
- :"request-id" => request[:"request-id"],
34
- :"code" => Packet::SSH_FXP_STATUS::SSH_FX_OK,
35
- :"error message" => "Success",
36
- :"language tag" => "",
37
- }
38
- rescue Errno::ENOENT
39
- {
40
- :"type" => Packet::SSH_FXP_STATUS::TYPE,
41
- :"request-id" => request[:"request-id"],
42
- :"code" => Packet::SSH_FXP_STATUS::SSH_FX_NO_SUCH_FILE,
43
- :"error message" => "No such file or directory",
44
- :"language tag" => "",
45
- }
46
- rescue Errno::EACCES
47
- {
48
- :"type" => Packet::SSH_FXP_STATUS::TYPE,
49
- :"request-id" => request[:"request-id"],
50
- :"code" => Packet::SSH_FXP_STATUS::SSH_FX_PERMISSION_DENIED,
51
- :"error message" => "Permission denied",
52
- :"language tag" => "",
53
- }
54
- rescue => e
55
- log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
56
- {
57
- :"type" => Packet::SSH_FXP_STATUS::TYPE,
58
- :"request-id" => request[:"request-id"],
59
- :"code" => Packet::SSH_FXP_STATUS::SSH_FX_FAILURE,
60
- :"error message" => e.message,
61
- :"language tag" => "",
62
- }
63
- end
64
- end
65
- end
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,9 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version3
4
- module DataType
5
- include Version2::DataType
6
- end
7
- end
8
- end
9
- end
@@ -1,16 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version3
4
- module Packet
5
- include Version2::Packet
6
- end
7
- end
8
- end
9
- end
10
-
11
- require "hrr_rb_sftp/protocol/version3/packet/014_ssh_fxp_mkdir"
12
- require "hrr_rb_sftp/protocol/version3/packet/019_ssh_fxp_readlink"
13
- require "hrr_rb_sftp/protocol/version3/packet/020_ssh_fxp_symlink"
14
- require "hrr_rb_sftp/protocol/version3/packet/101_ssh_fxp_status"
15
- require "hrr_rb_sftp/protocol/version3/packet/200_ssh_fxp_extended"
16
- require "hrr_rb_sftp/protocol/version3/packet/201_ssh_fxp_extended_reply"
@@ -1,58 +0,0 @@
1
- module HrrRbSftp
2
- class Protocol
3
- class Version3
4
- module Packet
5
- class SSH_FXP_MKDIR
6
- include Common::Packetable
7
-
8
- TYPE = 14
9
-
10
- FORMAT = [
11
- [DataType::Byte, :"type" ],
12
- [DataType::Uint32, :"request-id"],
13
- [DataType::String, :"path" ],
14
- [DataType::Attrs, :"attrs" ],
15
- ]
16
-
17
- def respond_to request
18
- begin
19
- Dir.mkdir request[:"path"]
20
- {
21
- :"type" => Packet::SSH_FXP_STATUS::TYPE,
22
- :"request-id" => request[:"request-id"],
23
- :"code" => Packet::SSH_FXP_STATUS::SSH_FX_OK,
24
- :"error message" => "Success",
25
- :"language tag" => "",
26
- }
27
- rescue Errno::EACCES
28
- {
29
- :"type" => Packet::SSH_FXP_STATUS::TYPE,
30
- :"request-id" => request[:"request-id"],
31
- :"code" => Packet::SSH_FXP_STATUS::SSH_FX_PERMISSION_DENIED,
32
- :"error message" => "Permission denied",
33
- :"language tag" => "",
34
- }
35
- rescue Errno::EEXIST
36
- {
37
- :"type" => Packet::SSH_FXP_STATUS::TYPE,
38
- :"request-id" => request[:"request-id"],
39
- :"code" => Packet::SSH_FXP_STATUS::SSH_FX_FAILURE,
40
- :"error message" => "File exists",
41
- :"language tag" => "",
42
- }
43
- rescue => e
44
- log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
45
- {
46
- :"type" => Packet::SSH_FXP_STATUS::TYPE,
47
- :"request-id" => request[:"request-id"],
48
- :"code" => Packet::SSH_FXP_STATUS::SSH_FX_FAILURE,
49
- :"error message" => e.message,
50
- :"language tag" => "",
51
- }
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
58
- end