line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MToken::Const; # $Id: Const.pm 105 2021-10-10 19:48:33Z minus $ |
2
|
4
|
|
|
4
|
|
453378
|
use strict; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
138
|
|
3
|
4
|
|
|
4
|
|
21
|
use utf8; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
30
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=encoding utf-8 |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
MToken::Const - Interface for MToken Constants |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 1.02 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use MToken::Const; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This module provide interface for MToken Constants |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 PROJECT, PROJECTNAME, PROJECTNAMEL |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Returns name of the project |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 HISTORY |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
See C file |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 TO DO |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
See C file |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 BUGS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
* none noted |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SEE ALSO |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
L |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 AUTHOR |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Serż Minus (Sergey Lepenkov) L Eabalama@cpan.orgE |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 COPYRIGHT |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Copyright (C) 1998-2021 D&D Corporation. All Rights Reserved |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 LICENSE |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
54
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
See C file and L |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
4
|
|
|
4
|
|
2682
|
use Try::Tiny; |
|
4
|
|
|
|
|
7448
|
|
|
4
|
|
|
|
|
1325
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
use constant { |
63
|
|
|
|
|
|
|
# GENERAL |
64
|
4
|
50
|
|
|
|
1966
|
PROJECT => 'MToken', |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
65
|
|
|
|
|
|
|
PROJECTNAME => 'MToken', |
66
|
|
|
|
|
|
|
PROJECTNAMEL => 'mtoken', |
67
|
|
|
|
|
|
|
PREFIX => 'mtoken', |
68
|
|
|
|
|
|
|
HOSTNAME => 'localhost', |
69
|
|
|
|
|
|
|
DEFAULT_URL => 'http://localhost', |
70
|
|
|
|
|
|
|
IS_TTY => (-t STDOUT) ? 1 : 0, |
71
|
|
|
|
|
|
|
IS_ROOT => ($> == 0) ? 1 : 0, |
72
|
|
|
|
|
|
|
IS_MSWIN => $^O =~ /mswin/i ? 1 : 0, |
73
|
|
|
|
|
|
|
SCREENWIDTH_DEFAULT => 80, |
74
|
|
|
|
|
|
|
DATE_FORMAT => "%YYYY-%MM-%DD", |
75
|
|
|
|
|
|
|
TIME_FORMAT => "%hh:%mm:%ss", |
76
|
|
|
|
|
|
|
DATETIME_FORMAT => "%YYYY-%MM-%DD %hh:%mm:%ss", |
77
|
|
|
|
|
|
|
DATETIME_GMT_FORMAT => "%YYYY-%MM-%DD %hh:%mm:%ss %G", |
78
|
|
|
|
|
|
|
TOKEN_PATTERN => qr/^[a-z][a-z0-9]+$/, |
79
|
|
|
|
|
|
|
TARBALL_FORMAT => "C%YYYY%MM%DDT%hh%mm%ss.tkn", |
80
|
|
|
|
|
|
|
TARBALL_PATTERN => qr/^C[0-9]{8}T[0-9]{6}\.tkn$/, |
81
|
|
|
|
|
|
|
RECORDS_PER_PAGE => 100, |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# UID/GID for daemon |
84
|
|
|
|
|
|
|
USERNAME => 'mtoken', |
85
|
|
|
|
|
|
|
GROUPNAME => 'mtoken', |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# DIRS |
88
|
|
|
|
|
|
|
DIR_KEYS => 'keys', |
89
|
|
|
|
|
|
|
DIR_CERTS => 'certs', |
90
|
|
|
|
|
|
|
DIR_ETC => 'etc', |
91
|
|
|
|
|
|
|
DIR_BACKUP => $^O =~ /mswin/i ? 'backup' : '.backup', |
92
|
|
|
|
|
|
|
DIR_RESTORE => $^O =~ /mswin/i ? 'restore' : '.restore', |
93
|
|
|
|
|
|
|
DIR_TMP => $^O =~ /mswin/i ? 'tmp' : '.tmp', |
94
|
|
|
|
|
|
|
DIR_PRIVATE => $^O =~ /mswin/i ? 'mtoken' : '.mtoken', |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Files |
97
|
|
|
|
|
|
|
GLOBAL_CONF_FILE => 'mtoken.conf', |
98
|
|
|
|
|
|
|
DEVICE_CONF_FILE => 'mtoken.conf', |
99
|
|
|
|
|
|
|
DEVICE_MANIFEST_FILE=> 'manifest.lst', |
100
|
|
|
|
|
|
|
DB_FILE => 'tokencase.db', |
101
|
|
|
|
|
|
|
RND_KEY_FILE => 'tokenrnd.key', |
102
|
|
|
|
|
|
|
PWCACHE_FILE => 'pwcache.tmp', |
103
|
|
|
|
|
|
|
PUBLIC_GPG_KEY => 'public.key', |
104
|
|
|
|
|
|
|
PRIVATE_GPG_KEY => 'private.key', |
105
|
|
|
|
|
|
|
MY_PUBLIC_KEY => 'mypublic.key', |
106
|
|
|
|
|
|
|
MY_PRIVATE_KEY => 'myprivate.key', |
107
|
|
|
|
|
|
|
GPGCONFFILE => 'gpg.conf', |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# System paths |
110
|
|
|
|
|
|
|
GPGBIN => 'gpg', |
111
|
|
|
|
|
|
|
OPENSSLBIN => 'openssl', |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# Server |
114
|
|
|
|
|
|
|
SERVER_URL => 'https://localhost:8642/mtoken', |
115
|
|
|
|
|
|
|
SERVER_LISTEN_PORT => 8642, |
116
|
|
|
|
|
|
|
SERVER_LISTEN_ADDR => "*", |
117
|
|
|
|
|
|
|
UPGRADE_TIMEOUT => 30, |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# MATH |
120
|
|
|
|
|
|
|
TRUE => 1, |
121
|
|
|
|
|
|
|
FALSE => 0, |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# CRYPT |
124
|
|
|
|
|
|
|
KEYSUFFIX => '.key', |
125
|
|
|
|
|
|
|
KEYMINSIZE => 32, |
126
|
|
|
|
|
|
|
KEYMAXSIZE => 2048, |
127
|
4
|
|
|
4
|
|
38
|
}; |
|
4
|
|
|
|
|
25
|
|
128
|
|
|
|
|
|
|
|
129
|
4
|
|
|
4
|
|
34
|
use base qw/Exporter/; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
620
|
|
130
|
|
|
|
|
|
|
|
131
|
4
|
|
|
4
|
|
33
|
use vars qw/$VERSION @EXPORT @EXPORT_OK %EXPORT_TAGS/; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1575
|
|
132
|
|
|
|
|
|
|
$VERSION = '1.02'; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# Named groups of exports |
135
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
136
|
|
|
|
|
|
|
'GENERAL' => [qw/ |
137
|
|
|
|
|
|
|
PROJECT PROJECTNAME PROJECTNAMEL PREFIX |
138
|
|
|
|
|
|
|
HOSTNAME DEFAULT_URL |
139
|
|
|
|
|
|
|
DIR_KEYS DIR_CERTS DIR_ETC DIR_BACKUP DIR_RESTORE DIR_TMP DIR_PRIVATE |
140
|
|
|
|
|
|
|
GLOBAL_CONF_FILE DEVICE_CONF_FILE DEVICE_MANIFEST_FILE DB_FILE PWCACHE_FILE RND_KEY_FILE |
141
|
|
|
|
|
|
|
MY_PUBLIC_KEY MY_PRIVATE_KEY |
142
|
|
|
|
|
|
|
GPGCONFFILE PUBLIC_GPG_KEY PRIVATE_GPG_KEY |
143
|
|
|
|
|
|
|
SCREENWIDTH_DEFAULT SCREENWIDTH |
144
|
|
|
|
|
|
|
IS_TTY IS_ROOT IS_MSWIN |
145
|
|
|
|
|
|
|
TOKEN_PATTERN TARBALL_PATTERN TARBALL_FORMAT |
146
|
|
|
|
|
|
|
DATE_FORMAT DATETIME_FORMAT TIME_FORMAT DATETIME_GMT_FORMAT |
147
|
|
|
|
|
|
|
RECORDS_PER_PAGE |
148
|
|
|
|
|
|
|
OPENSSLBIN GPGBIN |
149
|
|
|
|
|
|
|
SERVER_URL SERVER_LISTEN_PORT SERVER_LISTEN_ADDR UPGRADE_TIMEOUT |
150
|
|
|
|
|
|
|
USERNAME GROUPNAME |
151
|
|
|
|
|
|
|
/], |
152
|
|
|
|
|
|
|
'MATH' => [qw/ |
153
|
|
|
|
|
|
|
TRUE FALSE |
154
|
|
|
|
|
|
|
/], |
155
|
|
|
|
|
|
|
'CRYPT' => [qw/ |
156
|
|
|
|
|
|
|
KEYSUFFIX KEYMINSIZE KEYMAXSIZE |
157
|
|
|
|
|
|
|
/], |
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
my $myscreenw = undef; |
161
|
|
|
|
|
|
|
*SCREENWIDTH = sub { |
162
|
0
|
0
|
|
0
|
|
|
return $myscreenw if defined $myscreenw; |
163
|
0
|
|
|
|
|
|
if (IS_TTY) { |
164
|
|
|
|
|
|
|
try { |
165
|
0
|
|
|
0
|
|
|
require Term::ReadKey; |
166
|
0
|
|
|
|
|
|
my $w = (Term::ReadKey::GetTerminalSize())[0]; |
167
|
0
|
0
|
|
|
|
|
$myscreenw = $w < SCREENWIDTH_DEFAULT ? SCREENWIDTH_DEFAULT : $w; |
168
|
|
|
|
|
|
|
} catch { |
169
|
0
|
|
|
0
|
|
|
$myscreenw = SCREENWIDTH_DEFAULT; |
170
|
|
|
|
|
|
|
}; |
171
|
|
|
|
|
|
|
} else { |
172
|
0
|
|
|
|
|
|
$myscreenw = SCREENWIDTH_DEFAULT; |
173
|
|
|
|
|
|
|
} |
174
|
0
|
|
|
|
|
|
return $myscreenw; |
175
|
|
|
|
|
|
|
}; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# Items to export into callers namespace by default |
178
|
|
|
|
|
|
|
# (move infrequently used names to @EXPORT_OK below) |
179
|
|
|
|
|
|
|
@EXPORT = ( |
180
|
|
|
|
|
|
|
@{$EXPORT_TAGS{GENERAL}}, |
181
|
|
|
|
|
|
|
); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# Other items we are prepared to export if requested |
184
|
|
|
|
|
|
|
@EXPORT_OK = ( |
185
|
|
|
|
|
|
|
map {@{$_}} values %EXPORT_TAGS |
186
|
|
|
|
|
|
|
); |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
1; |