Class: RubySMB::Server::Share::Provider::Processor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_smb/server/share/provider/processor.rb

Overview

A processor is unique to a particular client connection-session combination and provides the share's functionality.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider, server_client, session) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 9

def initialize(provider, server_client, session)
  @provider = provider
  @server_client = server_client
  @session = session
end

Instance Attribute Details

#providerRubySMB::Server::Share::Provider::Base



111
112
113
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 111

def provider
  @provider
end

Instance Method Details

#disconnect!Object



25
26
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 25

def disconnect!
end

#do_close_smb1(request) ⇒ Object

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 28

def do_close_smb1(request)
  raise NotImplementedError
end

#do_close_smb2(request) ⇒ Object

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 44

def do_close_smb2(request)
  raise NotImplementedError
end

#do_create_smb2(request) ⇒ Object

Raises:

  • (NotImplementedError)


48
49
50
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 48

def do_create_smb2(request)
  raise NotImplementedError
end

#do_ioctl_smb2(request) ⇒ Object



52
53
54
55
56
57
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 52

def do_ioctl_smb2(request)
  response = RubySMB::SMB2::Packet::IoctlResponse.new
  response.smb2_header.nt_status = WindowsError::NTStatus::STATUS_NOT_FOUND
  response.smb2_header.credits = 1
  response
end

#do_nt_create_andx_smb1(request) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 32

def do_nt_create_andx_smb1(request)
  raise NotImplementedError
end

#do_query_directory_smb2(request) ⇒ Object

Raises:

  • (NotImplementedError)


59
60
61
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 59

def do_query_directory_smb2(request)
  raise NotImplementedError
end

#do_query_info_smb2(request) ⇒ Object

Raises:

  • (NotImplementedError)


63
64
65
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 63

def do_query_info_smb2(request)
  raise NotImplementedError
end

#do_read_andx_smb1(request) ⇒ Object

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 36

def do_read_andx_smb1(request)
  raise NotImplementedError
end

#do_read_smb2(request) ⇒ Object

Raises:

  • (NotImplementedError)


67
68
69
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 67

def do_read_smb2(request)
  raise NotImplementedError
end

#do_transactions2_smb1(request) ⇒ Object

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 40

def do_transactions2_smb1(request)
  raise NotImplementedError
end

#loggerLogger

The logger object associated with this instance.

Returns:

  • (Logger)


75
76
77
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 75

def logger
  @server_client.logger
end

#maximal_access(path = nil) ⇒ RubySMB::SMB2::BitField::FileAccessMask

Get the maximum access that can be obtained for the specified path. If no path is specified, the maximum access for the share as a whole is returned.

Parameters:

  • path (Pathname) (defaults to: nil)

Returns:



21
22
23
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 21

def maximal_access(path=nil)
  RubySMB::SMB2::BitField::FileAccessMask.new
end

#serverObject



79
80
81
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 79

def server
  @server_client.server
end

#share_io(method_name, request) ⇒ RubySMB::GenericPacket

Forward a share IO method for a particular request. This is a choke point to allow any hooks that were registered with the share provider to be executed before and after the specified method is invoked to process the request and generate the response. This is used for both SMB1 and SMB2 requests.

Parameters:

  • method_name (Symbol)

    The method name to forward the request to

  • request (RubySMB::GenericPacket)

    The request packet to be processed

Returns:



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/ruby_smb/server/share/provider/processor.rb', line 90

def share_io(method_name, request)
  @provider.hooks.each do |hook|
    next unless hook.request_class == request.class && hook.location == :before

    request = hook.callback.call(@session, request) || request
  end

  response = send(method_name, request)

  @provider.hooks.each do |hook|
    next unless hook.request_class == request.class && hook.location == :after

    response = hook.callback.call(@session, request, response) || response
  end

  response
end