|
| 1 | +module RubySMB |
| 2 | + module SMB1 |
| 3 | + module Packet |
| 4 | + module Trans2 |
| 5 | + # The Trans2 Parameter Block for TRANS2_SET_FS_INFORMATION. |
| 6 | + # Observed on the wire (and required by Samba) as a 4-byte block |
| 7 | + # containing a placeholder file handle plus the information level. |
| 8 | + # |
| 9 | + # The parent subcommand |
| 10 | + # [MS-CIFS 2.2.6.5 TRANS2_SET_FS_INFORMATION (0x0004)](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/ac4b00db-6015-416a-89a1-bf5da2503bc3) |
| 11 | + # is marked "reserved but not implemented"; the on-the-wire format |
| 12 | + # used here is defined by the CIFS UNIX Extensions draft and |
| 13 | + # implemented in |
| 14 | + # [source3/smbd/smb1_trans2.c:1706-1915 (`call_trans2setfsinfo`)](https://github.com/samba-team/samba/blob/33f516c06756e12a9d11f50e2bf309171cdf5c88/source3/smbd/smb1_trans2.c#L1706-L1915). |
| 15 | + class SetFsInformationRequestTrans2Parameters < BinData::Record |
| 16 | + endian :little |
| 17 | + |
| 18 | + uint16 :fid, label: 'File ID' |
| 19 | + uint16 :information_level, label: 'Information Level' |
| 20 | + |
| 21 | + # Returns the length of the Trans2Parameters struct |
| 22 | + # in number of bytes |
| 23 | + def length |
| 24 | + do_num_bytes |
| 25 | + end |
| 26 | + end |
| 27 | + |
| 28 | + # The Trans2 Data Block for TRANS2_SET_FS_INFORMATION. |
| 29 | + # |
| 30 | + # The data layout depends on the Information Level being set, so the |
| 31 | + # block carries an opaque byte buffer that the caller fills in for |
| 32 | + # the target info level. SMB_SET_CIFS_UNIX_INFO (0x0200) for example |
| 33 | + # carries a QueryFsCifsUnixInfo-shaped record (major/minor/caps). |
| 34 | + # |
| 35 | + # Not documented in |
| 36 | + # [MS-CIFS 2.2.6.5 TRANS2_SET_FS_INFORMATION (0x0004)](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/ac4b00db-6015-416a-89a1-bf5da2503bc3); |
| 37 | + # per-level layouts are defined by the CIFS UNIX Extensions draft |
| 38 | + # and implemented in |
| 39 | + # [source3/smbd/smb1_trans2.c:1706-1915 (`call_trans2setfsinfo`)](https://github.com/samba-team/samba/blob/33f516c06756e12a9d11f50e2bf309171cdf5c88/source3/smbd/smb1_trans2.c#L1706-L1915). |
| 40 | + class SetFsInformationRequestTrans2Data < BinData::Record |
| 41 | + string :buffer, read_length: -> { parent.buffer_read_length } |
| 42 | + |
| 43 | + # Returns the length of the Trans2Data struct |
| 44 | + # in number of bytes |
| 45 | + def length |
| 46 | + do_num_bytes |
| 47 | + end |
| 48 | + end |
| 49 | + |
| 50 | + # The {RubySMB::SMB1::DataBlock} specific to this packet type. The |
| 51 | + # parent subcommand |
| 52 | + # [MS-CIFS 2.2.6.5 TRANS2_SET_FS_INFORMATION (0x0004)](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/ac4b00db-6015-416a-89a1-bf5da2503bc3) |
| 53 | + # is documented as "reserved but not implemented"; this data block |
| 54 | + # is structured for the CIFS UNIX Extensions use in |
| 55 | + # [source3/smbd/smb1_trans2.c:1706-1915 (`call_trans2setfsinfo`)](https://github.com/samba-team/samba/blob/33f516c06756e12a9d11f50e2bf309171cdf5c88/source3/smbd/smb1_trans2.c#L1706-L1915). |
| 56 | + class SetFsInformationRequestDataBlock < RubySMB::SMB1::Packet::Trans2::DataBlock |
| 57 | + uint8 :name, label: 'Name', initial_value: 0x00 |
| 58 | + string :pad1, length: -> { pad1_length } |
| 59 | + set_fs_information_request_trans2_parameters :trans2_parameters, label: 'Trans2 Parameters' |
| 60 | + string :pad2, length: -> { pad2_length } |
| 61 | + set_fs_information_request_trans2_data :trans2_data, label: 'Trans2 Data' |
| 62 | + end |
| 63 | + |
| 64 | + # A Trans2 SET_FS_INFORMATION Request Packet. The on-disk layout |
| 65 | + # described by |
| 66 | + # [MS-CIFS 2.2.6.5 TRANS2_SET_FS_INFORMATION (0x0004)](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/ac4b00db-6015-416a-89a1-bf5da2503bc3) |
| 67 | + # is marked "reserved but not implemented" and does not document the |
| 68 | + # CIFS UNIX Extensions info levels; their wire format is defined by |
| 69 | + # the CIFS UNIX Extensions draft and matched by Samba's |
| 70 | + # `call_trans2setfsinfo` in |
| 71 | + # [source3/smbd/smb1_trans2.c:1706-1915 (`call_trans2setfsinfo`)](https://github.com/samba-team/samba/blob/33f516c06756e12a9d11f50e2bf309171cdf5c88/source3/smbd/smb1_trans2.c#L1706-L1915). |
| 72 | + class SetFsInformationRequest < RubySMB::GenericPacket |
| 73 | + COMMAND = RubySMB::SMB1::Commands::SMB_COM_TRANSACTION2 |
| 74 | + |
| 75 | + class ParameterBlock < RubySMB::SMB1::Packet::Trans2::Request::ParameterBlock |
| 76 | + end |
| 77 | + |
| 78 | + smb_header :smb_header |
| 79 | + parameter_block :parameter_block |
| 80 | + set_fs_information_request_data_block :data_block |
| 81 | + |
| 82 | + def initialize_instance |
| 83 | + super |
| 84 | + parameter_block.setup << RubySMB::SMB1::Packet::Trans2::Subcommands::SET_FS_INFORMATION |
| 85 | + end |
| 86 | + end |
| 87 | + end |
| 88 | + end |
| 89 | + end |
| 90 | +end |
0 commit comments