line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MToken; # $Id: MToken.pm 76 2019-07-20 07:48:18Z minus $ |
2
|
1
|
|
|
1
|
|
64969
|
use strict; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
28
|
|
3
|
1
|
|
|
1
|
|
574
|
use utf8; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=encoding utf-8 |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MToken - Tokens processing system (Security) |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 1.03 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
mtoken init MyToken |
18
|
|
|
|
|
|
|
perl Makefile.PL |
19
|
|
|
|
|
|
|
make init |
20
|
|
|
|
|
|
|
make help |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Tokens processing system (Security) |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over 4 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item STEP1 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Create a token device |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
cd /my/token/dir |
33
|
|
|
|
|
|
|
mtoken init MyToken |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item STEP2 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Initialize the MyToken device |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
perl Makefile.PL |
40
|
|
|
|
|
|
|
make init |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Get help page |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
make help |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Test the device |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
make test |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item STEP3 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Generate GPG key pair |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
make gengpgkey |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item STEP4 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Add file to device |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
make add |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Update file on device |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
make update |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Delete file from device |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
make delete |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Show file list on device |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
make show |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item STEP5 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Backup current token device to server |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
make backup |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Show list of all available backups on server |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
make list |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Show information about last backup stored on server |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
make info |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item STEP6 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Restore token device from server backup |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
make restore |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item STEP7 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Cleaning the device (delete all temporary files) |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
make clean |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 HISTORY |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
See C file |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L, L, C, C |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 TO DO |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
See C file |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 BUGS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
* none noted |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SEE ALSO |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
L |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Serż Minus (Sergey Lepenkov) L Eabalama@cpan.orgE |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 LICENSE |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
133
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
See C file and L |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
1
|
|
|
1
|
|
62
|
use vars qw/ $VERSION /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
140
|
|
|
|
|
|
|
$VERSION = "1.03"; |
141
|
|
|
|
|
|
|
|
142
|
1
|
|
|
1
|
|
6
|
use feature qw/say/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
136
|
|
143
|
1
|
|
|
1
|
|
8
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
144
|
1
|
|
|
1
|
|
6
|
use Cwd qw/getcwd/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
145
|
1
|
|
|
1
|
|
457
|
use CTK::Skel; |
|
1
|
|
|
|
|
193143
|
|
|
1
|
|
|
|
|
37
|
|
146
|
1
|
|
|
1
|
|
428
|
use MToken::Const; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
87
|
|
147
|
1
|
|
|
1
|
|
396
|
use MToken::Util qw/explain red yellow /; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
80
|
|
148
|
1
|
|
|
1
|
|
480
|
use MToken::Config; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
149
|
|
|
|
|
|
|
|
150
|
1
|
|
|
1
|
|
8
|
use base qw/ CTK::App /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
519
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
__PACKAGE__->register_handler( |
153
|
|
|
|
|
|
|
handler => "test", |
154
|
|
|
|
|
|
|
description => "MToken testing (internal use only)", |
155
|
|
|
|
|
|
|
code => sub { |
156
|
|
|
|
|
|
|
### CODE: |
157
|
|
|
|
|
|
|
my ($self, $meta, @arguments) = @_; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
if ($self->verbosemode) { |
160
|
|
|
|
|
|
|
say("CLI arguments: ", join("; ",@arguments) || yellow('none') ); |
161
|
|
|
|
|
|
|
say("Meta: ", explain($meta)); |
162
|
|
|
|
|
|
|
say("CTK object: ", explain($self)); |
163
|
|
|
|
|
|
|
say("App handlers: ", join(", ", $self->list_handlers)); |
164
|
|
|
|
|
|
|
} else { |
165
|
|
|
|
|
|
|
say STDERR red("Incorrect arguments!"); |
166
|
|
|
|
|
|
|
say STDERR "Usage:"; |
167
|
|
|
|
|
|
|
say STDERR " mtoken test -v -- for show app information"; |
168
|
|
|
|
|
|
|
return 0; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
return 1; |
172
|
|
|
|
|
|
|
}); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
__PACKAGE__->register_handler( |
175
|
|
|
|
|
|
|
handler => "init", |
176
|
|
|
|
|
|
|
description => "Initialize token device", |
177
|
|
|
|
|
|
|
code => sub { |
178
|
|
|
|
|
|
|
### CODE: |
179
|
|
|
|
|
|
|
my ($self, $meta, @arguments) = @_; |
180
|
|
|
|
|
|
|
my $prj = shift(@arguments); |
181
|
|
|
|
|
|
|
my $dir = $self->option("directory") || getcwd(); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# Project name |
184
|
|
|
|
|
|
|
$prj //= $self->project; |
185
|
|
|
|
|
|
|
$prj = lc($prj); |
186
|
|
|
|
|
|
|
$prj =~ s/\s+//g; |
187
|
|
|
|
|
|
|
$prj =~ s/[^a-z0-9]//g; |
188
|
|
|
|
|
|
|
$prj ||= $self->project; |
189
|
|
|
|
|
|
|
if ($prj =~ /^\d/) { |
190
|
|
|
|
|
|
|
$self->error("The project name must not begin with numbers. Choose another name consisting mainly of letters of the Latin alphabet"); |
191
|
|
|
|
|
|
|
return 0; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
my $skel = new CTK::Skel ( |
195
|
|
|
|
|
|
|
-name => $prj, |
196
|
|
|
|
|
|
|
-root => $dir, |
197
|
|
|
|
|
|
|
-skels => { |
198
|
|
|
|
|
|
|
device => 'MToken::DeviceSkel', |
199
|
|
|
|
|
|
|
}, |
200
|
|
|
|
|
|
|
-vars => { |
201
|
|
|
|
|
|
|
PROJECT => $prj, |
202
|
|
|
|
|
|
|
PROJECTNAME => $prj, |
203
|
|
|
|
|
|
|
NAME => ($prj eq $self->project) ? "MToken::Device" : sprintf("%s::Device", ucfirst($prj)), |
204
|
|
|
|
|
|
|
DISTNAME => $prj, |
205
|
|
|
|
|
|
|
GPGBIN => GPGBIN, |
206
|
|
|
|
|
|
|
OPENSSLBIN => OPENSSLBIN, |
207
|
|
|
|
|
|
|
MTOKEN_VERSION => $VERSION, |
208
|
|
|
|
|
|
|
CONFFILEONLY => MToken::Config::GLOBAL_CONF_FILE(), |
209
|
|
|
|
|
|
|
}, |
210
|
|
|
|
|
|
|
-debug => $self->debugmode, |
211
|
|
|
|
|
|
|
); |
212
|
|
|
|
|
|
|
#say("Skel object: ", explain($skel)); |
213
|
|
|
|
|
|
|
printf("Initializing device \"%s\"...\n", $prj); |
214
|
|
|
|
|
|
|
my %vars = ( |
215
|
|
|
|
|
|
|
PACKAGE => __PACKAGE__, |
216
|
|
|
|
|
|
|
VERSION => $VERSION, |
217
|
|
|
|
|
|
|
); |
218
|
|
|
|
|
|
|
if ($skel->build("device", $dir, {%vars})) { |
219
|
|
|
|
|
|
|
say "Done."; |
220
|
|
|
|
|
|
|
} else { |
221
|
|
|
|
|
|
|
say "Fail."; |
222
|
|
|
|
|
|
|
$self->error(sprintf("Can't build the device to \"%s\" directory", $dir)); |
223
|
|
|
|
|
|
|
return 0; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
return 1; |
226
|
|
|
|
|
|
|
}); |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
1; |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
__END__ |