Class: HrrRbSftp::Protocol::Version3::Extensions::LsetstatAtOpensshCom
- Inherits:
-
Extension
- Object
- Extension
- HrrRbSftp::Protocol::Version3::Extensions::LsetstatAtOpensshCom
- Defined in:
- lib/hrr_rb_sftp/protocol/version3/extensions/lsetstat_at_openssh_com.rb
Overview
This class implements [email protected] version 1 extension format and responder.
Constant Summary collapse
- EXTENSION_NAME =
Represents [email protected] version 1 extension name.
"[email protected]"
- EXTENSION_DATA =
Represents [email protected] version 1 extension data.
"1"
- REQUEST_FORMAT =
Represents SSH_FXP_EXTENDED packet additional format for [email protected] version 1 extension.
{ :"extended-request" => { "[email protected]" => [ [DataTypes::String, :"path" ], [DataTypes::Attrs, :"attrs"], ], }, }
Instance Attribute Summary
Attributes included from Loggable
Instance Method Summary collapse
-
#respond_to(request) ⇒ Hash{Symbol=>Object}
Responds to SSH_FXP_EXTENDED request with [email protected] extended-request.
Methods inherited from Extension
#context, #handles, #initialize, #version
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn
Constructor Details
This class inherits a constructor from HrrRbSftp::Protocol::Version3::Extensions::Extension
Instance Method Details
#respond_to(request) ⇒ Hash{Symbol=>Object}
Responds to SSH_FXP_EXTENDED request with [email protected] extended-request.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/hrr_rb_sftp/protocol/version3/extensions/lsetstat_at_openssh_com.rb', line 39 def respond_to request begin path = request[:"path"] attrs = request[:"attrs"] raise BadMessageError, "Invalid file attribute: size" if attrs.has_key?(:"size") if attrs.has_key?(:"atime") && attrs.has_key?(:"mtime") raise FileLutimeUnsupportedError, "File.lutime is not supported on this Ruby version" unless File.respond_to?(:lutime) log_debug { "File.lutime(#{attrs[:"atime"].inspect}, #{attrs[:"mtime"].inspect}, #{path.inspect})" } File.lutime(attrs[:"atime"], attrs[:"mtime"], path) end if attrs.has_key?(:"uid") && attrs.has_key?(:"gid") log_debug { "File.lchown(#{attrs[:"uid"].inspect}, #{attrs[:"gid"].inspect}, #{path.inspect})" } File.lchown(attrs[:"uid"], attrs[:"gid"], path) end if attrs.has_key?(:"permissions") log_debug { "File.lchmod(#{attrs[:"permissions"].inspect}, #{path.inspect})" } File.lchmod(attrs[:"permissions"], path) end { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_OK, :"error message" => "Success", :"language tag" => "", } rescue BadMessageError => e log_debug { e. } { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_BAD_MESSAGE, :"error message" => "Bad message", :"language tag" => "", } rescue FileLutimeUnsupportedError => e log_debug { e. } { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_FAILURE, :"error message" => e., :"language tag" => "", } rescue Errno::ENOENT => e log_debug { e. } { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_NO_SUCH_FILE, :"error message" => "No such file or directory", :"language tag" => "", } rescue Errno::EACCES, Errno::EPERM => e log_debug { e. } { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_PERMISSION_DENIED, :"error message" => "Permission denied", :"language tag" => "", } rescue NotImplementedError => e log_debug { e. } { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_FAILURE, :"error message" => e., :"language tag" => "", } rescue => e log_error { [e.backtrace[0], ": ", e., " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join } { :"type" => Packets::SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => Packets::SSH_FXP_STATUS::SSH_FX_FAILURE, :"error message" => e., :"language tag" => "", } end end |