| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# SMB Perl library, Copyright (C) 2014-2018 Mikhael Goikhman, migo@cpan.org |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify |
|
4
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
|
5
|
|
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
|
6
|
|
|
|
|
|
|
# (at your option) any later version. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
9
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11
|
|
|
|
|
|
|
# GNU General Public License for more details. |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
14
|
|
|
|
|
|
|
# along with this program. If not, see . |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package SMB::v2::Command::TreeConnect; |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
21
|
|
|
19
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
18
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
4
|
use parent 'SMB::v2::Command'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
3
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub init ($) { |
|
24
|
0
|
|
|
0
|
0
|
|
$_[0]->set( |
|
25
|
|
|
|
|
|
|
share_type => 1, |
|
26
|
|
|
|
|
|
|
share_flags => 0x800, |
|
27
|
|
|
|
|
|
|
capabilities => 0, |
|
28
|
|
|
|
|
|
|
access_mask => 0x1f01ff, |
|
29
|
|
|
|
|
|
|
uri => undef, |
|
30
|
|
|
|
|
|
|
tree => undef, |
|
31
|
|
|
|
|
|
|
) |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub verify_uri ($) { |
|
35
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
die "Tree connect $self misses share uri\n" |
|
38
|
|
|
|
|
|
|
unless $self->parse_share_uri($self->uri); |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return $self->uri; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub parse ($$) { |
|
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
45
|
0
|
|
|
|
|
|
my $parser = shift; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
if ($self->is_response) { |
|
48
|
0
|
|
|
|
|
|
$self->share_type($parser->uint8); |
|
49
|
0
|
|
|
|
|
|
$parser->uint8; # reserved |
|
50
|
0
|
|
|
|
|
|
$self->share_flags($parser->uint32); |
|
51
|
0
|
|
|
|
|
|
$self->capabilities($parser->uint32); |
|
52
|
0
|
|
|
|
|
|
$self->access_mask($parser->uint32); |
|
53
|
|
|
|
|
|
|
} else { |
|
54
|
0
|
|
|
|
|
|
$parser->uint16; # reserved |
|
55
|
0
|
|
|
|
|
|
$parser->uint16; |
|
56
|
0
|
|
|
|
|
|
my $uri_len = $parser->uint16; |
|
57
|
0
|
|
|
|
|
|
$self->uri($parser->utf16($uri_len)); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return $self; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub pack ($$) { |
|
64
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
65
|
0
|
|
|
|
|
|
my $packer = shift; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if ($self->is_response) { |
|
68
|
0
|
|
0
|
|
|
|
my $is_ipc = $self->tree && $self->tree->is_ipc; |
|
69
|
0
|
0
|
|
|
|
|
$packer |
|
|
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
->uint8($is_ipc ? 2 : $self->share_type) |
|
71
|
|
|
|
|
|
|
->uint8(0) # reserved |
|
72
|
|
|
|
|
|
|
->uint32($is_ipc ? 0x30 : $self->share_flags) |
|
73
|
|
|
|
|
|
|
->uint32($self->capabilities) |
|
74
|
|
|
|
|
|
|
->uint32($self->access_mask) |
|
75
|
|
|
|
|
|
|
; |
|
76
|
|
|
|
|
|
|
} else { |
|
77
|
0
|
|
|
|
|
|
$packer |
|
78
|
|
|
|
|
|
|
->uint16(0) # reserved |
|
79
|
|
|
|
|
|
|
->uint16($packer->diff('smb-header') + 4) |
|
80
|
|
|
|
|
|
|
->stub('uri-len', 'uint16') |
|
81
|
|
|
|
|
|
|
->mark('uri') |
|
82
|
|
|
|
|
|
|
->utf16($self->verify_uri) |
|
83
|
|
|
|
|
|
|
->fill('uri-len', $packer->diff('uri')) |
|
84
|
|
|
|
|
|
|
; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |