Class: HrrRbSftp::Protocol::Version1::Packets::SSH_FXP_FSETSTAT
- Inherits:
-
Packet
- Object
- Common::Packets::Packet
- Packet
- HrrRbSftp::Protocol::Version1::Packets::SSH_FXP_FSETSTAT
- Defined in:
- lib/hrr_rb_sftp/protocol/version1/packets/010_ssh_fxp_fsetstat.rb
Overview
This class implements SFTP protocol version 1 SSH_FXP_FSETSTAT packet type, format, and responder.
Constant Summary collapse
- TYPE =
Represents SSH_FXP_FSETSTAT packet type.
10
- FORMAT =
Represents SSH_FXP_FSETSTAT packet format.
[ [DataTypes::Byte, :"type" ], [DataTypes::Uint32, :"request-id"], [DataTypes::String, :"handle" ], [DataTypes::Attrs, :"attrs" ], ]
Instance Attribute Summary
Attributes included from Loggable
Instance Method Summary collapse
-
#respond_to(request) ⇒ Hash{Symbol=>Object}
Responds to SSH_FXP_FSETSTAT request.
Methods inherited from Packet
#context, #handles, #initialize, #version
Methods inherited from Common::Packets::Packet
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn
Constructor Details
This class inherits a constructor from HrrRbSftp::Protocol::Version1::Packets::Packet
Instance Method Details
#respond_to(request) ⇒ Hash{Symbol=>Object}
Responds to SSH_FXP_FSETSTAT request.
32 33 34 35 36 37 38 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 |
# File 'lib/hrr_rb_sftp/protocol/version1/packets/010_ssh_fxp_fsetstat.rb', line 32 def respond_to request begin raise "Specified handle does not exist" unless handles.has_key?(request[:"handle"]) log_debug { "file = handles[#{request[:"handle"].inspect}]" } file = handles[request[:"handle"]] attrs = request[:"attrs"] if attrs.has_key?(:"size") log_debug { "file.truncate(#{attrs[:"size"].inspect})" } file.truncate(attrs[:"size"]) end if attrs.has_key?(:"permissions") log_debug { "file.chmod(#{attrs[:"permissions"].inspect})" } file.chmod(attrs[:"permissions"]) end if attrs.has_key?(:"atime") && attrs.has_key?(:"mtime") log_debug { "File.utime(#{attrs[:"atime"].inspect}, #{attrs[:"mtime"].inspect}, #{file.path.inspect})" } File.utime(attrs[:"atime"], attrs[:"mtime"], file.path) end if attrs.has_key?(:"uid") && attrs.has_key?(:"gid") log_debug { "file.chown(#{attrs[:"uid"].inspect}, #{attrs[:"gid"].inspect})" } file.chown(attrs[:"uid"], attrs[:"gid"]) end { :"type" => SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => SSH_FXP_STATUS::SSH_FX_OK, :"error message" => "Success", :"language tag" => "", } rescue Errno::EPERM => e log_debug { e. } { :"type" => SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => SSH_FXP_STATUS::SSH_FX_PERMISSION_DENIED, :"error message" => "Permission denied", :"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" => SSH_FXP_STATUS::TYPE, :"request-id" => request[:"request-id"], :"code" => SSH_FXP_STATUS::SSH_FX_FAILURE, :"error message" => e., :"language tag" => "", } end end |