blib/lib/CGI/AuthRegister.pm

filter: Statementstmt 4.0% 52 / 1289 Branchbran 0.1% 1 / 544 Conditioncond 0.0% 0 / 123 MC/DCmcdc 0.0% 0 / 77 Subroutinesub 12.8% 9 / 70 Podpod 10.0% 5 / 50 totaltotal 3.1% 67 / 2153 CC 324 SCAR 52.9
CC
324
Cov
3%
run_cas
812.0
_db8_update
552.0
_require_login_using_cas
519.6
CRAP 199.1
↑ Summary
1 # file: AuthRegister.pm
2 # CGI::AuthRegister - AuthRegister Module for Simple CGI Authentication and
3 # Registration in Perl
4 # (c) 2012-22 Vlado Keselj http://vlado.ca
5  
6 package CGI::AuthRegister;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use vars qw($NAME $ABSTRACT $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 $NAME = 'AuthRegister';
10 1 $ABSTRACT = 'AuthRegister Module for Simple CGI Authentication and '.
11 'Registration in Perl';
12 1 $VERSION = '1.404'; # Last update: 2022-09-19
13  
14 1 ▶use CGI qw(:standard);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 # Useful diagnostics:
16 # use CGI qw(:standard :Carp -debug);
17 # use CGI::Carp 'fatalsToBrowser';
18 # use diagnostics; # verbose error messages
19 # use strict; # check for mistakes
20 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 require Exporter;
22 1 ▶use vars qw(@ISA @EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 @ISA = qw(Exporter);
24 1 @EXPORT = qw($AddAuthenticatedUser $DebugLevel $Error $SessionId
25 $SiteId $SiteName $User $UserEmail $UserId $SendLogs $LogReport
26 $LDAPuse $LDAPserver $LDAPdn $LDAPaddUsers $LinkForgotpwd
27 $GenCasPageCustom
28 analyze_cookie header_delete_cookie header_session_cookie
29 import_dir_and_config login logout
30 require_https require_login run_cas send_email_reminder
31 get_user get_user_by_userid send_email_to_admin
32 set_new_session store_log
33 );
34  
35 1 ▶use vars qw( $AddAuthenticatedUser $AllowSignup
Subroutine BEGIN: called CC=1 SCAR=0.0
36 $DBdir $DBusers $DBpwd $DBsessions $DBusersCas $DBpwdCas
37 $DBsessionsCas $DBcasTokens $DebugLevel
38 $Email_admin $Email_from $Email_bcc $Error $ErrorInternal
39 $GenCasPageCustom $Header $LogReport
40 $LDAPuse $LDAPserver $LDAPdn $LDAPaddUsers $LinkForgotpwd
41 $Sendmail $Session $SessionId $SiteId $SiteName $Ticket
42 1 $User $UserEmail $UserId $SendLogs $SecretSalt);
43 1 $AddAuthenticatedUser = ''; # If user is authenticated and not in database,
44 # add user to the database. (it should replace $LDAPaddUsers)!!!
45 1 $AllowSignup = ''; # 1 to allow new user signup
46 1 $DBdir = 'db'; # directory for stored data (822 db, sessions)
47 1 $DBusers = 'users.db'; # Users db
48 1 $DBusersCas = 'users-cas.db'; # CAS users db
49 1 $DBpwd = 'passwords'; # Passwords file
50 1 $DBpwdCas = 'passwords-cas'; # CAS passwords
51 1 $DBsessions = 'sessions.d'; # Sessions
52 1 $DBsessionsCas = 'sessions-cas.d'; # CAS sessions
53 1 $DBcasTokens = 'cas-tokens.db'; # CAS Tokens
54 # $Error = ''; # Appended error messages, OK to be sent to user
55 # $ErrorInternal = ''; # Appended internal error messages, intended
56 # for administrator
57 # $Header # Keeps the latest prepared HTTP header, if not printed
58 # $LogReport = ''; # Collecting some important log events if needed
59 1 $SecretSalt = &random_name; # Secret salt for generating secrets (e.g. tokens)
60 # $Session = ''; # Session data structure
61 # $SessionId = ''; # Session identifier, generated
62 1 $SiteId = 'Site'; # Site identifier, used in cookies and emails
63 1 $SiteName = 'Site'; # Site name, can include spaces
64 # $Ticket = ''; # Session ticket for security, generated
65 # $User = ''; # User data structure
66 # $UserEmail = ''; # User email address
67 # $SendLogs = ''; # If true, send logs by email to admin ($Email_bcc)
68  
69 1 $Email_from = ''; # Example: $SiteId.' <vlado@dnlp.ca>';
70 1 $Email_bcc = ''; # Example: $SiteId.' Bcc <vlado@dnlp.ca>';
71  
72 1 $Sendmail = "/usr/lib/sendmail"; # Sendmail with full path
73  
74 # Some function prototypes
75 sub putfile($@);
76  
77 ########################################################################
78 # Section: Configuration
79 # sets site id as the base directory name; imports configuration.pl if exists
80 0 ▶sub import_dir_and_config {
Subroutine import_dir_and_config: not called CC=2 SCAR=17.9
Pod documented
81 0 my $base = `pwd`; $base =~ /\/([^\/]*)$/; $base = $1; $base =~ s/\s+$//;
82 0 $SiteId = $SiteName = $base;
83 0 ▶ if (-r 'configuration.pl') { package main; require 'configuration.pl'; }
Branch: 1 branch
BranchTrueFalseTotal
if (-r "configuration.pl") 0 0 0
84 }
85  
86 ########################################################################
87 # Section: HTTPS Connection and Cookies Management
88  
89 # Check that the connection is HTTPS and if not, redirect to HTTPS.
90 # It must be done before script produces any output.
91 0 ▶sub require_https {
Subroutine require_https: not called CC=2 SCAR=17.9
Pod documented
92 0 ▶ if ($ENV{'HTTPS'} ne 'on') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"HTTPS"} ne "on") 0 0 0
93 0 print "Status: 301 Moved Permanently\n".
94 "Location: https://$ENV{SERVER_NAME}$ENV{SCRIPT_NAME}\n\n";
95 0 exit 0; }
96 }
97  
98 # Used to run a CAS service. If not logged in, ask for userid and password.
99 # On success, offer to pass confirmation back to the site; on fail offer retry
100 # or go back to the site. If site not given, stay. If previously logged in
101 # offer to pass confirmation to the site. Handles ?logout requests.
102 # Allows parentheses in userid's for login, which are removed. This allows
103 # users to use auxiliary comments with userid, so that browser can distinguish
104 # passwords.
105 0 ▶sub run_cas {
Subroutine run_cas: not called CC=28 SCAR=67.0
Pod undocumented
106 0 my %params = @_;
107 0 my $querystring = $ENV{QUERY_STRING};
108 0 $DBusers = $DBusersCas; $DBpwd = $DBpwdCas; $DBsessions = $DBsessionsCas;
109 0 &import_dir_and_config; &require_https;
110 0 ▶ if ($querystring eq '' && param('querystring')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($querystring eq "" and param("querystring")) 0 0 0
Condition0%0/3
$querystring eq "" and param("querystring")
!ll&&!rl&&r
000
MC/DC0%0/2
$querystring eq "" and param("querystring")
$querystring eq "" param("querystring")
Truth table0%0/3
A and B
A= $querystring eq ""B= param("querystring")
ABresult
0X0
100
111
111 0 $querystring=param('querystring') }
112 0 ▶ if ($querystring eq 'cas-all.css') { &deliver('cas-all.css') }
Branch: 1 branch
BranchTrueFalseTotal
if ($querystring eq "cas-all.css") 0 0 0
113 0 ▶ if ($querystring eq 'cas-mobile.css') { &deliver('cas-mobile.css') }
Branch: 1 branch
BranchTrueFalseTotal
if ($querystring eq "cas-mobile.css") 0 0 0
114  
115 0 ▶ if (param('rt') ne '' && param('rt') eq 'verify') {
Branch: 1 branch
BranchTrueFalseTotal
if (param("rt") ne "" and param("rt") eq "verify") 0 0 0
Condition0%0/3
param("rt") ne "" and param("rt") eq "verify"
!ll&&!rl&&r
000
MC/DC0%0/2
param("rt") ne "" and param("rt") eq "verify"
param("rt") ne "" param("rt") eq "verify"
Truth table0%0/3
A and B
A= param("rt") ne ""B= param("rt") eq "verify"
ABresult
0X0
100
111
116 0 my $username = param('username'); my $stoken = param('stoken');
117 0 my $r = &_db8_find_first("$DBdir/$DBcasTokens", 'k=stoken', $stoken);
118 0 my $ans = 'fail';
119 0 ▶ if ($r ne '' and $r->{stoken} eq $stoken and $r->{userid} eq $username) {
Branch: 1 branch
BranchTrueFalseTotal
if ($r ne "" and $r->{"stoken"} eq $stoken and $r->{"userid"} eq $username) 0 0 0
Condition0%0/6
$r ne "" and $r->{"stoken"} eq $stoken and $r->{"userid"} eq $username
!ll&&!rl&&r
000
$r ne "" and $r->{"stoken"} eq $stoken
!ll&&!rl&&r
000
MC/DC0%0/3
$r ne "" and $r->{"stoken"} eq $stoken and $r->{"userid"} eq $username
$r ne "" $r->{"stoken"} eq $stoken $r->{"userid"} eq $username
Truth table0%0/4
A and B and C
A= $r ne ""B= $r->{"stoken"} eq $stokenC= $r->{"userid"} eq $username
ABCresult
0XX0
10X0
1100
1111
120 0 $ans = 'ok';
121 0 ▶ if ($DebugLevel > 5) { $LogReport .= "CAS verification OK for ".
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::DebugLevel > 5) 0 0 0
122 0 "username($username) stoken($stoken)"; &store_log; }
123 }
124 0 ▶ if ($ans ne 'ok') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ans ne "ok") 0 0 0
125 0 print header(), "answer:fail\n";
126 0 ▶ if ($DebugLevel > 5) { $LogReport .= "CAS verify failed for ".
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::DebugLevel > 5) 0 0 0
127 "username($username) stoken($stoken)"; }
128 0 &store_log; exit(); }
129 0 &_db8_remove("$DBdir/$DBcasTokens", 'k=stoken', $stoken);
130 0 print header(), "answer:ok\n"; exit();
131 }
132
133 0 my $redirect_uri;
134 0 ▶ if (param('redirect_uri') ne '') { $redirect_uri = param('redirect_uri') }
Branch: 2 branches
BranchTrueFalseTotal
if (param('redirect_uri') ne '') { } 0 0 0
elsif (param('r') ne '') { } 0 0 0
135 0 elsif (param('r') ne '') { $redirect_uri = param('r') }
136  
137 ### Helper functions: finishGeneral, finishWithPageBack
138  
139 0 ▶ local *finishGeneral = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
140 0 my $page = &gen_cas_page;
141 0 ▶ if ($redirect_uri ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($redirect_uri ne "") 0 0 0
142 0 my $h = "<input type=\"hidden\" name=\"redirect_uri\" ".
143 "value=\"$redirect_uri\">";
144 0 $page=~ s/<!--!hiddenfields-->/$h\n$&/;
145 0 my $t = "CAS Authentication requested by the following site:<br>\n".
146 "<code>".&htmlquote($redirect_uri)."</code>";
147 0 $page =~ s/(<!--38--)>(.*)/$1>$t/;
148 }
149 0 print $page; exit; };
150
151 0 ▶ local *finishWithPageBack = sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
152 0 my $page = &gen_cas_page; my $h = 'Successful Authentication!';
153 0 my $userid = $User->{userid};
154 0 my $t = "You are authenticated with the userid '$userid'.\n";
155 0 ▶ if ($redirect_uri ne '') { $t.="Click the button 'Proceed' to ".
Branch: 1 branch
BranchTrueFalseTotal
if ($redirect_uri ne "") 0 0 0
156 "pass the userid and an authentication code to the site:\n<br>".
157 "<code>".&htmlquote($redirect_uri)."</code>"; }
158 0 $page =~ s/(<!--37--)>(.*)/$1>$h/;
159 0 $page =~ s/(<!--38--)>(.*)/$1>$t/;
160 0 $page =~ s/<!--!username-->.*?\n\n/\n/s;
161 0 $page =~ s/<!--!password-->.*?\n\n/\n/s;
162 0 ▶ if ($redirect_uri ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($redirect_uri ne '') { } 0 0 0
163 0 my $stoken = &gen_secret; $userid=~s/["<>]//g;
164 0 my $f = "$DBdir/$DBcasTokens";
165 0 ▶ if (!-f $f && !&check_db_files) { $LogReport.=$Error; &store_log;
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $f or &check_db_files) 0 0 0
Condition0%0/3
-f $f or &check_db_files
l!l&&r!l&&!r
000
MC/DC0%0/2
-f $f or &check_db_files
-f $f &check_db_files
Truth table0%0/3
A or B
A= -f $fB= &check_db_files
ABresult
1X1
011
000
166 0 print "<html><body>Error: $Error"; exit; }
167 0 ▶ if (!-f $f) { putfile $f, ''; chmod 0600, $f; }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $f) 0 0 0
168 0 &_db8_append($f, "userid:$userid\nstoken:$stoken" );
169 0 ▶ if ($Error ne '') { $LogReport.=$Error; &store_log;
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::Error ne "") 0 0 0
170 0 print "<html><body>Error: $Error"; exit; }
171 0 my $h = "<input type=\"hidden\" name=\"username\" value=\"$userid\">";
172 0 $page=~ s/<!--!hiddenfields-->/$h\n$&/;
173 0 $h = "<input type=\"hidden\" name=\"stoken\" value=\"$stoken\">";
174 0 $page=~ s/<!--!hiddenfields-->/$h\n$&/;
175 0 $page =~ s/(<input class="inputButton" value=)"Login"/$1"Proceed"/;
176 0 my $r = &encodeuri($redirect_uri);
177 0 $page =~ s/(<form id="login_form" action=)"\?login"/$1"$r"/;
178 0 } else { $page =~ s/<input class="inputButton".*?>//s; }
179 0 print $page;
180 # Log out user so that they have to login every time they use the service
181 0 logout();
182 0 exit;
183 0 };
184 ### End of helper functions
185
186 # Check redirect_uri
187 0 ▶ if ($redirect_uri ne '' &&
Branch: 1 branch
BranchTrueFalseTotal
if ($redirect_uri ne "" and not $redirect_uri =~ m[^https://(\w|[-.~/])+]i and not $redirect_uri =~ m[^http://(\w|[-.~/:])+]i) 0 0 0
Condition0%0/6
$redirect_uri ne "" and not $redirect_uri =~ m[^https://(\w|[-.~/])+]i and not $redirect_uri =~ m[^http://(\w|[-.~/:])+]i
!ll&&!rl&&r
000
$redirect_uri ne "" and not $redirect_uri =~ m[^https://(\w|[-.~/])+]i
!ll&&!rl&&r
000
MC/DC0%0/3
$redirect_uri ne "" and not $redirect_uri =~ m[^https://(\w|[-.~/])+]i and not $redirect_uri =~ m[^http://(\w|[-.~/:])+]i
$redirect_uri ne "" not $redirect_uri =~ m[^https://(\w|[-.~/])+]i not $redirect_uri =~ m[^http://(\w|[-.~/:])+]i
Truth table0%0/4
A and not(B) and not(C)
A= $redirect_uri ne ""B= not $redirect_uri =~ m[^https://(\w|[-.~/])+]iC= not $redirect_uri =~ m[^http://(\w|[-.~/:])+]i
ABCresult
0XX0
10X0
1100
1111
188 $redirect_uri !~ /^https:\/\/(\w|[-.~\/])+/i &&
189 $redirect_uri !~ /^http:\/\/(\w|[-.~\/:])+/i ## This is temporary for a student project
190 ## It is probably is too relaxed.
191 ) {
192 0 my $page = &gen_cas_page;
193 0 my $h = 'redirect_uri Error!';
194 0 my $t = "URI of the requesting site is not in an acceptable format:<br>\n".
195 "<code>".&htmlquote($redirect_uri)."</code><br>\n".
196 "Please check with the CAS maintainer if you think that this URI ".
197 "should be accepted. The rules include a requirement that the URI ".
198 "starts with 'https://' (including uppercase), and can have only some ".
199 "standard characters. It is possible that more characters should be ".
200 "allowed.";
201 0 $page =~ s/(<!--37--)>(.*)/$1>$h/;
202 0 $page =~ s/(<!--38--)>(.*)/$1>$t/;
203 0 $page =~ s/<!--username-->.*?<!--\/lastrow-->//s;
204 0 print header(), $page; exit;
205 }
206  
207 0 ▶ if ($querystring eq 'forgotpwd' or param('rt') eq 'forgotpwd') {
Branch: 1 branch
BranchTrueFalseTotal
if ($querystring eq "forgotpwd" or param("rt") eq "forgotpwd") 0 0 0
Condition0%0/3
$querystring eq "forgotpwd" or param("rt") eq "forgotpwd"
l!l&&r!l&&!r
000
MC/DC0%0/2
$querystring eq "forgotpwd" or param("rt") eq "forgotpwd"
$querystring eq "forgotpwd" param("rt") eq "forgotpwd"
Truth table0%0/3
A or B
A= $querystring eq "forgotpwd"B= param("rt") eq "forgotpwd"
ABresult
1X1
011
000
208 0 ▶ if ($LinkForgotpwd) { print CGI::redirect(-uri=>$LinkForgotpwd); exit; }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::LinkForgotpwd) 0 0 0
209 0 my $page = &gen_cas_page; my $h = 'Send Password';
210 0 my $t = "Enter your UserID or Email to have password reset and sent to ".
211 "you by email.\nIf you do not receive email, it may mean that you are ".
212 "not registered in the system, and you should contanct the administrator.";
213 0 $page =~ s/(<!--37--)>(.*)/$1>$h/;
214 0 $page =~ s/(<!--38--)>(.*)/$1>$t/;
215 0 $page =~ s/<!--!password-->.*?\n\n/\n/s;
216 0 $page =~ s/(<input class="inputButton" value=)"Login"/$1"Send_Password"/;
217 0 print header(), $page; exit;
218 }
219
220 0 my $title = "Login Page for Site: $CGI::AuthRegister::SiteName";
221 0 my $HTMLstart = "<HTML><HEAD><TITLE>$title</TITLE><BODY><h1>$title</h1>\n";
222 0 my $Formstart = "<form action=\"$ENV{SCRIPT_NAME}\" method=\"post\">";
223 0 my $LoginForm = "<p>Please login with your DalFCS Account userid and password:<br>\n".$Formstart.
224 hidden('querystring',$querystring).
225 "<table><tr><td align=right>CS Userid:</td><td>".
226 textfield(-name=>"csuserid")."</td></tr>\n<tr><td align=right>".
227 "Password:</td><td>".password_field(-name=>"password")."</td></tr>\n".
228 '<tr><td>&nbsp;</td><td><input type="submit" name="request_type" value="Login"/>'.
229 "</td></tr></table></form>\n";
230  
231 # $LoginForm.="<pre>LogReport:\n$CGI::AuthRegister::LogReport\nError=$CGI::AuthRegister::Error\n";
232  
233 0 &analyze_cookie;
234  
235 # Logout from CAS
236 0 ▶ if ($CGI::AuthRegister::SessionId ne '' && param('keywords') eq 'logout') {
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::SessionId ne "" and param("keywords") eq "logout") 0 0 0
Condition0%0/3
$CGI::AuthRegister::SessionId ne "" and param("keywords") eq "logout"
!ll&&!rl&&r
000
MC/DC0%0/2
$CGI::AuthRegister::SessionId ne "" and param("keywords") eq "logout"
$CGI::AuthRegister::SessionId ne "" param("keywords") eq "logout"
Truth table0%0/3
A and B
A= $CGI::AuthRegister::SessionId ne ""B= param("keywords") eq "logout"
ABresult
0X0
100
111
237 0 CGI::AuthRegister::logout(); print header(); &finishGeneral; }
238
239 0 ▶ if ($SessionId ne '') { print header(); &finishWithPageBack; }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::SessionId ne "") 0 0 0
240  
241 0 my $Request_type = param('request_type');
242  
243 0 ▶ if ($Request_type eq 'Login') {
Branch: 2 branches
BranchTrueFalseTotal
if ($Request_type eq 'Login') { } 0 0 0
elsif ($Request_type eq 'Send_Password') { } 0 0 0
244 0 my $username = param('username'); my $password = param('password');
245 0 $username =~ s/\(.*\)//g; $username =~ s/\s+$//; $username =~ s/^\s+//;
246 0 $username =~ s/[^a-zA-Z0-9_-]//g; $username = lc($username);
247
248 0 ▶ if (! &login($username, $password) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not &login($username, $password)) { } 0 0 0
249 0 my $page = &gen_cas_page;
250 0 my $t = "<b>Unsuccessful login!</b><br>\n";
251 0 ▶ if ($redirect_uri ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($redirect_uri ne "") 0 0 0
252 0 my $h = "<input type=\"hidden\" name=\"redirect_uri\" ".
253 "value=\"$redirect_uri\">";
254 0 $page=~ s/<!--!hiddenfields-->/$h\n$&/;
255 0 $t.= "CAS Authentication requested by the following site:<br>\n".
256 "<code>".&htmlquote($redirect_uri)."</code>"; }
257 0 $page =~ s/(<!--38--)>(.*)/$1>$t/;
258 0 print header(), $page; $LogReport.=$Error; &store_log; exit;
259 }
260 0 else { print header_session_cookie(); &finishWithPageBack; }
261 }
262 elsif ($Request_type eq 'Send_Password') {
263 0 &send_email_reminder(param('username'), 'raw');
264 0 my $page = &gen_cas_page;
265 0 my $h = 'Request Received';
266 0 my $t = "Send password request received. You should receive a password ".
267 "if your email is registered at this site.\nIf you do not receive ".
268 "a reminder, you should contact the administrator.";
269 0 $page =~ s/(<!--37--)>(.*)/$1>$h/;
270 0 $page =~ s/(<!--38--)>(.*)/$1>$t/;
271 0 $page =~ s/<!--username-->.*?<!--\/lastrow-->//s; # remove the form
272 0 print header(), $page;
273 0 $LogReport.=$Error; &store_log;
274 0 exit;
275 }
276 else { # should be: $Request_type eq ''
277 0 print header(); &finishGeneral; }
278 0 die; # Not supposed to be reached
279 }
280  
281  
282 # If not logged in, ask for userid/email and password. Catches ?logout
283 # request as well. Allows parentheses in userid/email for login, which are
284 # removed. This allows users to use auxiliary comments with userid, so that
285 # browser can distinguish passwords.
286 0 ▶sub require_login {
Subroutine require_login: not called CC=15 SCAR=54.8
Pod documented
287 0 ▶ my %args = @_; return &_require_login_using_cas(@_) if exists($args{-cas});
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"-cas"} 0 0 0
288 0 my $title = "Login Page for Site: $SiteId";
289 0 my $HTMLstart = "<HTML><HEAD><TITLE>$title</TITLE><BODY><h1>$title</h1>\n";
290 0 my $Formstart = "<form action=\"$ENV{SCRIPT_NAME}\" method=\"post\">";
291 0 my $Back = "<a href=\"$ENV{SCRIPT_NAME}\">Click here for the main page.</a>\n";
292 0 ▶ local *tr = sub { my($a,$b) = @_; return "<tr><td align=right>$a:</td><td>".
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$a =~ /password/i ? : 0 0 0
293 ($a=~/password/i?password_field(-name=>$b):textfield(-name=>$b)).
294 0 "</td></tr>\n"; };
295 0 my $LoginForm = "<p>Please log in to access the site:<br>\n".$Formstart.
296 "<table>\n".&tr('Userid or email','userid').
297 &tr('Password','password').
298 '<tr><td>&nbsp;</td><td><input type="submit" name="request_type" value="Login"/>'.
299 "</td></tr></table></form>\n";
300 0 ▶ my $SendResetForm = "<p>If you forgot your password, it may be possible to ".
Branch: 1 branch
BranchTrueFalseTotal
$CGI::AuthRegister::AllowSignup ? : 0 0 0
301 "retrieve it by email:<br>\n".$Formstart."Email: ".
302 textfield(-name=>"email_pw_send")."\n".
303 '<input type="submit" name="request_type" value="Send_Password"/>'.
304 "</form>\n".
305 "Or, you can reqest password to be reset and sent to you:<br>\n".
306 $Formstart."Email: ".textfield(-name=>"email_reset")."\n".
307 '<input type="submit" name="request_type" value="Reset_Password"/>'.
308 "</form>\n".
309 ($AllowSignup?("<a href=\"$ENV{SCRIPT_NAME}?signup\">".
310 "Register new user</a>\n"):'');
311 0 my $RegistrationForm = $Formstart.
312 "<table>\n".&tr('Userid','reg_userid').&tr('Email','reg_email').
313 &tr('Password','reg_password').&tr('Confirm password','reg_password2').
314 '<tr><td>&nbsp;</td><td><input type="submit" name="request_type" value="Register"/>'.
315 "</td></tr></table></form>\n";
316
317 0 &analyze_cookie;
318 0 ▶ if ($SessionId ne '' && param('keywords') eq 'logout') {
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::SessionId ne "" and param("keywords") eq "logout") 0 0 0
Condition0%0/3
$CGI::AuthRegister::SessionId ne "" and param("keywords") eq "logout"
!ll&&!rl&&r
000
MC/DC0%0/2
$CGI::AuthRegister::SessionId ne "" and param("keywords") eq "logout"
$CGI::AuthRegister::SessionId ne "" param("keywords") eq "logout"
Truth table0%0/3
A and B
A= $CGI::AuthRegister::SessionId ne ""B= param("keywords") eq "logout"
ABresult
0X0
100
111
319 0 logout(); print header_delete_cookie(),$HTMLstart,
320 0 "<p>You are logged out.\n", $LoginForm, $SendResetForm; exit; }
321  
322 0 ▶ if ($SessionId ne '') { print header(); return 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::SessionId ne "") 0 0 0
323  
324 0 ▶ if (param('keywords') eq 'signup' && $AllowSignup) {
Branch: 2 branches
BranchTrueFalseTotal
if (param('keywords') eq 'signup' and $CGI::AuthRegister::AllowSignup) { } 0 0 0
elsif (param('confirmation_code')) { } 0 0 0
Condition0%0/3
param("keywords") eq "signup" and $CGI::AuthRegister::AllowSignup
!ll&&!rl&&r
000
MC/DC0%0/2
param("keywords") eq "signup" and $CGI::AuthRegister::AllowSignup
param("keywords") eq "signup" $CGI::AuthRegister::AllowSignup
Truth table0%0/3
A and B
A= param("keywords") eq "signup"B= $CGI::AuthRegister::AllowSignup
ABresult
0X0
100
111
325 0 print header(), $HTMLstart, "<h2>New Registration</h2>\n",
326 0 $RegistrationForm; exit; }
327 elsif (param('confirmation_code')) {
328 0 print header(), $HTMLstart, "<h2>Email Confirmation</h2>\n";
329 0 &email_confirmation(param('confirmation_code')); exit;
330 }
331
332 0 my $Request_type = param('request_type');
333  
334 0 ▶ if ($Request_type eq 'Login') {
Branch: 4 branches
BranchTrueFalseTotal
if ($Request_type eq 'Login') { } 0 0 0
elsif ($Request_type eq 'Send_Password') { } 0 0 0
elsif ($Request_type eq 'Reset_Password') { } 0 0 0
elsif ($Request_type eq 'Register' and $CGI::AuthRegister::AllowSignup) { } 0 0 0
335 0 my $email = param('userid'); my $password = param('password');
336 0 $email =~ s/\(.*\)//g; $email =~ s/\s+$//; $email =~ s/^\s+//;
337  
338 0 ▶ if (! &login($email, $password) ) { # checks for userid and email
Branch: 1 branch
BranchTrueFalseTotal
if (not &login($email, $password)) { } 0 0 0
339 0 print header(), $HTMLstart, "Unsuccessful login!\n";
340 0 print $LoginForm, $SendResetForm; exit;
341 }
342 0 else { print header_session_cookie(); return 1; }
343 }
344 elsif ($Request_type eq 'Send_Password') {
345 0 &send_email_reminder(param('email_pw_send'), 'raw');
346 0 print header(), $HTMLstart, "You should receive password reminder if ".
347 "your email is registered at this site.\n".
348 "If you do not receive remider, you can contact the administrator.\n",
349 $LoginForm, $SendResetForm;
350 0 $LogReport.=$Error; &store_log;
351 0 exit;
352 }
353 elsif ($Request_type eq 'Reset_Password') {
354 0 &reset_and_send_email_reminder(param('email_reset'), 'raw');
355 0 print header(), $HTMLstart, "You should receive new password if ".
356 "your email is registered at this site.\n".
357 "If you do not receive remider, you can contact the administrator.\n",
358 0 $LoginForm, $SendResetForm; exit;
359 }
360 ▶ elsif ($Request_type eq 'Register' && $AllowSignup) {
Condition0%0/3
$Request_type eq "Register" and $CGI::AuthRegister::AllowSignup
!ll&&!rl&&r
000
MC/DC0%0/2
$Request_type eq "Register" and $CGI::AuthRegister::AllowSignup
$Request_type eq "Register" $CGI::AuthRegister::AllowSignup
Truth table0%0/3
A and B
A= $Request_type eq "Register"B= $CGI::AuthRegister::AllowSignup
ABresult
0X0
100
111
361 0 $|=1; print header(), $HTMLstart;
362 0 &register_new_user;
363 0 exit;
364 }
365 else { # should be: $Request_type eq ''
366 0 print header(), $HTMLstart, $LoginForm, $SendResetForm; exit; }
367
368 0 die; # Not supposed to be reached
369 }
370  
371 # parameters:
372 # -return_status=>1 rather than exiting on failure, return status
373 # return status values: 'logged out', 1, 'not logged in' 'login failed'
374 # If we want that user gets a suggestion to use CAS to login, then
375 # this option should not be used.
376 #
377 # -header_no_print=> do not print header on success, but keep in $Header
378 0 ▶sub _require_login_using_cas {
Subroutine _require_login_using_cas: not called CC=23 SCAR=62.5
379 0 my %args = @_; my $casurl = $args{-cas};
380 0 my $header_no_print = $args{-header_no_print};
381 0 my $retStatus;
382 0 ▶ $retStatus = $args{-return_status} if exists($args{-return_status});
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"-return_status"} 0 0 0
383 0 my $title = "Login Page for Site: $SiteId";
384 0 my $HTMLstart = "<HTML><HEAD><TITLE>$title</TITLE><BODY><h1>$title</h1>\n";
385 0 my $casurl_r = "$casurl?r=".url();
386 0 my $LoginMsg = "<p>Please use <a href=\"".encodeuri($casurl_r)."\">CAS</a> ".
387 "to login.\n";
388  
389 0 &analyze_cookie;
390 0 ▶ if ($SessionId ne '' && param('keywords') eq 'logout') {
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::SessionId ne "" and param("keywords") eq "logout") 0 0 0
Condition0%0/3
$CGI::AuthRegister::SessionId ne "" and param("keywords") eq "logout"
!ll&&!rl&&r
000
MC/DC0%0/2
$CGI::AuthRegister::SessionId ne "" and param("keywords") eq "logout"
$CGI::AuthRegister::SessionId ne "" param("keywords") eq "logout"
Truth table0%0/3
A and B
A= $CGI::AuthRegister::SessionId ne ""B= param("keywords") eq "logout"
ABresult
0X0
100
111
391 0 logout(); print header_delete_cookie();
392 0 ▶ if ($retStatus) { return 'logged out' }
Branch: 1 branch
BranchTrueFalseTotal
if ($retStatus) 0 0 0
393 0 print "<HTML><HEAD>";
394 0 my $redirect;
395 0 ▶ if ($args{-logout_redirect}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"-logout_redirect"}) 0 0 0
396 0 $redirect = encodeuri($args{-logout_redirect});
397 0 print "<meta http-equiv=\"Refresh\" content=\"2; URL=".
398 "$redirect\">\n"; }
399 0 ▶ my $t = $title; $t = $args{-logout_title} if $args{-logout_title};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"-logout_title"} 0 0 0
400 0 print "<TITLE>$t</TITLE><BODY>\n<H1>$t</H1>\n";
401 0 print "<p>You are logged out.\n";
402 0 ▶ if ($redirect) {
Branch: 1 branch
BranchTrueFalseTotal
if ($redirect) { } 0 0 0
403 0 print "<p>You are redirected to <a href=\"$redirect\">$redirect</a>.\n";
404 0 } else { print $LoginMsg; }
405 0 exit; }
406  
407 0 ▶ if ($SessionId ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::SessionId ne "") 0 0 0
408 0 my $header = header();
409 0 ▶ if ($header_no_print) { $Header=$header; return 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($header_no_print) 0 0 0
410 0 print $header; return 1; }
411  
412 0 my $request_type = param('request_type');
413 0 ▶ if ($request_type ne 'Proceed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($request_type ne "Proceed") 0 0 0
414 0 ▶ if ($retStatus) { print header(); return 'not logged in' }
Branch: 1 branch
BranchTrueFalseTotal
if ($retStatus) 0 0 0
415 0 print CGI::redirect(-uri=>$casurl_r);
416 0 exit; }
417 0 my $username = param('username'); my $stoken = param('stoken');
418 0 ▶ if ($username eq '' or $stoken eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($username eq "" or $stoken eq "") 0 0 0
Condition0%0/3
$username eq "" or $stoken eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
$username eq "" or $stoken eq ""
$username eq "" $stoken eq ""
Truth table0%0/3
A or B
A= $username eq ""B= $stoken eq ""
ABresult
1X1
011
000
419 0 ▶ print header(); if ($retStatus) { return 'not logged in' }
Branch: 1 branch
BranchTrueFalseTotal
if ($retStatus) 0 0 0
420 0 print $HTMLstart, $LoginMsg; exit; }
421  
422 0 ▶ if ($casurl !~ /^https:\/\//i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($casurl =~ m[^https://]i) 0 0 0
423 0 my $u = CGI::url(); $u=~ s/\/[^\/]+$//; $casurl = "$u/$casurl"; }
424  
425 0 require LWP::UserAgent; require HTTP::Request; require Mozilla::CA;
426 0 my $ua = LWP::UserAgent->new();
427 1 ▶ use HTTP::Request::Common qw(POST);
Subroutine BEGIN: called CC=1 SCAR=0.0
428 0 my $req = POST $casurl, [ rt=>'verify', username=>$username, stoken=>$stoken ];
429 0 my $resp = $ua->request($req);
430 0 my $result = 'fail';
431 0 ▶ if ($resp->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resp->is_success) { } 0 0 0
432 0 my $message = $resp->decoded_content; $message =~ s/\s//g;
433 0 ▶ if ($message eq 'answer:ok') { $result = 'ok'; &_dbg383; }
Branch: 1 branch
BranchTrueFalseTotal
if ($message eq 'answer:ok') { } 0 0 0
434 0 else { $Error.=" message=($message);" }
435 } else {
436 0 $Error.= "HTTP POST error code: ". $resp->code. "\n".
437 "HTTP POST error message: ".$resp->message."\n";
438 }
439 0 ▶ if ($result ne 'ok') {
Branch: 1 branch
BranchTrueFalseTotal
if ($result ne "ok") 0 0 0
440 0 $Error.="ERR-401:verify failed, result=($result) casurl=($casurl)\n";
441 0 print header(); $LogReport.=$Error; &store_log;
442 0 ▶ if ($retStatus) { return 'login failed'; }
Branch: 1 branch
BranchTrueFalseTotal
if ($retStatus) 0 0 0
443 0 print $HTMLstart, "Unsuccessful login!\n"; exit; }
444 0 ▶ my $u = ($AddAuthenticatedUser ? &get_user_by_userid_or_add($username) :
Branch: 1 branch
BranchTrueFalseTotal
$CGI::AuthRegister::AddAuthenticatedUser ? : 0 0 0
445 &get_user_unique('userid', $username));
446 0 ▶ if ($u eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($u eq "") 0 0 0
447 0 $Error.="411-ERR: no userid ($username) in users.db\n";
448 0 $LogReport.=$Error; &store_log;
449 0 ▶ print header(); if ($retStatus) { return 'login failed'; }
Branch: 1 branch
BranchTrueFalseTotal
if ($retStatus) 0 0 0
450 0 print $HTMLstart,
451 "Unsuccessful login! (username not in users.db, ERR-414)\n";
452 0 &store_log; exit; }
453 0 $User = $u; &set_new_session($User);
454 0 $LogReport.="User $UserEmail logged in.\n"; &store_log;
455 0 print header_session_cookie(); return 1;
456 }
457  
458 # Requires session (i.e., to be logged in). Otherwise, makes redirection.
459 0 ▶sub require_session {
Subroutine require_session: not called CC=8 SCAR=42.8
Pod documented
460 0 my %args=@_; my $defaultcgi = 'index.cgi';
461 0 ▶ if (exists($args{-redirect}) && $args{-redirect} ne '' &&
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"-redirect"} and $args{"-redirect"} ne "" and $args{"-redirect"} ne $ENV{"SCRIPT_NAME"}) 0 0 0
Condition0%0/6
exists $args{"-redirect"} and $args{"-redirect"} ne "" and $args{"-redirect"} ne $ENV{"SCRIPT_NAME"}
!ll&&!rl&&r
000
exists $args{"-redirect"} and $args{"-redirect"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/3
exists $args{"-redirect"} and $args{"-redirect"} ne "" and $args{"-redirect"} ne $ENV{"SCRIPT_NAME"}
exists $args{"-redirect"} $args{"-redirect"} ne "" $args{"-redirect"} ne $ENV{"SCRIPT_NAME"}
Truth table0%0/4
A and B and C
A= exists $args{"-redirect"}B= $args{"-redirect"} ne ""C= $args{"-redirect"} ne $ENV{"SCRIPT_NAME"}
ABCresult
0XX0
10X0
1100
1111
462 $args{-redirect} ne $ENV{SCRIPT_NAME})
463 0 { $defaultcgi = $args{-redirect} }
464 0 ▶ if (exists($args{-back}) && $args{-back}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"-back"} and $args{"-back"}) 0 0 0
Condition0%0/3
exists $args{"-back"} and $args{"-back"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $args{"-back"} and $args{"-back"}
exists $args{"-back"} $args{"-back"}
Truth table0%0/3
A and B
A= exists $args{"-back"}B= $args{"-back"}
ABresult
0X0
100
111
465 0 $defaultcgi.="?goto=$args{-back}";
466 }
467 0 &analyze_cookie;
468 0 ▶ if ($SessionId eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::SessionId eq "") 0 0 0
469 0 ▶ if ($ENV{SCRIPT_NAME} eq $defaultcgi) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"SCRIPT_NAME"} eq $defaultcgi) 0 0 0
470 0 print CGI::header(), CGI::start_html, CGI::h1("159-ERR:Login required");
471 0 exit; }
472 0 print CGI::redirect(-uri=>$defaultcgi); exit;
473 }
474 }
475  
476 # Prepare HTTP header. If SessionId is not empty, generate cookie with
477 # the sessionid and ticket.
478 0 ▶sub header_session_cookie {
Subroutine header_session_cookie: not called CC=4 SCAR=30.0
Pod undocumented
479 0 my %args=@_; my $redirect=$args{-redirect};
480 0 ▶ if ($redirect ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($redirect ne '') { } 0 0 0
481 0 ▶ if ($SessionId eq '') { return redirect(-uri=>$redirect) }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::SessionId eq '') { } 0 0 0
482 else {
483 0 return redirect(-uri=>$redirect,-cookie=>
484 cookie(-name=>$SiteId,
485 -value=>"$SessionId $Ticket"));
486 }
487 } else {
488 0 ▶ if ($SessionId eq '') { return header } else
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::SessionId eq '') { } 0 0 0
489 0 { return header(-cookie=>cookie(-name=>$SiteId,
490 -value=>"$SessionId $Ticket")) }
491 }
492 }
493  
494 # Delete cookie after logging out. Return string.
495 0 ▶sub header_delete_cookie {
Subroutine header_delete_cookie: not called CC=1 SCAR=6.9
Pod undocumented
496 0 return header(-cookie=>cookie(-name=>$SiteId, -value=>'', -expires=>"now")) }
497  
498 # Analyze cookie to detect session, and check the ticket as well. It
499 # should be called at the beginning of a script. $SessionId and
500 # $Ticket are set to empty string if not successful. The information
501 # about the session is stored in $DBdir/$DBsessions/$SessionId/session.info
502 # file. The structures $Session and $User are set if successful.
503 0 ▶sub analyze_cookie {
Subroutine analyze_cookie: not called CC=14 SCAR=53.5
Pod documented
504 0 my $c = cookie(-name=>$SiteId); # sessionid and ticket
505 0 ▶ if ($DebugLevel > 5) { $LogReport.="cookie:$SiteId:$c\n"; &store_log; }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::DebugLevel > 5) 0 0 0
506 0 ▶ if ($c eq '') { $SessionId = $Ticket = ''; return; }
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "") 0 0 0
507 0 ($SessionId, $Ticket) = split(/\s+/, $c);
508 0 ▶ if ($SessionId !~ /^[\w.:-]+$/ or $Ticket !~ /^\w+$/)
Branch: 1 branch
BranchTrueFalseTotal
unless ($CGI::AuthRegister::SessionId =~ /^[\w.:-]+$/ and $CGI::AuthRegister::Ticket =~ /^\w+$/) 0 0 0
Condition0%0/3
$CGI::AuthRegister::SessionId =~ /^[\w.:-]+$/ and $CGI::AuthRegister::Ticket =~ /^\w+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$CGI::AuthRegister::SessionId =~ /^[\w.:-]+$/ and $CGI::AuthRegister::Ticket =~ /^\w+$/
$CGI::AuthRegister::SessionId =~ /^[\w.:-]+$/ $CGI::AuthRegister::Ticket =~ /^\w+$/
Truth table0%0/3
A and B
A= $CGI::AuthRegister::SessionId =~ /^[\w.:-]+$/B= $CGI::AuthRegister::Ticket =~ /^\w+$/
ABresult
0X0
100
111
509 0 { $User = $SessionId = $Ticket = ''; return; }
510  
511 # check validity of session and set user variables
512 0 my $sessioninfofile = "$DBdir/$DBsessions/$SessionId/session.info";
513 0 ▶ if (!-f $sessioninfofile) { $SessionId = $Ticket = ''; return; }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $sessioninfofile) 0 0 0
514 0 my $se = &read_db_record("file=$sessioninfofile");
515 0 ▶ if (!ref($se) or $Ticket ne $se->{'Ticket'})
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $se or $CGI::AuthRegister::Ticket ne $se->{"Ticket"}) 0 0 0
Condition0%0/3
not ref $se or $CGI::AuthRegister::Ticket ne $se->{"Ticket"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not ref $se or $CGI::AuthRegister::Ticket ne $se->{"Ticket"}
not ref $se $CGI::AuthRegister::Ticket ne $se->{"Ticket"}
Truth table0%0/3
not(A) or B
A= not ref $seB= $CGI::AuthRegister::Ticket ne $se->{"Ticket"}
ABresult
1X1
011
000
516 0 { $User = $SessionId = $Ticket = ''; return; }
517 0 $Session = $se;
518 0 $UserEmail = $se->{email}; $UserId = $se->{userid};
519 0 ▶ if ($UserEmail =~ /@/) { $User = &get_user_unique('email', $UserEmail) }
Branch: 2 branches
BranchTrueFalseTotal
if ($CGI::AuthRegister::UserEmail =~ /@/) { } 0 0 0
elsif ($CGI::AuthRegister::UserId ne '') { } 0 0 0
520 0 elsif ($UserId ne '') { $User = &get_user_unique('userid', $UserId) }
521 0 else { $Error.="435-ERR: Could not identify the user.\n"; goto E; }
522 0 ▶ if ($UserId ne '' && $User->{userid} ne $UserId) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::UserId ne "" and $CGI::AuthRegister::User->{"userid"} ne $CGI::AuthRegister::UserId) 0 0 0
Condition0%0/3
$CGI::AuthRegister::UserId ne "" and $CGI::AuthRegister::User->{"userid"} ne $CGI::AuthRegister::UserId
!ll&&!rl&&r
000
MC/DC0%0/2
$CGI::AuthRegister::UserId ne "" and $CGI::AuthRegister::User->{"userid"} ne $CGI::AuthRegister::UserId
$CGI::AuthRegister::UserId ne "" $CGI::AuthRegister::User->{"userid"} ne $CGI::AuthRegister::UserId
Truth table0%0/3
A and B
A= $CGI::AuthRegister::UserId ne ""B= $CGI::AuthRegister::User->{"userid"} ne $CGI::AuthRegister::UserId
ABresult
0X0
100
111
523 0 $Error.="437-ERR: Non-matching userid.\n"; goto E; }
524 0 ▶ if ($Error ne '') { goto E }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::Error ne "") 0 0 0
525 0 return 1;
526 E:
527 0 ▶ if ($Error ne '') { $LogReport.=$Error; &store_log; }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::Error ne "") 0 0 0
528 0 $User = $SessionId = $Ticket = ''; return;
529 }
530  
531 ########################################################################
532 # Section: User Management
533  
534 0 ▶sub register_new_user {
Subroutine register_new_user: not called CC=13 SCAR=52.0
Pod undocumented
535 0 my $reg_userid = param('reg_userid'); my $reg_email = param('reg_email');
536 0 my $reg_password = param('reg_password');
537 0 my $reg_password2 = param('reg_password2');
538 0 ▶ if ($reg_userid !~ /^(\w|[.-])+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reg_userid =~ /^(\w|[.-])+$/) 0 0 0
539 0 $Error = "Userid must consist of \w . or - characters.";
540 0 print $Error; exit; }
541 0 ▶ if (!&emailcheckok($reg_email)) { print "Invalid email."; exit; }
Branch: 1 branch
BranchTrueFalseTotal
unless (&emailcheckok($reg_email)) 0 0 0
542 0 ▶ if ($reg_password eq '') { print "Empty password."; exit; }
Branch: 1 branch
BranchTrueFalseTotal
if ($reg_password eq "") 0 0 0
543 0 ▶ if ($reg_password ne $reg_password2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reg_password ne $reg_password2) 0 0 0
544 0 print "Passwords do not match."; exit; }
545 0 my $confirmation_code = &random_string(12,'0'..'9','A'..'Z','a'..'z');
546 0 my $dbf = "$DBdir/$DBusers";
547 0 ▶ if (!-f $dbf && !&check_db_files) { print "No db file."; exit; }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $dbf or &check_db_files) 0 0 0
Condition0%0/3
-f $dbf or &check_db_files
l!l&&r!l&&!r
000
MC/DC0%0/2
-f $dbf or &check_db_files
-f $dbf &check_db_files
Truth table0%0/3
A or B
A= -f $dbfB= &check_db_files
ABresult
1X1
011
000
548 0 ▶ if (!&lock_mkdir($dbf)) { print "DB lock fail."; exit; }
Branch: 1 branch
BranchTrueFalseTotal
unless (&lock_mkdir($dbf)) 0 0 0
549 0 my $dbfc = getfile($dbf); my $db_ref = &read_db($dbfc);
550 0 ▶ if (ref($db_ref) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $db_ref ne "ARRAY") 0 0 0
551 0 print "ERR-540: Cound not read db file."; &unlock_mkdir($dbf); exit; }
552 0 my @db = @{ $db_ref };
553 0 ▶ local *fin = sub { my $url="https://$ENV{SERVER_NAME}$ENV{SCRIPT_NAME}";
Subroutine __ANON__: not called CC=1 SCAR=6.9
554 0 print "\nUser browser back button to edit data, or click ".
555 0 "<a href=\"$url\">Home</a>.\n"; &unlock_mkdir($dbf); exit; };
556 0 for my $u (@db) {
557 0 ▶ if ($u->{userid} eq $reg_userid) { print "Userid already exists."; &fin; }
Branch: 1 branch
BranchTrueFalseTotal
if ($u->{"userid"} eq $reg_userid) 0 0 0
558 0 ▶ if ($u->{email} eq $reg_email) { print "Email already exists."; &fin; }
Branch: 1 branch
BranchTrueFalseTotal
if ($u->{"email"} eq $reg_email) 0 0 0
559 }
560 0 $dbfc =~ s/\n+$/\n/s;
561 0 $dbfc.="\nuserid:$reg_userid\nemail:$reg_email\n".
562 "status:disabled, waiting for confirmation code $confirmation_code\n";
563 0 putfile($dbf,$dbfc);
564 0 &unlock_mkdir($dbf);
565 0 &password_set($reg_email,$reg_password,'md5');
566 0 ▶ if ($Error) { print "Error: $Error"; exit; }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::Error) 0 0 0
567 0 print "New user registered.\n";
568 0 print "<br>An email is being sent to confirm your email ".
569 "address...\n";
570 0 my $httpsconfirm = "https://$ENV{SERVER_NAME}$ENV{SCRIPT_NAME}?".
571 "confirmation_code=$confirmation_code";
572 0 my $msg = "Hi,\n\nPlease click or visit the following link to confirm ".
573 "your registration at the site $SiteId:\n\n".
574 "$httpsconfirm\n\nBest regards,\n$SiteId Admin\n";
575 0 &send_email_to($reg_email, "Subject: $SiteId Email Confirmation", $msg);
576 0 print "<br>Email sent. Use the sent link to confirm your email.\n";
577 }
578  
579 0 ▶sub email_confirmation {
Subroutine email_confirmation: not called CC=10 SCAR=47.0
Pod undocumented
580 0 my $confirmation_code = shift;
581 0 my $dbf = "$DBdir/$DBusers";
582 0 ▶ if (!-f $dbf && !&check_db_files) { print "No db file."; exit; }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $dbf or &check_db_files) 0 0 0
Condition0%0/3
-f $dbf or &check_db_files
l!l&&r!l&&!r
000
MC/DC0%0/2
-f $dbf or &check_db_files
-f $dbf &check_db_files
Truth table0%0/3
A or B
A= -f $dbfB= &check_db_files
ABresult
1X1
011
000
583 0 ▶ if (!&lock_mkdir($dbf)) { print "DB lock fail."; exit; }
Branch: 1 branch
BranchTrueFalseTotal
unless (&lock_mkdir($dbf)) 0 0 0
584 0 my $dbfc = getfile($dbf); my $db_ref = &read_db($dbfc);
585 0 ▶ if (ref($db_ref) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $db_ref ne "ARRAY") 0 0 0
586 0 print "ERR-540: Cound not read db file."; &unlock_mkdir($dbf); exit; }
587 0 my @db = @{ $db_ref }; my $flag = '';
588 0 for my $u (@db) {
589 0 ▶ if (defined($u->{status}) and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $u->{"status"} and $u->{"status"} =~ /^disabled, waiting for confirmation code (\S+)/ and $1 eq $confirmation_code) 0 0 0
Condition0%0/6
defined $u->{"status"} and $u->{"status"} =~ /^disabled, waiting for confirmation code (\S+)/ and $1 eq $confirmation_code
!ll&&!rl&&r
000
defined $u->{"status"} and $u->{"status"} =~ /^disabled, waiting for confirmation code (\S+)/
!ll&&!rl&&r
000
MC/DC0%0/3
defined $u->{"status"} and $u->{"status"} =~ /^disabled, waiting for confirmation code (\S+)/ and $1 eq $confirmation_code
defined $u->{"status"} $u->{"status"} =~ /^disabled, waiting for confirmation code (\S+)/ $1 eq $confirmation_code
Truth table0%0/4
A and B and C
A= defined $u->{"status"}B= $u->{"status"} =~ /^disabled, waiting for confirmation code (\S+)/C= $1 eq $confirmation_code
ABCresult
0XX0
10X0
1100
1111
590 $u->{status} =~ /^disabled, waiting for confirmation code (\S+)/ and
591 $1 eq $confirmation_code) {
592 $u->{status} =~
593 0 s/^disabled, waiting for confirmation code (\S+)/email confirmed/;
594 0 $flag = 1; last; } }
595 0 ▶ if (!$flag) { print "Invalid confirmation code.\n"; &unlock_mkdir($dbf);
Branch: 1 branch
BranchTrueFalseTotal
unless ($flag) 0 0 0
596 0 return; }
597 0 _db8_update("file=$dbf", \@db);
598 0 &unlock_mkdir($dbf);
599 0 print "Email confirmed.\n<a href=\"https://$ENV{SERVER_NAME}".
600 "$ENV{SCRIPT_NAME}\">Login page</a>\n";
601 }
602  
603 ########################################################################
604 # Section: Session Management
605  
606 # params: $email, opt: pwstore type: md5 raw
607 0 ▶sub reset_password {
Subroutine reset_password: not called CC=9 SCAR=45.0
Pod undocumented
608 0 ▶ my $email = shift; my $pwstore = shift; $pwstore = 'md5' if $pwstore eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $pwstore eq "" 0 0 0
609 0 my $password = &random_password(6); my $pwdf = "$DBdir/$DBpwd";
610 0 ▶ if (!-f $pwdf) { putfile $pwdf, ''; chmod 0600, $pwdf }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $pwdf) 0 0 0
611 0 ▶ if (!&lock_mkdir($pwdf)) { $Error.="378-ERR:\n"; return ''; }
Branch: 1 branch
BranchTrueFalseTotal
unless (&lock_mkdir($pwdf)) 0 0 0
612 0 ▶ local *PH; open(PH, $pwdf) or croak($!);
Branch: 1 branch
BranchTrueFalseTotal
open PH, $pwdf or croak($!) 0 0 0
613 0 my $content = '';
614 0 ▶ while (<PH>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline PH)) 0 0 0
615 0 my ($e,$p) = split;
616 0 ▶ $content .= $_ if $e ne $email;
Branch: 1 branch
BranchTrueFalseTotal
if $e ne $email 0 0 0
617 }
618 0 close(PH);
619 0 $content .= "$email ";
620 0 ▶ if ($pwstore eq 'raw') { $content.="raw:$password" }
Branch: 2 branches
BranchTrueFalseTotal
if ($pwstore eq 'raw') { } 0 0 0
elsif ($pwstore eq 'md5') { } 0 0 0
621 0 elsif($pwstore eq 'md5') { $content.="md5:".md5_base64($password) }
622 0 else { $content.="raw:$password" }
623 0 $content .= "\n";
624 0 putfile $pwdf, $content; chmod 0600, $pwdf; &unlock_mkdir($pwdf);
625 0 return $password;
626 }
627  
628 # $pwstoretype:md5,raw
629 0 ▶sub password_set {
Subroutine password_set: not called CC=8 SCAR=42.8
Pod undocumented
630 0 my $email = shift; my $pwd = shift; my $pwstoretype = shift;
631 0 ▶ $pwstoretype = 'md5' if $pwstoretype eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $pwstoretype eq "" 0 0 0
632 0 my $pwdf = "$DBdir/$DBpwd";
633 0 ▶ if (!&check_db_files) { $Error.="AuthERR-587:\n"; return '' }
Branch: 1 branch
BranchTrueFalseTotal
unless (&check_db_files) 0 0 0
634 0 ▶ if (!&lock_mkdir($pwdf)) { $Error.="AuthErr-588:\n"; return ''; }
Branch: 1 branch
BranchTrueFalseTotal
unless (&lock_mkdir($pwdf)) 0 0 0
635 0 ▶ local *PH; open(PH, $pwdf) or croak($!);
Branch: 1 branch
BranchTrueFalseTotal
open PH, $pwdf or croak($!) 0 0 0
636 0 my $newrow = "$email ";
637 0 ▶ if ($pwstoretype eq 'md5') { $newrow.="md5:".md5_base64($pwd)."\n" }
Branch: 1 branch
BranchTrueFalseTotal
if ($pwstoretype eq 'md5') { } 0 0 0
638 0 else { $newrow.="raw:$pwd\n" }
639 0 my $content = '';
640 0 ▶ while (<PH>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline PH)) 0 0 0
641 0 my ($e,$p) = split;
642 0 ▶ if ($e eq $email) { $content.=$newrow; $newrow=''; }
Branch: 1 branch
BranchTrueFalseTotal
if ($e eq $email) { } 0 0 0
643 0 else { $content.=$_ }
644 }
645 0 $content.=$newrow; $newrow=''; close(PH);
646 0 putfile $pwdf, $content; chmod 0600, $pwdf; &unlock_mkdir($pwdf);
647 0 return 1;
648 }
649  
650 0 ▶sub md5_base64 {
Subroutine md5_base64: not called CC=1 SCAR=6.9
Pod undocumented
651 0 my $arg=shift; require Digest::MD5; return Digest::MD5::md5_base64($arg); }
652  
653 0 ▶sub random_password {
Subroutine random_password: not called CC=2 SCAR=17.9
Pod undocumented
654 0 ▶ my $n = shift; $n = 8 unless $n > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $n > 0 0 0 0
655 0 my @chars = (2..9, 'a'..'k', 'm'..'z', 'A'..'N', 'P'..'Z',
656 qw(, . / ? ; : - = + ! @ $ % *) );
657 0 return join('', map { $chars[rand($#chars+1)] } (1..$n));
658 }
659  
660 # removes session file and return the appropriate HTTP header
661 0 ▶sub logout {
Subroutine logout: not called CC=3 SCAR=21.1
Pod undocumented
662 0 ▶ if ($Session eq '') { $Error.= "481-ERR: No session to log out\n"; return; }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::Session eq "") 0 0 0
663 0 ▶ if (!-d "$DBdir/$DBsessions/$SessionId") { $Error.="482-ERR: No session dir\n" }
Branch: 1 branch
BranchTrueFalseTotal
if (not -d "$CGI::AuthRegister::DBdir/$CGI::AuthRegister::DBsessions/$CGI::AuthRegister::SessionId") { } 0 0 0
664 else {
665 0 ▶ unlink(<$DBdir/$DBsessions/$SessionId/*>);
Subroutine BEGIN: called CC=1 SCAR=0.2
666 0 rmdir("$DBdir/$DBsessions/$SessionId"); }
667 0 $LogReport.=$Error."User UserId:$UserId UserEmail:$UserEmail logged out.\n";
668 0 &store_log; $Session = $SessionId = $Ticket = '';
669 0 return 1;
670 }
671  
672 # The first parameter can be an userid and email. (diff by @)
673 0 ▶sub login {
Subroutine login: not called CC=10 SCAR=47.0
Pod undocumented
674 0 my $email = shift; my $password = shift;
675 0 $email = lc $email; my $userid;
676 0 ▶ if ($email !~ /@/) { $userid=$email; $email=''; }
Branch: 1 branch
BranchTrueFalseTotal
unless ($email =~ /@/) 0 0 0
677 0 ▶ if ($email ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($email ne '') { } 0 0 0
678 0 ▶ if (!&emailcheckok($email)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&emailcheckok($email)) 0 0 0
679 0 $Error.="402-ERR:Incorrect email address format"; return; }
680 #my $u = &get_user_by_email($email);
681 0 my $u = &get_user_unique('email', $email);
682 0 ▶ if ($u eq '') { $Error.='405-ERR:Email not registered'; return; }
Branch: 1 branch
BranchTrueFalseTotal
if ($u eq "") 0 0 0
683 0 $userid = $u->{userid};
684 0 $User = $u;
685 } else {
686 0 ▶ if ($userid eq '') { $Error.="409-ERR:Empty userid"; return; }
Branch: 1 branch
BranchTrueFalseTotal
if ($userid eq "") 0 0 0
687 0 ▶ if ($LDAPuse and $LDAPaddUsers) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::LDAPuse and $CGI::AuthRegister::LDAPaddUsers) 0 0 0
Condition0%0/3
$CGI::AuthRegister::LDAPuse and $CGI::AuthRegister::LDAPaddUsers
!ll&&!rl&&r
000
MC/DC0%0/2
$CGI::AuthRegister::LDAPuse and $CGI::AuthRegister::LDAPaddUsers
$CGI::AuthRegister::LDAPuse $CGI::AuthRegister::LDAPaddUsers
Truth table0%0/3
A and B
A= $CGI::AuthRegister::LDAPuseB= $CGI::AuthRegister::LDAPaddUsers
ABresult
0X0
100
111
688 0 return _login_ldap_add($userid, $password); }
689 0 my $u = &get_user_unique('userid', $userid);
690 0 ▶ if ($u eq '') { $Error.='531-ERR:Not exist-unique'; &store_log; return; }
Branch: 1 branch
BranchTrueFalseTotal
if ($u eq "") 0 0 0
691 0 $email = $u->{email};
692 0 $User = $u;
693 }
694 # Randomize more salt
695 0 $SecretSalt = md5_base64("$SecretSalt $password");
696  
697 0 ▶ if (!password_check($User, $password)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (password_check($CGI::AuthRegister::User, $password)) 0 0 0
698 0 $Error.="418:Invalid password\n"; return ''; }
699  
700 0 &set_new_session($User);
701 0 $LogReport.="User $UserEmail logged in.\n"; &store_log;
702 0 return 1;
703 }
704  
705 0 ▶sub _login_ldap_add {
Subroutine _login_ldap_add: not called CC=3 SCAR=24.8
706 0 my $userid = shift; my $password = shift;
707 0 ▶ if (!&password_check_ldap($userid, $password)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&password_check_ldap($userid, $password)) 0 0 0
708 0 $Error.="570-ERR:Invalid password for LDAP\n"; return ''; }
709 0 my $u = &get_user_by_userid_or_add($userid);
710 0 ▶ if ($u eq '') { $Error.="572-ERR:\n"; &store_log; return; }
Branch: 1 branch
BranchTrueFalseTotal
if ($u eq "") 0 0 0
711 0 $User = $u;
712 # Randomize more salt
713 0 $SecretSalt = md5_base64("$SecretSalt $password");
714 0 &set_new_session($User);
715 0 $LogReport.="User userid:$userid logged in.\n"; &store_log;
716 0 return 1;
717 }
718  
719 0 ▶sub set_new_session {
Subroutine set_new_session: not called CC=12 SCAR=50.5
Pod undocumented
720 0 my $u = shift;
721 0 my $email = $u->{email};
722 0 my $userid = $u->{userid};
723 0 ▶ if ($email !~ /@/ && $userid !~ /\w/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($email =~ /@/ or $userid =~ /\w/) 0 0 0
Condition0%0/3
$email =~ /@/ or $userid =~ /\w/
l!l&&r!l&&!r
000
MC/DC0%0/2
$email =~ /@/ or $userid =~ /\w/
$email =~ /@/ $userid =~ /\w/
Truth table0%0/3
A or B
A= $email =~ /@/B= $userid =~ /\w/
ABresult
1X1
011
000
724 0 $Error .= "586-ERR: No email nor userid\n"; return ''; }
725 0 my $sDir = "$DBdir/$DBsessions";
726 0 ▶ if (!-d $sDir && !&check_db_files) { return ''; }
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $sDir or &check_db_files) 0 0 0
Condition0%0/3
-d $sDir or &check_db_files
l!l&&r!l&&!r
000
MC/DC0%0/2
-d $sDir or &check_db_files
-d $sDir &check_db_files
Truth table0%0/3
A or B
A= -d $sDirB= &check_db_files
ABresult
1X1
011
000
727  
728 0 $^T =~ /\d{6}$/; my $sessionid = 't'.$&.'_';
729 0 my $a = $userid.'_'.$email,'______';
730 0 $a =~ /.*?(\w).*?(\w).*?(\w).*?(\w).*?(\w).*?(\w)/;
731 0 $sessionid.= $1.$2.$3.$4.$5;
732 0 ▶ if (! mkdir("$sDir/$sessionid", 0700)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (mkdir "$sDir/$sessionid", 448) 0 0 0
733 0 ▶ my $cnt=1; for(;$cnt<100 and !mkdir("$sDir/${sessionid}_$cnt", 0700); ++$cnt) {}
Branch: 1 branch
BranchTrueFalseTotal
if ($cnt < 100 and not mkdir("$sDir/${sessionid}_$cnt", 448)) 0 0 0
Condition0%0/3
$cnt < 100 and not mkdir("$sDir/${sessionid}_$cnt", 448)
!ll&&!rl&&r
000
MC/DC0%0/2
$cnt < 100 and not mkdir("$sDir/${sessionid}_$cnt", 448)
$cnt < 100 not mkdir("$sDir/${sessionid}_$cnt", 448)
Truth table0%0/3
A and not(B)
A= $cnt < 100B= not mkdir("$sDir/${sessionid}_$cnt", 448)
ABresult
0X0
100
111
734 0 ▶ croak "Cannot create sessions!" if $cnt == 100;
Branch: 1 branch
BranchTrueFalseTotal
if $cnt == 100 0 0 0
735 0 $sessionid = "${sessionid}_$cnt";
736 }
737 0 $SessionId = $sessionid; $Ticket = &gen_secret;
738 0 my $sessionrecord = "SessionId:$SessionId\nTicket:$Ticket\n";
739 0 ▶ $sessionrecord.="email:$email\n" if $email ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $email ne "" 0 0 0
740 0 ▶ $sessionrecord.="userid:$userid\n" if $userid ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $userid ne "" 0 0 0
741 0 my $sessioninfofile = "$sDir/$SessionId/session.info";
742 0 putfile($sessioninfofile, $sessionrecord);
743 0 $UserEmail = $email; $UserId = $userid; $User = $u;
744 0 $Session = &read_db_record("file=$sessioninfofile");
745 0 ▶ die unless ref($Session);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $CGI::AuthRegister::Session 0 0 0
746 0 return $SessionId;
747 }
748  
749 # Return 1 if OK, '' otherwise
750 0 ▶sub password_check {
Subroutine password_check: not called CC=8 SCAR=42.8
Pod undocumented
751 0 my $u = shift; my $password = shift;
752 0 ▶ if (defined($u->{status}) and $u->{status}=~/^\s*disabled\b/)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $u->{"status"} and $u->{"status"} =~ /^\s*disabled\b/) 0 0 0
Condition0%0/3
defined $u->{"status"} and $u->{"status"} =~ /^\s*disabled\b/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $u->{"status"} and $u->{"status"} =~ /^\s*disabled\b/
defined $u->{"status"} $u->{"status"} =~ /^\s*disabled\b/
Truth table0%0/3
A and B
A= defined $u->{"status"}B= $u->{"status"} =~ /^\s*disabled\b/
ABresult
0X0
100
111
753 0 { return '' }
754 0 ▶ if ($LDAPuse) { return &password_check_ldap($u->{userid}, $password); }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::LDAPuse) 0 0 0
755 0 my $pwstored = &find_password($u->{email});
756 0 ▶ if ($pwstored =~ /^raw:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pwstored =~ /^raw:/) 0 0 0
757 0 ▶ $pwstored=$'; return ( ($pwstored eq $password) ? 1 : '' ); }
Branch: 1 branch
BranchTrueFalseTotal
$pwstored eq $password ? : 0 0 0
758 0 ▶ if ($pwstored =~ /^md5:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pwstored =~ /^md5:/) 0 0 0
759 0 ▶ $pwstored=$'; return ( ($pwstored eq md5_base64($password)) ? 1 : ''); }
Branch: 1 branch
BranchTrueFalseTotal
$pwstored eq md5_base64($password) ? : 0 0 0
760 0 $Error.="316-ERR:PWCheck error($pwstored)\n"; $ErrorInternal="AuthRegister:$Error"; return '';
761 }
762  
763 # Modifying for LDAP; Return 1 if OK, '' otherwise
764 0 ▶sub password_check_ldap {
Subroutine password_check_ldap: not called CC=7 SCAR=40.3
Pod undocumented
765 0 my $username = shift; my $password = shift;
766 0 $username =~ s/[^a-zA-Z0-9._+=-]//g;
767 0 ▶ if ($username eq '' or $LDAPserver eq '' or $LDAPdn eq '') { return '' }
Branch: 1 branch
BranchTrueFalseTotal
if ($username eq "" or $CGI::AuthRegister::LDAPserver eq "" or $CGI::AuthRegister::LDAPdn eq "") 0 0 0
Condition0%0/6
$username eq "" or $CGI::AuthRegister::LDAPserver eq "" or $CGI::AuthRegister::LDAPdn eq ""
l!l&&r!l&&!r
000
$username eq "" or $CGI::AuthRegister::LDAPserver eq ""
l!l&&r!l&&!r
000
MC/DC0%0/3
$username eq "" or $CGI::AuthRegister::LDAPserver eq "" or $CGI::AuthRegister::LDAPdn eq ""
$username eq "" $CGI::AuthRegister::LDAPserver eq "" $CGI::AuthRegister::LDAPdn eq ""
Truth table0%0/4
A or B or C
A= $username eq ""B= $CGI::AuthRegister::LDAPserver eq ""C= $CGI::AuthRegister::LDAPdn eq ""
ABCresult
1XX1
01X1
0011
0000
768 #use Net::LDAP;
769 0 eval "require Net::LDAP;";
770 0 ▶ if ($@) { $Error.="643-ERR: Net::LDAP module required for LDAP ".
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
771 0 "functionality\n"; return ''; }
772 0 my $dn = "uid=$username,$LDAPdn";
773 0 ▶ my $ldap = Net::LDAP->new("ldaps://$LDAPserver") or die "$@";
Branch: 1 branch
BranchTrueFalseTotal
my $ldap = "Net::LDAP"->new("ldaps://$CGI::AuthRegister::LDAPserver") or die "$@" 0 0 0
774 0 my $mesg = $ldap->bind($dn, password => $password);
775 0 ▶ if ($mesg->code == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mesg->code == 0) 0 0 0
776 # Password correct
777 0 $ldap->unbind; $ldap->disconnect;
778 0 return 1;
779 }
780 # else invalid password
781 0 $ldap->unbind;
782 0 $ldap->disconnect;
783 0 return '';
784 }
785  
786 0 ▶sub find_password {
Subroutine find_password: not called CC=7 SCAR=40.3
Pod undocumented
787 0 my $email = shift; my $pwfile = "$DBdir/$DBpwd";
788 0 $email = lc $email;
789 0 ▶ if (!-f $pwfile && !&check_db_files) { return '' }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $pwfile or &check_db_files) 0 0 0
Condition0%0/3
-f $pwfile or &check_db_files
l!l&&r!l&&!r
000
MC/DC0%0/2
-f $pwfile or &check_db_files
-f $pwfile &check_db_files
Truth table0%0/3
A or B
A= -f $pwfileB= &check_db_files
ABresult
1X1
011
000
790 0 ▶ if (!&lock_mkdir($pwfile)) { $Error.="431-ERR:\n"; return ''; }
Branch: 1 branch
BranchTrueFalseTotal
unless (&lock_mkdir($pwfile)) 0 0 0
791 0 ▶ local *PH; if (!open(PH,$pwfile)) { &unlock_mkdir($pwfile);
Branch: 1 branch
BranchTrueFalseTotal
unless (open PH, $pwfile) 0 0 0
792 0 $Error.="433-ERR: Cannot open ($pwfile):$!\n"; return ''; }
793 0 ▶ while (<PH>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline PH)) 0 0 0
794 0 my ($e,$p) = split; $e = lc $e;
795 0 ▶ if ($e eq $email) { close(PH); &unlock_mkdir($pwfile); return $p; }
Branch: 1 branch
BranchTrueFalseTotal
if ($e eq $email) 0 0 0
796 }
797 0 $Error.="NOTFOUND($email)";
798 0 close(PH); &unlock_mkdir($pwfile); return '';
799 }
800  
801 # Try to generate a secure random secret
802 # The best option is to use Math::Random::Secure if available
803 # This implementation uses its own additional randomization
804 0 ▶sub gen_secret {
Subroutine gen_secret: not called CC=3 SCAR=24.8
Pod undocumented
805 0 ▶ my $n = shift; $n = 10 unless $n > 0; my $ret;
Branch: 1 branch
BranchTrueFalseTotal
unless $n > 0 0 0 0
806 0 ▶ while (length($ret) < $n) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $ret < $n) 0 0 0
807 0 $SecretSalt.= md5_base64($SecretSalt.rand);
808 0 my $a=md5_base64($SecretSalt.rand); $a=~ s/[+\/]//g; $ret.=$a;
809 }
810 0 return substr($ret, 0, $n);
811 }
812  
813 1 ▶sub random_name {
Subroutine random_name: called CC=2 SCAR=7.0
Pod undocumented
814 1 ▶ my $n = shift; $n = 8 unless $n > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $n > 0 1 0 1
815 1 my @chars = (0..9, 'a'..'z', 'A'..'Z');
816 1 return join('', map { $chars[rand($#chars+1)] } (1..$n));
817 }
818  
819 0 ▶sub store_log {
Subroutine store_log: not called CC=4 SCAR=30.0
Pod undocumented
820 0 ▶ if($#_>=-1) { $LogReport.=$_[0] }
Branch: 1 branch
BranchTrueFalseTotal
if ($#_ >= -1) 0 0 0
821 0 ▶ return if $LogReport eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $CGI::AuthRegister::LogReport eq "" 0 0 0
822 0 ▶ if ($SendLogs) { &send_email_to_admin('Log entry', $LogReport); }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::SendLogs) 0 0 0
823 0 $LogReport = '';
824 }
825  
826 ########################################################################
827 # Section: Email communication
828  
829 # params: $email, opt: 'raw' or 'md5' to generate passord
830 0 ▶sub reset_and_send_email_reminder {
Subroutine reset_and_send_email_reminder: not called CC=4 SCAR=30.0
Pod undocumented
831 0 my $email = shift; my $pwstore = shift;
832 0 $email=lc $email; $email =~ s/\s/ /g;
833 0 ▶ if ($email eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($email eq "") 0 0 0
834 0 $Error.="328-ERR:No e-mail provided to send password\n"; return; }
835 0 ▶ if (!emailcheckok($email)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (emailcheckok($email)) 0 0 0
836 0 $Error.="330-ERR:Invalid e-mail address provided($email)\n"; return; }
837 0 my $user = get_user_unique('email',$email);
838 0 ▶ if ($user eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($user eq "") 0 0 0
839 0 $Error.="333-ERR: No user with email ($email)\n"; return; }
840 0 my $pw = &reset_password($email, $pwstore);
841 0 &send_email_reminder1($email, $pw);
842 0 return 1;
843 }
844  
845 # params: $email, opt: 'raw' or 'md5' to generate new password if not found
846 0 ▶sub send_email_reminder {
Subroutine send_email_reminder: not called CC=7 SCAR=40.3
Pod undocumented
847 0 my $email = shift; my $pwstore = shift;
848 0 $email=lc $email; $email =~ s/\s/ /g;
849 0 ▶ if ($email eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($email eq "") 0 0 0
850 0 $Error.="505-ERR:No e-mail provided to send password\n"; return; }
851 0 my $user;
852 0 ▶ if ($email =~ /@/) { $user = &get_user_unique('email', $email) }
Branch: 1 branch
BranchTrueFalseTotal
if ($email =~ /@/) { } 0 0 0
853 0 else { $user = &get_user_unique('userid', $email) }
854 0 ▶ if ($user eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($user eq "") 0 0 0
855 0 $Error.="510-ERR: No user with userid/email ($email)\n"; return; }
856 0 $email = $user->{email};
857 0 ▶ if (!emailcheckok($email)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (emailcheckok($email)) 0 0 0
858 0 $Error.="513-ERR:Invalid e-mail address ($email)\n"; return; }
859 0 my $pw = find_password($email);
860 0 ▶ if ($pw =~ /^raw:/) { $pw = $' }
Branch: 2 branches
BranchTrueFalseTotal
if ($pw =~ /^raw:/) { } 0 0 0
elsif ($pw ne '') { } 0 0 0
861 0 elsif ($pw ne '') { $Error.="516-ERR:Cannot retrieve password\n"; return; }
862 0 else { $pw = &reset_password($email, $pwstore) }
863  
864 0 &send_email_reminder1($email, $pw);
865 0 return 1;
866 }
867  
868 0 ▶sub send_email_reminder1 {
Subroutine send_email_reminder1: not called CC=1 SCAR=6.9
Pod undocumented
869 0 my $email = shift; my $pw = shift;
870 0 my $httpslogin = "https://$ENV{SERVER_NAME}$ENV{SCRIPT_NAME}";
871  
872 0 my $msg = "Hi,\n\nYour email and password for the $SiteId site is:\n\n".
873 "Email: $email\nPassword: $pw\n\n".
874 "You can log in at:\n\n$httpslogin\n\n\n".
875 # "$HttpsBaseLink/login.cgi\n\n\n".
876 "Best regards,\n$SiteId Admin\n";
877 0 &send_email_to($email, "Subject: $SiteId Password Reminder", $msg);
878 }
879  
880 0 ▶sub send_email_to_admin {
Subroutine send_email_to_admin: not called CC=3 SCAR=24.8
Pod undocumented
881 0 my $subject = shift; my $msg1 = shift;
882 0 $subject =~ s/\s+/ /g;
883 0 $subject = "Subject: [$SiteId System Report] $subject";
884 0 ▶ return if $Email_bcc eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $CGI::AuthRegister::Email_bcc eq "" 0 0 0
885 0 my $msg = '';
886 0 ▶ $msg.="From: $Email_from\n" unless $Email_from eq '';
Branch: 1 branch
BranchTrueFalseTotal
unless $CGI::AuthRegister::Email_from eq "" 0 0 0
887 0 $msg.="To: $Email_bcc\n";
888 0 $msg.="$subject\n\n$msg1";
889 0 &_send_email($msg);
890 }
891  
892 0 ▶sub send_email_to {
Subroutine send_email_to: not called CC=5 SCAR=34.0
Pod undocumented
893 0 ▶ my $email = shift; croak unless &emailcheckok($email);
Branch: 1 branch
BranchTrueFalseTotal
unless &emailcheckok($email) 0 0 0
894 0 my $subject = shift; $subject =~ s/[\n\r]/ /g;
895 0 ▶ if ($subject !~ /^Subject: /) { $subject = "Subject: $subject" }
Branch: 1 branch
BranchTrueFalseTotal
unless ($subject =~ /^Subject: /) 0 0 0
896 0 my $msg1 = shift;
897  
898 0 my $msg = '';
899 0 ▶ $msg.="From: $Email_from\n" unless $Email_from eq '';
Branch: 1 branch
BranchTrueFalseTotal
unless $CGI::AuthRegister::Email_from eq "" 0 0 0
900 0 $msg.="To: $email\n";
901 0 ▶ $msg.="Bcc: $Email_bcc\n" unless $Email_bcc eq '';
Branch: 1 branch
BranchTrueFalseTotal
unless $CGI::AuthRegister::Email_bcc eq "" 0 0 0
902 0 $msg.="$subject\n\n$msg1";
903 0 &_send_email($msg);
904 }
905  
906 0 ▶sub _send_email {
Subroutine _send_email: not called CC=3 SCAR=24.8
907 0 my $fullmessage = shift;
908 0 ▶ if (! -x $Sendmail) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-x $CGI::AuthRegister::Sendmail) 0 0 0
909 0 $Error.="390-ERR:No sendmail ($Sendmail)\n"; return ''; }
910 0 local *S;
911 0 ▶ if (!open(S,"|$Sendmail -ti")) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open S, "|$CGI::AuthRegister::Sendmail -ti") 0 0 0
912 0 $Error.="393-ERR:Cannot run sendmail:$!\n"; return ''; }
913 0 print S $fullmessage; close(S);
914 }
915  
916 ########################################################################
917 # Section: Data checks and transformations
918  
919 # encode string into a \w* sequence
920 0 ▶sub encode_w {
Subroutine encode_w: not called CC=1 SCAR=6.9
Pod undocumented
921 0 local $_ = shift;
922 0 s/[\Wx]/'x'.uc unpack("H2",$&)/ge;
923 0 return $_;
924 }
925  
926 0 ▶sub decode_w {
Subroutine decode_w: not called CC=1 SCAR=6.9
Pod undocumented
927 0 local $_ = shift;
928 0 s/x([0-9A-Fa-f][0-9A-Fa-f])/pack("c",hex($1))/ge;
929 0 return $_;
930 }
931  
932 0 ▶sub encodeuri($) {
Subroutine encodeuri: not called CC=1 SCAR=6.9
Pod undocumented
933 0 local $_ = shift;
934 0 s/[^-A-Za-z0-9_.~:\/?=]/"%".uc unpack("H2",$1)/ge;
935 0 return $_;
936 }
937  
938 # Prepare for HTML display by quoting meta characters.
939 0 ▶sub htmlquote($) { local $_ = shift; s/&/&amp;/g; s/</&lt;/g; return $_; }
Subroutine htmlquote: not called CC=1 SCAR=6.9
Pod undocumented
940  
941 0 ▶sub emailcheckok {
Subroutine emailcheckok: not called CC=2 SCAR=17.9
Pod undocumented
942 0 my $email = shift;
943 0 ▶ if ($email =~ /^[a-zA-Z][\w\.+-]*[a-zA-Z0-9+-]@
Branch: 1 branch
BranchTrueFalseTotal
if ($email =~ /^[a-zA-Z][\w\.+-]*[a-zA-Z0-9+-]@ [a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/x) 0 0 0
944 [a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/x)
945 0 { return 1 }
946 0 return '';
947 }
948  
949 0 ▶sub useridcheckok {
Subroutine useridcheckok: not called CC=2 SCAR=17.9
Pod undocumented
950 0 ▶ my $userid = shift; return 1 if $userid=~/^[a-zA-Z0-9-]+$/; return ''; }
Branch: 1 branch
BranchTrueFalseTotal
if $userid =~ /^[a-zA-Z0-9-]+$/ 0 0 0
951  
952 # DB related functions
953  
954 0 ▶sub read_users_db {
Subroutine read_users_db: not called CC=2 SCAR=17.9
Pod undocumented
955 0 my $f = "$DBdir/$DBusers";
956 0 ▶ if (!-f $f) { $Error.= "636-ERR: no file $f\n"; return; }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $f) 0 0 0
957 0 return &read_db("file=$f") }
958  
959 0 ▶sub _db8_find_first {
Subroutine _db8_find_first: not called CC=6 SCAR=37.4
960 0 my $dbf = shift; my $k = shift; my $v = shift;
961 0 ▶ die unless $k =~ /^k=/; $k = $';
Branch: 1 branch
BranchTrueFalseTotal
unless $k =~ /^k=/ 0 0 0
962 0 my $db_ref = &read_db("file=$dbf");
963 0 ▶ if (ref($db_ref) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $db_ref ne "ARRAY") 0 0 0
964 0 $Error.="745-ERR: Could not read db file ($dbf)"; return ''; }
965 0 my @db = @{ $db_ref };
966 0 for my $r (@db) {
967 0 ▶ if (exists($r->{$k}) && $v eq $r->{$k}) { $Error.="FOUND\n"; return $r } }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $r->{$k} and $v eq $r->{$k}) 0 0 0
Condition0%0/3
exists $r->{$k} and $v eq $r->{$k}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $r->{$k} and $v eq $r->{$k}
exists $r->{$k} $v eq $r->{$k}
Truth table0%0/3
A and B
A= exists $r->{$k}B= $v eq $r->{$k}
ABresult
0X0
100
111
968 0 return '';
969 }
970  
971 0 ▶sub get_user {
Subroutine get_user: not called CC=5 SCAR=34.0
Pod undocumented
972 0 my $k = shift; my $v = shift;
973 0 my $db_ref = &read_users_db;
974 0 ▶ if (ref($db_ref) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $db_ref ne "ARRAY") 0 0 0
975 0 $Error.="AuthERR-836: Could not get users data (file system problem?)\n";
976 0 return $User='';
977 }
978 0 my @db = @{ $db_ref };
979 0 for my $r (@db)
980 0 ▶ { if (exists($r->{$k}) && $v eq $r->{$k}) { return $User=$r } }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $r->{$k} and $v eq $r->{$k}) 0 0 0
Condition0%0/3
exists $r->{$k} and $v eq $r->{$k}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $r->{$k} and $v eq $r->{$k}
exists $r->{$k} $v eq $r->{$k}
Truth table0%0/3
A and B
A= exists $r->{$k}B= $v eq $r->{$k}
ABresult
0X0
100
111
981 0 $Error.="AuthERR-842: no user with key=($k) v=($v)\n"; return $User='';
982 }
983  
984 0 ▶sub get_user_by_email {
Subroutine get_user_by_email: not called CC=4 SCAR=30.0
Pod undocumented
985 0 my $email = shift;
986 0 my $db_ref = &read_users_db;
987 0 ▶ if (ref($db_ref) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $db_ref ne "ARRAY") 0 0 0
988 0 $Error.="657-ERR: Could not get users data (file system problem?)";
989 0 return $User=''; }
990 0 my @db = @{ $db_ref };
991 0 ▶ for my $r (@db) { if (lc($email) eq lc($r->{email})) { return $User=$r } }
Branch: 1 branch
BranchTrueFalseTotal
if (lc $email eq lc $r->{"email"}) 0 0 0
992 0 $Error.="661-ERR: no user with email ($email)\n"; return $User='';
993 }
994  
995 0 ▶sub get_user_by_userid { return &get_user('userid', $_[0]) }
Subroutine get_user_by_userid: not called CC=1 SCAR=6.9
Pod undocumented
996  
997 # Get user by userid, or add userid if does not exist
998 0 ▶sub get_user_by_userid_or_add {
Subroutine get_user_by_userid_or_add: not called CC=8 SCAR=42.8
Pod undocumented
999 0 my $userid = shift; my $f = "$DBdir/$DBusers";
1000 0 ▶ if (!-f $f && !&check_db_files) { return '' }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $f or &check_db_files) 0 0 0
Condition0%0/3
-f $f or &check_db_files
l!l&&r!l&&!r
000
MC/DC0%0/2
-f $f or &check_db_files
-f $f &check_db_files
Truth table0%0/3
A or B
A= -f $fB= &check_db_files
ABresult
1X1
011
000
1001 0 my @db = @{ &read_db("file=$f") };
1002 0 my $u = '';
1003 0 for my $r (@db) {
1004 0 ▶ next unless exists($r->{userid}); my $v1 = $r->{userid};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $r->{"userid"} 0 0 0
1005 0 $v1=~s/^\s+//; $v1=~s/\s+$//; $v1=~s/\s+/ /g; $v1 = lc $v1;
1006 0 ▶ next unless $v1 eq $userid;
Branch: 1 branch
BranchTrueFalseTotal
unless $v1 eq $userid 0 0 0
1007 0 ▶ if ($u eq '') { $u = $r; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($u eq "") 0 0 0
1008 0 $Error.= "819-ERR: double userid ($userid)\n"; return '';
1009 }
1010 0 ▶ return $User=$u unless $u eq '';
Branch: 1 branch
BranchTrueFalseTotal
unless $u eq "" 0 0 0
1011 0 $userid =~ s/\s//g; &_db8_append($f, "userid:$userid");
1012 0 return get_user_by_userid($userid);
1013 }
1014  
1015 # Get user by a key,value, but make sure there is exactly one such user
1016 # Normalizes whitespace and case insensitive
1017 0 ▶sub get_user_unique {
Subroutine get_user_unique: not called CC=10 SCAR=47.0
Pod undocumented
1018 0 my $k = shift; my $v = shift; my $f = "$DBdir/$DBusers";
1019 0 ▶ if (!-f $f && !&check_db_files) { return '' }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $f or &check_db_files) 0 0 0
Condition0%0/3
-f $f or &check_db_files
l!l&&r!l&&!r
000
MC/DC0%0/2
-f $f or &check_db_files
-f $f &check_db_files
Truth table0%0/3
A or B
A= -f $fB= &check_db_files
ABresult
1X1
011
000
1020 0 my @db = @{ &read_db("file=$f") };
1021 0 $v=~s/^\s+//; $v=~s/\s+$//; $v=~s/\s+/ /g; $v = lc $v;
1022 0 ▶ if ($k eq '' or $v eq '')
Branch: 1 branch
BranchTrueFalseTotal
if ($k eq "" or $v eq "") 0 0 0
Condition0%0/3
$k eq "" or $v eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
$k eq "" or $v eq ""
$k eq "" $v eq ""
Truth table0%0/3
A or B
A= $k eq ""B= $v eq ""
ABresult
1X1
011
000
1023 0 { $Error.="669-ERR:Empty k or v ($k:$v)\n"; return ''; }
1024 0 my $u = '';
1025 0 for my $r (@db) {
1026 0 ▶ next unless exists($r->{$k}); my $v1 = $r->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $r->{$k} 0 0 0
1027 0 $v1=~s/^\s+//; $v1=~s/\s+$//; $v1=~s/\s+/ /g; $v1 = lc $v1;
1028 0 ▶ next unless $v eq $v1;
Branch: 1 branch
BranchTrueFalseTotal
unless $v eq $v1 0 0 0
1029 0 ▶ if ($u eq '') { $u = $r; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($u eq "") 0 0 0
1030 0 $Error.= "676-ERR: double user key ($k:$v)\n"; return '';
1031 }
1032 0 ▶ return $User=$u unless $u eq '';
Branch: 1 branch
BranchTrueFalseTotal
unless $u eq "" 0 0 0
1033 0 $Error.="894-ERR: no user with key ($k:$v)\n"; return '';
1034 }
1035  
1036 0 ▶sub check_db_files {
Subroutine check_db_files: not called CC=9 SCAR=45.0
Pod undocumented
1037 0 my $ret; my $pwfile = "$DBdir/$DBpwd";
1038 0 ▶ if (!-d $DBdir) { $ret = mkdir($DBdir, 0700);
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $CGI::AuthRegister::DBdir) 0 0 0
1039 0 ▶ if (!$ret) { $Error.="687-ERR: Could not create dir '$DBdir'"; return ''; }}
Branch: 1 branch
BranchTrueFalseTotal
unless ($ret) 0 0 0
1040 0 ▶ if (!-f $pwfile) { putfile $pwfile, ''; chmod 0600, $pwfile; }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $pwfile) 0 0 0
1041 0 ▶ if (!-f $pwfile) { $Error.="689-ERR: Could not create $pwfile file";
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $pwfile) 0 0 0
1042 0 return ''; }
1043 0 my $f = "$DBdir/$DBusers";
1044 0 ▶ if (!-f $f) { putfile $f, "#userid:someid\n#email:email\@domain.com\n";
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $f) 0 0 0
1045 0 chmod 0600, $f; }
1046 0 ▶ if (!-f $f) { $Error.="694-ERR: Could not create $f file"; return ''; }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $f) 0 0 0
1047 0 $f = "$DBdir/$DBsessions";
1048 0 ▶ if (!-d $f) { $ret = mkdir($f, 0700);
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $f) 0 0 0
1049 0 ▶ if (!$ret) { $Error.="708-ERR: Could not create dir '$f'"; return ''; }}
Branch: 1 branch
BranchTrueFalseTotal
unless ($ret) 0 0 0
1050  
1051 0 return 1;
1052 }
1053  
1054 # _db8_update - updates given db with minimal changes
1055 # Usage: db8_update($strOrFile, $db)
1056 # 2013-2017 Vlado Keselj, version 1.4; documentation in DB822.txt
1057 # Example: &db8_update("file=$filename", $db);
1058 0 ▶sub _db8_update {
Subroutine _db8_update: not called CC=23 SCAR=63.1
1059 0 my $arg = shift; my $db=shift; my $file='';
1060 0 ▶ if ($arg =~ /^file=/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /^file=/) 0 0 0
1061 0 ▶ $file = $'; die "file=''!?" if $file eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $file eq "" 0 0 0
1062 0 ▶ local *F; open(F, $file) or die "cannot open $file:$!";
Branch: 1 branch
BranchTrueFalseTotal
open F, $file or die "cannot open ${file}:$!" 0 0 0
1063 0 $arg = join('', <F>);
1064 0 close(F);
1065 }
1066
1067 0 my $arg_save = $arg; my $dbi = 0; my $argcopy = '';
1068 0 ▶ while ($arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg) 0 0 0
1069 # allow comments and space betwen records
1070 0 ▶ if ($arg =~ /^(\s*\n|[ \t]*#.*\n)*/) { $argcopy.=$&; $arg = $'; }
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /^(\s*\n|[ \t]*#.*\n)*/) 0 0 0
1071 0 my $record;
1072 0 ▶ if ($arg =~ /\n(\n+)/) { $record = "$`\n"; $arg = $1.$'; }
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /\n(\n+)/) { } 0 0 0
1073 0 else { $record = $arg; $arg = ''; }
1074 0 ▶ if ($dbi > $#{$db}) { last }
Branch: 1 branch
BranchTrueFalseTotal
if ($dbi > $#{$db;}) 0 0 0
1075 0 my $r = {}; my %savedkeys = ();
1076 0 ▶ while ($record) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record) 0 0 0
1077 0 my $avpair = '';
1078 0 ▶ if ($record =~ /^.*/) { $avpair = $& }
Branch: 1 branch
BranchTrueFalseTotal
if ($record =~ /^.*/) 0 0 0
1079 0 ▶ while ($record =~ /^(.*)(\\\n|\n[ \t]+)(.*)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($record =~ /^(.*)(\\\n|\n[ \t]+)(.*)/) 0 0 0
1080 0 { $record = "$1 $3$'"; $avpair.= $2.$3; }
1081 0 ▶ $record =~ /^([^\n:]*):(.*)\n/ or die;
Branch: 1 branch
BranchTrueFalseTotal
$record =~ /^([^\n:]*):(.*)\n/ or die 0 0 0
1082 0 my $k = $1; my $v = $2; $record = $';
1083 0 $avpair .= "\n";
1084 0 ▶ if (exists($r->{$k})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $r->{$k}) 0 0 0
1085 0 my $c = 0;
1086 0 ▶ while (exists($r->{"$k-$c"})) { ++$c }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$r{"$k-$c"}) 0 0 0
1087 0 $k = "$k-$c";
1088 }
1089 0 $r->{$k} = $v;
1090 0 ▶ if (exists($db->[$dbi]->{$k}) && $db->[$dbi]->{$k} eq $v)
Branch: 2 branches
BranchTrueFalseTotal
if (exists $db->[$dbi]{$k} and $db->[$dbi]{$k} eq $v) { } 0 0 0
elsif (exists $db->[$dbi]{$k}) { } 0 0 0
Condition0%0/3
exists $db->[$dbi]{$k} and $db->[$dbi]{$k} eq $v
!ll&&!rl&&r
000
MC/DC0%0/2
exists $db->[$dbi]{$k} and $db->[$dbi]{$k} eq $v
exists $db->[$dbi]{$k} $db->[$dbi]{$k} eq $v
Truth table0%0/3
A and B
A= exists $db->[$dbi]{$k}B= $db->[$dbi]{$k} eq $v
ABresult
0X0
100
111
1091 0 { $argcopy .= $avpair }
1092 elsif (exists($db->[$dbi]->{$k})) {
1093 0 my $newv = $db->[$dbi]->{$k}; $newv =~ s/\s/ /g; #to be improved
1094 0 $argcopy .= "$k:$newv\n";
1095 } # else skip it
1096 0 $savedkeys{$k} = 1;
1097 }
1098 0 for my $k (keys %{ $db->[$dbi] }) {
1099 0 ▶ if (!exists($savedkeys{$k})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $savedkeys{$k}) 0 0 0
1100 0 my $newv = $db->[$dbi]->{$k}; $newv =~ s/\s/ /g; #to be improved
1101 0 $argcopy .= "$k:$newv\n";
1102 }
1103 }
1104 0 ++$dbi;
1105 }
1106  
1107 0 ▶ while ($dbi <= $#{$db}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dbi <= $#{$db;}) 0 0 0
1108 0 $argcopy .= "\n";
1109 0 for my $k (sort(keys(%{ $db->[$dbi] }))) {
1110 0 my $newv = $db->[$dbi]->{$k}; $newv =~ s/\s/ /g; #to be improved
1111 0 $argcopy .= "$k:$newv\n";
1112 }
1113 0 ++$dbi;
1114 }
1115  
1116 0 ▶ if ($file ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($file ne '') { } 0 0 0
1117 0 ▶ if ($argcopy ne $arg_save) {
Branch: 1 branch
BranchTrueFalseTotal
if ($argcopy ne $arg_save) 0 0 0
1118 #rename($file, "$file.bak");
1119 0 local *F; open(F,">$file"); print F $argcopy; close(F);
1120 }
1121 0 return;
1122 0 } else { return $argcopy }
1123 } # end of _db8_update
1124  
1125 0 ▶sub _db8_remove {
Subroutine _db8_remove: not called CC=18 SCAR=58.3
1126 0 my $dbf = shift; my $kdel = shift; my $vdel = shift;
1127 0 ▶ die unless $kdel =~ /^k=/; $kdel = $';
Branch: 1 branch
BranchTrueFalseTotal
unless $kdel =~ /^k=/ 0 0 0
1128 0 ▶ if (!&lock_mkdir($dbf)) { $Error.="793-ERR"; return '' }
Branch: 1 branch
BranchTrueFalseTotal
unless (&lock_mkdir($dbf)) 0 0 0
1129 0 ▶ local *F; if (!open(F, $dbf)) { &unlock_mkdir($dbf);
Branch: 1 branch
BranchTrueFalseTotal
unless (open F, $dbf) 0 0 0
1130 0 $Error.="795-ERR: opening file $dbf: $!"; return ''; }
1131 0 my $arg = join('',<F>); close(F);
1132  
1133 0 my $arg_save = $arg; my $dbi = 0; my $argcopy = '';
1134 0 ▶ while ($arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg) 0 0 0
1135 0 my $prologue;
1136 0 ▶ if ($arg =~ /^([ \t\r]*(#.*)?\n)+/) { $prologue = $&; $arg = $'; }
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /^([ \t\r]*(#.*)?\n)+/) 0 0 0
1137 0 $argcopy.=$prologue;
1138 0 ▶ last if $arg eq ''; my $record; my $record_save;
Branch: 1 branch
BranchTrueFalseTotal
if $arg eq "" 0 0 0
1139 0 ▶ if ($arg =~ /([ \t\r]*\n){2,}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /([ \t\r]*\n){2,}/) { } 0 0 0
1140 0 $record = "$`\n"; $arg = $'; $record_save = "$`$&"; }
1141 0 else { $record_save = $record = $arg; $arg = ''; }
1142 0 my $r = {};
1143 0 ▶ while ($record) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record) 0 0 0
1144 0 ▶ $record =~ /^[ \t]*([^\n:]*?)[ \t]*:/ or die "db8: no attribute";
Branch: 1 branch
BranchTrueFalseTotal
$record =~ /^[ \t]*([^\n:]*?)[ \t]*:/ or die "db8: no attribute" 0 0 0
1145 0 my $k = $1; $record = $';
1146 0 ▶ while ($record =~ /^(.*)(\\\r?\n|\r?\n[ \t]+)(\S.*)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($record =~ /^(.*)(\\\r?\n|\r?\n[ \t]+)(\S.*)/) 0 0 0
1147 0 { $record = "$1 $3$'" }
1148 0 ▶ $record =~ /^[ \t]*(.*?)[ \t\r]*\n/ or die;
Branch: 1 branch
BranchTrueFalseTotal
$record =~ /^[ \t]*(.*?)[ \t\r]*\n/ or die 0 0 0
1149 0 my $v = $1; $record = $';
1150 0 ▶ if (exists($r->{$k})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $r->{$k}) 0 0 0
1151 0 my $c = 0;
1152 0 ▶ while (exists($r->{"$k-$c"})) { ++$c }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$r{"$k-$c"}) 0 0 0
1153 0 $k = "$k-$c";
1154 }
1155 0 $r->{$k} = $v;
1156 }
1157 0 ▶ if (exists($r->{$kdel}) && $r->{$kdel} eq $vdel) {}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $r->{$kdel} and $r->{$kdel} eq $vdel) { } 0 0 0
Condition0%0/3
exists $r->{$kdel} and $r->{$kdel} eq $vdel
!ll&&!rl&&r
000
MC/DC0%0/2
exists $r->{$kdel} and $r->{$kdel} eq $vdel
exists $r->{$kdel} $r->{$kdel} eq $vdel
Truth table0%0/3
A and B
A= exists $r->{$kdel}B= $r->{$kdel} eq $vdel
ABresult
0X0
100
111
1158 0 else { $argcopy .= $record_save }
1159 }
1160  
1161 0 ▶ if ($argcopy ne $arg_save) {
Branch: 1 branch
BranchTrueFalseTotal
if ($argcopy ne $arg_save) 0 0 0
1162 0 ▶ if (!open(F, ">$dbf.lock/new")) { &unlock_mkdir($dbf);
Branch: 1 branch
BranchTrueFalseTotal
unless (open F, ">$dbf.lock/new") 0 0 0
1163 0 $Error.="828-ERR: opening file $dbf.lock/new: $!"; return ''; }
1164 0 print F $argcopy; close(F); chmod 0600, "$dbf.lock/new"; unlink($dbf);
1165 0 rename("$dbf.lock/new", $dbf); }
1166 0 &unlock_mkdir($dbf);
1167 } # end of _db8_remove
1168  
1169 # Read DB records in the RFC822-like style (to add reference).
1170 0 ▶sub read_db {
Subroutine read_db: not called CC=12 SCAR=50.5
Pod undocumented
1171 0 my $arg = shift;
1172 0 ▶ if ($arg =~ /^file=/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /^file=/) 0 0 0
1173 0 ▶ my $f = $'; if (!&lock_mkdir($f)) { return '' }
Branch: 1 branch
BranchTrueFalseTotal
unless (&lock_mkdir($f)) 0 0 0
1174 0 local *F;
1175 0 ▶ if (!open(F, $f)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open F, $f) 0 0 0
1176 0 $Error.="ERR-945: $f: $!"; &unlock_mkdir($f); return ''; }
1177 0 $arg = join('', <F>); close(F); &unlock_mkdir($f);
1178 }
1179  
1180 0 my $db = [];
1181 0 ▶ while ($arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg) 0 0 0
1182 0 $arg =~ s/^\s*(#.*\s*)*//; # allow comments betwen records
1183 0 my $record;
1184 0 ▶ if ($arg =~ /\n\n+/) { $record = "$`\n"; $arg = $'; }
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /\n\n+/) { } 0 0 0
1185 0 else { $record = $arg; $arg = ''; }
1186 0 my $r = {};
1187 0 ▶ while ($record) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record) 0 0 0
1188 0 ▶ if ($record =~ /^#.*\n?/) { $record=$'; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($record =~ /^#.*\n?/) 0 0 0
1189 0 ▶ while ($record =~ /^(.*)(\\\n|\n[ \t]+)(.*)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($record =~ /^(.*)(\\\n|\n[ \t]+)(.*)/) 0 0 0
1190 0 { $record = "$1 $3$'" }
1191 0 ▶ $record =~ /^([^\n:]*):(.*)\n/ or die;
Branch: 1 branch
BranchTrueFalseTotal
$record =~ /^([^\n:]*):(.*)\n/ or die 0 0 0
1192 0 my $k = $1; my $v = $2; $record = $';
1193 0 ▶ if (exists($r->{$k})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $r->{$k}) 0 0 0
1194 0 my $c = 0;
1195 0 ▶ while (exists($r->{"$k-$c"})) { ++$c }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$r{"$k-$c"}) 0 0 0
1196 0 $k = "$k-$c";
1197 }
1198 0 $r->{$k} = $v;
1199 }
1200 0 push @{ $db }, $r;
1201 }
1202 0 return $db;
1203 }
1204  
1205 # Append a record or records to db8
1206 # Assumes that the file is in a good format
1207 0 ▶sub _db8_append {
Subroutine _db8_append: not called CC=4 SCAR=30.0
1208 0 my $fdb=shift;
1209 0 ▶ if (!&lock_mkdir($fdb)) { $Error.="ERR-975: $!"; return '' }
Branch: 1 branch
BranchTrueFalseTotal
unless (&lock_mkdir($fdb)) 0 0 0
1210 0 ▶ local *F; if (!open(F, ">>$fdb")) { &unlock_mkdir($fdb);
Branch: 1 branch
BranchTrueFalseTotal
unless (open F, ">>$fdb") 0 0 0
1211 0 $Error.="ERR-977: write file $fdb: $!"; return ''; }
1212 0 ▶ while (@_) { my $r=shift; $r =~ s/\s*$/\n/s; print F "\n$r"; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
1213 0 &unlock_mkdir($fdb);
1214 }
1215  
1216 # Read one DB record in the RFC822-like style (to add reference).
1217 0 ▶sub read_db_record {
Subroutine read_db_record: not called CC=10 SCAR=47.0
Pod undocumented
1218 0 my $arg = shift;
1219 0 ▶ if ($arg =~ /^file=/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /^file=/) 0 0 0
1220 0 ▶ my $f = $'; local *F; open(F, $f) or die "cannot open $f:$!";
Branch: 1 branch
BranchTrueFalseTotal
open F, $f or die "cannot open ${f}:$!" 0 0 0
1221 0 $arg = join('', <F>); close(F);
1222 }
1223  
1224 0 ▶ while ($arg =~ s/^(\s*|\s*#.*)\n//) {} # allow comments before record
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ s/^(\s*|\s*#.*)\n//) 0 0 0
1225 0 my $record;
1226 0 ▶ if ($arg =~ /\n\n+/) { $record = "$`\n"; $arg = $'; }
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /\n\n+/) { } 0 0 0
1227 0 else { $record = $arg; $arg = ''; }
1228 0 my $r = {};
1229 0 ▶ while ($record) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record) 0 0 0
1230 0 ▶ while ($record =~ /^(.*)(\\\n|\n[ \t]+)(.*)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($record =~ /^(.*)(\\\n|\n[ \t]+)(.*)/) 0 0 0
1231 0 { $record = "$1 $3$'" }
1232 0 ▶ $record =~ /^([^\n:]*):(.*)\n/ or die;
Branch: 1 branch
BranchTrueFalseTotal
$record =~ /^([^\n:]*):(.*)\n/ or die 0 0 0
1233 0 my $k = $1; my $v = $2; $record = $';
1234 0 ▶ if (exists($r->{$k})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $r->{$k}) 0 0 0
1235 0 my $c = 0;
1236 0 ▶ while (exists($r->{"$k-$c"})) { ++$c }
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$r{"$k-$c"}) 0 0 0
1237 0 $k = "$k-$c";
1238 }
1239 0 $r->{$k} = $v;
1240 }
1241 0 return $r;
1242 }
1243  
1244 # parameters: $n - sequence length; @_ domain elements
1245 0 ▶sub random_string {
Subroutine random_string: not called CC=2 SCAR=17.9
Pod undocumented
1246 0 my $n = shift;
1247 0 ▶ return '' if $n < 1;
Branch: 1 branch
BranchTrueFalseTotal
if $n < 1 0 0 0
1248 0 my @r = map { $_[rand($#_+1)] } (1..$n);
1249 0 return join('',@r);
1250 }
1251  
1252 0 ▶sub putfile($@) {
Subroutine putfile: not called CC=3 SCAR=24.8
Pod undocumented
1253 0 my $f = shift; local *F;
1254 0 ▶ if (!open(F, ">$f")) { $Error.="325-ERR:Cannot write ($f):$!\n"; return; }
Branch: 1 branch
BranchTrueFalseTotal
unless (open F, ">$f") 0 0 0
1255 0 for (@_) { print F } close(F);
1256 }
1257  
1258 0 ▶sub getfile($) {
Subroutine getfile: not called CC=3 SCAR=24.8
Pod undocumented
1259 0 my $f = shift; local *F;
1260 0 ▶ if (!open(F, "<$f")) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open F, "<$f") 0 0 0
1261 0 $Error.="ERR-1099:getfile:cannot open $f:$!"; return; }
1262 0 my @r = <F>; close(F);
1263 0 ▶ return wantarray ? @r : join ('', @r);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1264 }
1265  
1266 ########################################################################
1267 # Section: Simple file locking using mkdir
1268  
1269 # Exlusive locking using mkdir
1270 # lock_mkdir($fname); # return 1=success ''=fail
1271 0 ▶sub lock_mkdir {
Subroutine lock_mkdir: not called CC=6 SCAR=37.4
Pod undocumented
1272 0 my $fname = shift; my $lockd = "$fname.lock"; my $locked;
1273 # First, hopefully most usual case
1274 0 ▶ if (!-e $lockd && ($locked = mkdir($lockd,0700))) { return $locked }
Branch: 1 branch
BranchTrueFalseTotal
if (not -e $lockd and $locked = mkdir($lockd, 448)) 0 0 0
Condition0%0/3
not -e $lockd and $locked = mkdir($lockd, 448)
!ll&&!rl&&r
000
MC/DC0%0/2
not -e $lockd and $locked = mkdir($lockd, 448)
not -e $lockd $locked = mkdir($lockd, 448)
Truth table0%0/3
not(A) and B
A= not -e $lockdB= $locked = mkdir($lockd, 448)
ABresult
0X0
100
111
1275 0 my $tryfor=10; #sec
1276 0 $locked = ''; # flag
1277 0 ▶ for (my $i=0; $i<2*$tryfor; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 2 * $tryfor) 0 0 0
1278 0 select(undef,undef,undef,0.5); # wait for 0.5 sec
1279 0 ▶ !-e $lockd && ($locked = mkdir($lockd,0700));
Branch: 1 branch
BranchTrueFalseTotal
-e $lockd or $locked = mkdir($lockd, 448) 0 0 0
1280 0 ▶ if ($locked) { return $locked }
Branch: 1 branch
BranchTrueFalseTotal
if ($locked) 0 0 0
1281 }
1282 0 $Error.="393-ERR:Could not lock file ($fname)\n"; return $locked;
1283 }
1284  
1285 # Unlock using mkdir
1286 # unlock_mkdir($fname); # return 1=success ''=fail or no lock
1287 0 ▶sub unlock_mkdir {
Subroutine unlock_mkdir: not called CC=5 SCAR=34.0
Pod undocumented
1288 0 my $fname = shift; my $lockd = "$fname.lock";
1289 0 ▶ if (!-e $lockd) { $Error.="400-ERR:No lock on ($fname)\n"; return '' }
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $lockd) 0 0 0
1290 0 ▶ if (-d $lockd) { return rmdir($lockd) }
Branch: 1 branch
BranchTrueFalseTotal
if (-d $lockd) 0 0 0
1291 0 ▶ if (-f $lockd or -l $lockd) { unlink($lockd) }
Branch: 1 branch
BranchTrueFalseTotal
if (-f $lockd or -l $lockd) 0 0 0
Condition0%0/3
-f $lockd or -l $lockd
l!l&&r!l&&!r
000
MC/DC0%0/2
-f $lockd or -l $lockd
-f $lockd -l $lockd
Truth table0%0/3
A or B
A= -f $lockdB= -l $lockd
ABresult
1X1
011
000
1292 0 $Error.="AuthERR-1279:Unknown error"; return '';
1293 }
1294  
1295 ########################################################################
1296 # Section: Prepackaged HTML and CSS files
1297  
1298 0 ▶sub gen_cas_page {
Subroutine gen_cas_page: not called CC=7 SCAR=40.3
Pod undocumented
1299 0 my $ret;
1300 #<? my $c = getfile('cas-template/cas.html');
1301 # echo "\$ret=<<'EOT';\n${c}EOT"; !>#+
1302 0 $ret=<<'EOT';
1303 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
1304 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1305 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
1306 <head><title>CAS - Central Authentication Service</title>
1307 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
1308 <meta name="Description" content="CAS - Central Authentication Service">
1309 <meta name="viewport" content="width=device-width">
1310 <link rel="stylesheet" href="cas-all.css" type="text/css" media="screen">
1311 <link rel="stylesheet" href="cas-mobile.css"
1312 media="handheld, only screen and (max-device-width: 480px)" type="text/css">
1313  
1314 <script type="text/javascript" language="javascript">
1315 // <![CDATA[
1316 function searchFocus(){document.getElementById('username').focus();}
1317 // ]]>
1318 </script>
1319  
1320 <style type="text/css">
1321 /* <![CDATA[ */
1322 .formInput { float: left; }
1323 /* ]]> */
1324 </style>
1325 </head>
1326  
1327 <body onload="searchFocus();">
1328 <div id="pagebox"> <div id="headerBox">
1329 <h1>CAS <span class="hideInMobile">&ndash; Central Authentication
1330 </span>Service</h1></div>
1331  
1332 <div id="content"><div id="content-left">
1333  
1334 <form id="login_form" action="?login" method="post">
1335 <table id="form-layout" cellspacing="0" cellpadding="5" border="0">
1336 <tbody><tr><td width="" valign="top" align="left">&nbsp;</td>
1337 <td width="" valign="top" align="left">
1338 <h1><!--37-->Login Required
1339 </h1><p class="sans"><!--38-->CAS Authentication
1340 </p></td></tr>
1341  
1342 <!--!username--><tr><td width="" valign="top" align="left">
1343 <p class="formLabel">UserID:</p></td>
1344 <td width="" valign="top" align="left">
1345 <input id="username" name="username" class="formInput" tabindex="1"
1346 size="20" autocomplete="off" type="text">
1347 </td></tr>
1348  
1349 <!--!password-->
1350 <tr><td width="" valign="top" align="left">
1351 <p class="formLabel">Password:</p></td>
1352 <td width="" valign="top" align="left">
1353 <input id="password" name="password" class="formInput" tabindex="2"
1354 value="" size="20" autocomplete="off" type="password">
1355 </td></tr>
1356  
1357 <tr><td width="" valign="top" align="left">&nbsp;</td>
1358 <td width="" valign="top" align="left">
1359 <!--!hiddenfields-->
1360 <input class="inputButton" value="Login" type="submit"
1361 name="request_type"></td></tr>
1362  
1363 <tr class="hideInMobile"><td width="" valign="top" align="left">
1364 &nbsp;</td><td width="" valign="top" align="left">
1365 <h2>Please note</h2><p class="sans"><!--60-->
1366 Before entering your userid and password, verify that the URL
1367 for this page begins with:
1368 <strong>_THIS_URL_</strong></p>
1369 <p class="sans">
1370 To protect your privacy, quit your web browser when you
1371 are done accessing services that require authentication.
1372 </p></td></tr>
1373 <!--/lastrow-->
1374 </tbody></table>
1375 </form></div>
1376  
1377 <div id="content-right">
1378 <ul class="plain">
1379 <!--!#forgot <li><a href="?rt=forgotpwd" target="_blank">Forgot your password?</a></li>-->
1380 <!--!# <li class="disabled">CAS Login</li>-->
1381 <!--!#logout <li><a href="?logout">CAS Logout</a></li>-->
1382 <!--!# <li><a href="?help">Help with CAS</a></li>-->
1383 <!--!# <li><span class="hideInMobile">-->
1384 <!--!# <a href="?feeback" target="_blank">Feedback</a></span></li>-->
1385 </ul>
1386  
1387 <span class="hideInMobile">
1388 <ul class="plain-serif"><li>
1389 <!--!# <a href="?forgotpwd" target="_blank">Forgot your password?</a></li>-->
1390 <!--!# <li><a href="?changepwd" target="_blank">Changing your password</a></li>-->
1391 </ul>
1392 </span><!--/hideInMobile-->
1393  
1394 </div><!--content-right-->
1395 <div style="clear:both;"></div></div></div>
1396 </body></html>
1397 EOT#-
1398 #+
1399 $ret=<<'EOT';
1400 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
1401 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1402 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
1403 <head><title>CAS - Central Authentication Service</title>
1404 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
1405 <meta name="Description" content="CAS - Central Authentication Service">
1406 <meta name="viewport" content="width=device-width">
1407 <link rel="stylesheet" href="cas-all.css" type="text/css" media="screen">
1408 <link rel="stylesheet" href="cas-mobile.css"
1409 media="handheld, only screen and (max-device-width: 480px)" type="text/css">
1410  
1411 <script type="text/javascript" language="javascript">
1412 // <![CDATA[
1413 function searchFocus(){document.getElementById('username').focus();}
1414 // ]]>
1415 </script>
1416  
1417 <style type="text/css">
1418 /* <![CDATA[ */
1419 .formInput { float: left; }
1420 /* ]]> */
1421 </style>
1422 </head>
1423  
1424 <body onload="searchFocus();">
1425 <div id="pagebox"> <div id="headerBox">
1426 <h1>CAS <span class="hideInMobile">&ndash; Central Authentication
1427 </span>Service</h1></div>
1428  
1429 <div id="content"><div id="content-left">
1430  
1431 <form id="login_form" action="?login" method="post">
1432 <table id="form-layout" cellspacing="0" cellpadding="5" border="0">
1433 <tbody><tr><td width="" valign="top" align="left">&nbsp;</td>
1434 <td width="" valign="top" align="left">
1435 <h1><!--37-->Login Required
1436 </h1><p class="sans"><!--38-->CAS Authentication
1437 </p></td></tr>
1438  
1439 <!--!username--><tr><td width="" valign="top" align="left">
1440 <p class="formLabel">UserID:</p></td>
1441 <td width="" valign="top" align="left">
1442 <input id="username" name="username" class="formInput" tabindex="1"
1443 size="20" autocomplete="off" type="text">
1444 </td></tr>
1445  
1446 <!--!password-->
1447 <tr><td width="" valign="top" align="left">
1448 <p class="formLabel">Password:</p></td>
1449 <td width="" valign="top" align="left">
1450 <input id="password" name="password" class="formInput" tabindex="2"
1451 value="" size="20" autocomplete="off" type="password">
1452 </td></tr>
1453  
1454 <tr><td width="" valign="top" align="left">&nbsp;</td>
1455 <td width="" valign="top" align="left">
1456 <!--!hiddenfields-->
1457 <input class="inputButton" value="Login" type="submit"
1458 name="request_type"></td></tr>
1459  
1460 <tr class="hideInMobile"><td width="" valign="top" align="left">
1461 &nbsp;</td><td width="" valign="top" align="left">
1462 <h2>Please note</h2><p class="sans"><!--60-->
1463 Before entering your userid and password, verify that the URL
1464 for this page begins with:
1465 <strong>_THIS_URL_</strong></p>
1466 <p class="sans">
1467 To protect your privacy, quit your web browser when you
1468 are done accessing services that require authentication.
1469 </p></td></tr>
1470 <!--/lastrow-->
1471 </tbody></table>
1472 </form></div>
1473  
1474 <div id="content-right">
1475 <ul class="plain">
1476 <!--!#forgot <li><a href="?rt=forgotpwd" target="_blank">Forgot your password?</a></li>-->
1477 <!--!# <li class="disabled">CAS Login</li>-->
1478 <!--!#logout <li><a href="?logout">CAS Logout</a></li>-->
1479 <!--!# <li><a href="?help">Help with CAS</a></li>-->
1480 <!--!# <li><span class="hideInMobile">-->
1481 <!--!# <a href="?feeback" target="_blank">Feedback</a></span></li>-->
1482 </ul>
1483  
1484 <span class="hideInMobile">
1485 <ul class="plain-serif"><li>
1486 <!--!# <a href="?forgotpwd" target="_blank">Forgot your password?</a></li>-->
1487 <!--!# <li><a href="?changepwd" target="_blank">Changing your password</a></li>-->
1488 </ul>
1489 </span><!--/hideInMobile-->
1490  
1491 </div><!--content-right-->
1492 <div style="clear:both;"></div></div></div>
1493 </body></html>
1494 EOT
1495 #-
1496 0 ▶ if ($GenCasPageCustom ne '') { $ret = $GenCasPageCustom }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::GenCasPageCustom ne "") 0 0 0
1497
1498 0 my $cssCasAll = $ENV{SCRIPT_NAME}.'?cas-all.css';
1499 0 my $cssCasMobile = $ENV{SCRIPT_NAME}.'?cas-mobile.css';
1500 0 $ret=~ s/href="cas-all.css"/href="$cssCasAll"/;
1501 0 $ret=~ s/href="cas-mobile.css"/href="$cssCasMobile"/;
1502  
1503 0 my $redirect_uri;
1504 0 ▶ if (param('redirect_uri') ne '') { $redirect_uri = param('redirect_uri') }
Branch: 2 branches
BranchTrueFalseTotal
if (param('redirect_uri') ne '') { } 0 0 0
elsif (param('r') ne '') { } 0 0 0
1505 0 elsif (param('r') ne '') { $redirect_uri = param('r') }
1506
1507 # Remove "Before entering" unless there is a URL to show (todo, for now,
1508 # just remove)
1509 0 $ret=~ s/<!--60-->.*?(<\/p>)/$1/s;
1510  
1511 0 my $forgotpassword = 1; # include link, todo for exclusion
1512 0 my $removerighthandside = 1;
1513 0 ▶ if ($forgotpassword) {
Branch: 1 branch
BranchTrueFalseTotal
if ($forgotpassword) 0 0 0
1514 0 $removerighthandside=''; $ret=~s/<!--!#forgot (.*?)-->/$1/g; }
1515 0 ▶ if ($SessionId ne '') { $ret=~s/<!--!#logout (.*?)-->/$1/g; }
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::AuthRegister::SessionId ne "") 0 0 0
1516
1517 0 $ret=~s/<!--!#.*?-->//g;
1518  
1519 # Remove righthand side
1520 0 ▶ if($removerighthandside) {
Branch: 1 branch
BranchTrueFalseTotal
if ($removerighthandside) { } 0 0 0
1521 0 $ret =~
1522 s/(<div id="content-right">)(.*?)(<\/div><!--content-right-->)/$1$3/s;
1523 }
1524 else { # remove "hideinMobile"
1525 0 $ret =~ s/<span class="hideInMobile".*?<!--\/hideInMobile-->//; }
1526
1527 0 return $ret;
1528 }
1529  
1530 0 ▶sub deliver {
Subroutine deliver: not called CC=3 SCAR=24.8
Pod undocumented
1531 0 my $par = shift;
1532 0 ▶ if ($par eq 'cas-all.css') {
Branch: 2 branches
BranchTrueFalseTotal
if ($par eq 'cas-all.css') { } 0 0 0
elsif ($par eq 'cas-mobile.css') { } 0 0 0
1533 0 print "Content-Type: text/css; charset=UTF-8\n\n".
1534 #<? my $c = getfile('cas-template/cas-all.css');
1535 # echo "<<'EOT';\n${c}EOT\n;"; !>#+
1536 <<'EOT';
1537 body {
1538 background-color: #D1AF55; /*#76A9DC;*/
1539 color: #444;
1540 font-family: "Times New Roman", Times, serif;
1541 margin: 30px;
1542 padding: 5px;
1543 }
1544  
1545 a:link { text-decoration: none; }
1546 a:visited { text-decoration: none; }
1547 a:active { text-decoration: none; }
1548 a:hover { text-decoration: underline; }
1549 .hide { display: none; }
1550  
1551 .shadow {
1552 box-shadow: 5px 5px 5px #ccc;
1553 -moz-box-shadow: 5px 5px 5px #ccc;
1554 -webkit-box-shadow: 5px 5px 5px #ccc;
1555 }
1556  
1557 #pagebox {
1558 background: #fff;
1559 border: 1px solid #000;
1560 box-shadow: 10px 10px 10px #444;
1561 -moz-box-shadow: 10px 10px 10px #444;
1562 -webkit-box-shadow: 10px 10px 20px #444;
1563 margin: 0px auto;
1564 width: 788px;
1565 height: 491px;
1566 }
1567  
1568 #headerBox {
1569 background: #A17F25;
1570 border-bottom: 1px solid #916F15;
1571 border-left: 1px solid #916F15;
1572 border-right: 1px solid #916F15;
1573 border-top: 1px solid #916F15;
1574 clear: both;
1575 height: 82px;
1576 width: 786px;
1577 text-align:center;
1578 color: #ffffff;
1579 }
1580  
1581 #content-left {
1582 background: #fff;
1583 border-right: 1px solid #0F4D92;
1584 clear: both;
1585 float: left;
1586 height: 377px;
1587 margin: 0px;
1588 padding: 15px;
1589 width: 530px;
1590 }
1591  
1592 #content-right {
1593 background: #fafae8;
1594 border: 0px;
1595 float: right;
1596 height: 377px;
1597 margin: 0px;
1598 padding: 15px;
1599 width: 197px;
1600 }
1601  
1602 #content-left h1 {
1603 font-family: "Times New Roman", Times, serif;
1604 font-size: 20px;
1605 font-weight: normal;
1606 margin: 0px 0px 5px 0px;
1607 }
1608  
1609 #content-left h2 {
1610 font-family: "Times New Roman", Times, serif;
1611 font-size: 20px;
1612 font-weight: normal;
1613 margin: 5px 0px 5px 0px;
1614 }
1615  
1616 #content-left p.formLabel {
1617 color: #5F5F5F;
1618 font-family: "Times New Roman", Times, serif;
1619 font-size: 16px;
1620 font-weight: normal;
1621 margin: 6px 0px 0px 0px;
1622 text-align: right;
1623 }
1624
1625 #content-left p.sans {
1626 color: #5F5F5F;
1627 font-family: Verdana, Arial, Helvetica, sans;
1628 font-size: 11px;
1629 font-weight: normal;
1630 line-height: 1.7em;
1631 margin: 5px 0px 5px 0px;
1632 }
1633
1634 #content-left p.sansURL {
1635 color: #4e6d98;
1636 font-family: Verdana, Arial, Helvetica, sans;
1637 font-size: 11px;
1638 font-weight: normal;
1639 line-height: 1em;
1640 margin: 15px 0px 5px 0px;
1641 }
1642  
1643 #content ul.plain, ul.plain a {
1644 color: #1A3E6F;
1645 font-family: Verdana, Geneva, Arial, sans-serif;
1646 font-size: 14px;
1647 line-height: 1.5em;
1648 list-style: none;
1649 margin: .4em 0em .2em 0em;
1650 padding: 0em 0em 0em 0em;
1651 text-indent: 0em;
1652 }
1653
1654 #content ul.plain li, ul.plain li a {
1655 padding-bottom: 0.8em;
1656 }
1657
1658 #content ul.plain li.disabled {
1659 color: #bbb;
1660 }
1661
1662
1663 #content ul.plain-serif, ul.plain-serif a {
1664 color: #1A3E6F;
1665 font-family: "Times New Roman", Times, serif;
1666 font-size: 14px;
1667 line-height: 1.2em;
1668 list-style: none;
1669 margin: 30px 0px 0px 0px;
1670 padding: 0px 0px 0px 0px;
1671 text-indent: 0em;
1672 }
1673
1674 #content ul.plain-serif li, ul.plain-serif li a {
1675 padding-bottom: 0.8em;
1676 }
1677
1678 #content ol {
1679 font-family: Verdana, Arial, Helvetica, sans;
1680 font-size: 11px;
1681 font-weight: normal;
1682 line-height: 1.8em;
1683 margin: 0px 0px 0px 20px;
1684 padding: 0px 0px 0px 0px;
1685 text-indent: 0em;
1686 }
1687
1688 #content ol li, ol li a { padding-bottom: 0.8em; }
1689 EOT
1690 ;#-
1691 #+
1692 0 <<'EOT';
1693 body {
1694 background-color: #D1AF55; /*#76A9DC;*/
1695 color: #444;
1696 font-family: "Times New Roman", Times, serif;
1697 margin: 30px;
1698 padding: 5px;
1699 }
1700  
1701 a:link { text-decoration: none; }
1702 a:visited { text-decoration: none; }
1703 a:active { text-decoration: none; }
1704 a:hover { text-decoration: underline; }
1705 .hide { display: none; }
1706  
1707 .shadow {
1708 box-shadow: 5px 5px 5px #ccc;
1709 -moz-box-shadow: 5px 5px 5px #ccc;
1710 -webkit-box-shadow: 5px 5px 5px #ccc;
1711 }
1712  
1713 #pagebox {
1714 background: #fff;
1715 border: 1px solid #000;
1716 box-shadow: 10px 10px 10px #444;
1717 -moz-box-shadow: 10px 10px 10px #444;
1718 -webkit-box-shadow: 10px 10px 20px #444;
1719 margin: 0px auto;
1720 width: 788px;
1721 height: 491px;
1722 }
1723  
1724 #headerBox {
1725 background: #A17F25;
1726 border-bottom: 1px solid #916F15;
1727 border-left: 1px solid #916F15;
1728 border-right: 1px solid #916F15;
1729 border-top: 1px solid #916F15;
1730 clear: both;
1731 height: 82px;
1732 width: 786px;
1733 text-align:center;
1734 color: #ffffff;
1735 }
1736  
1737 #content-left {
1738 background: #fff;
1739 border-right: 1px solid #0F4D92;
1740 clear: both;
1741 float: left;
1742 height: 377px;
1743 margin: 0px;
1744 padding: 15px;
1745 width: 530px;
1746 }
1747  
1748 #content-right {
1749 background: #fafae8;
1750 border: 0px;
1751 float: right;
1752 height: 377px;
1753 margin: 0px;
1754 padding: 15px;
1755 width: 197px;
1756 }
1757  
1758 #content-left h1 {
1759 font-family: "Times New Roman", Times, serif;
1760 font-size: 20px;
1761 font-weight: normal;
1762 margin: 0px 0px 5px 0px;
1763 }
1764  
1765 #content-left h2 {
1766 font-family: "Times New Roman", Times, serif;
1767 font-size: 20px;
1768 font-weight: normal;
1769 margin: 5px 0px 5px 0px;
1770 }
1771  
1772 #content-left p.formLabel {
1773 color: #5F5F5F;
1774 font-family: "Times New Roman", Times, serif;
1775 font-size: 16px;
1776 font-weight: normal;
1777 margin: 6px 0px 0px 0px;
1778 text-align: right;
1779 }
1780
1781 #content-left p.sans {
1782 color: #5F5F5F;
1783 font-family: Verdana, Arial, Helvetica, sans;
1784 font-size: 11px;
1785 font-weight: normal;
1786 line-height: 1.7em;
1787 margin: 5px 0px 5px 0px;
1788 }
1789
1790 #content-left p.sansURL {
1791 color: #4e6d98;
1792 font-family: Verdana, Arial, Helvetica, sans;
1793 font-size: 11px;
1794 font-weight: normal;
1795 line-height: 1em;
1796 margin: 15px 0px 5px 0px;
1797 }
1798  
1799 #content ul.plain, ul.plain a {
1800 color: #1A3E6F;
1801 font-family: Verdana, Geneva, Arial, sans-serif;
1802 font-size: 14px;
1803 line-height: 1.5em;
1804 list-style: none;
1805 margin: .4em 0em .2em 0em;
1806 padding: 0em 0em 0em 0em;
1807 text-indent: 0em;
1808 }
1809
1810 #content ul.plain li, ul.plain li a {
1811 padding-bottom: 0.8em;
1812 }
1813
1814 #content ul.plain li.disabled {
1815 color: #bbb;
1816 }
1817
1818
1819 #content ul.plain-serif, ul.plain-serif a {
1820 color: #1A3E6F;
1821 font-family: "Times New Roman", Times, serif;
1822 font-size: 14px;
1823 line-height: 1.2em;
1824 list-style: none;
1825 margin: 30px 0px 0px 0px;
1826 padding: 0px 0px 0px 0px;
1827 text-indent: 0em;
1828 }
1829
1830 #content ul.plain-serif li, ul.plain-serif li a {
1831 padding-bottom: 0.8em;
1832 }
1833
1834 #content ol {
1835 font-family: Verdana, Arial, Helvetica, sans;
1836 font-size: 11px;
1837 font-weight: normal;
1838 line-height: 1.8em;
1839 margin: 0px 0px 0px 20px;
1840 padding: 0px 0px 0px 0px;
1841 text-indent: 0em;
1842 }
1843
1844 #content ol li, ol li a { padding-bottom: 0.8em; }
1845 EOT
1846 ;
1847 #-
1848 }
1849 elsif ($par eq 'cas-mobile.css') {
1850 0 print "Content-Type: text/css; charset=UTF-8\n\n".
1851 #<? my $c = getfile('cas-template/cas-mobile.css');
1852 # echo "<<'EOT';\n${c}EOT\n;"; !>#+
1853 <<'EOT';
1854 body {
1855 background-color: #fff;
1856 color: #444;
1857 font-family: "Times New Roman", Times, serif;
1858 margin: 0px;
1859 padding: 0px;
1860 }
1861  
1862 a:link { text-decoration: none; }
1863 a:visited { text-decoration: none; }
1864 a:active { text-decoration: none; }
1865 a:hover { text-decoration: underline; }
1866 .hide { display: none; }
1867 .hideInMobile { display: none; }
1868  
1869 #pagebox {
1870 border: 0px;
1871 background: #fff;
1872 margin: 0px;
1873 width: auto;
1874 height: auto;
1875 box-shadow: none;
1876 -moz-box-shadow: none;
1877 -webkit-box-shadow: none;
1878 }
1879
1880 #headerBox {
1881 border: 0px;
1882 background: #A17F25;
1883 overflow: hidden;
1884 width: auto;
1885 height: auto;
1886 }
1887  
1888 #headerBox h1 { font-size: 14pt; }
1889  
1890 #content-left {
1891 background: #fff;
1892 border: 0px;
1893 margin: 0px;
1894 padding: 15px;
1895 width: auto;
1896 height: auto;
1897 float: none;
1898 }
1899
1900 #content-right {
1901 background: #fff;
1902 border: 0px;
1903 width: auto;
1904 height: auto;
1905 float: none;
1906 margin-left: 85px;
1907 }
1908  
1909 #form-layout { width: auto; }
1910  
1911 #login_form input {
1912 background: #f8f8f8;
1913 border: 1px solid #aaa;
1914 color: #555;
1915 font-family: Verdana, Arial, Helvetica, sans;
1916 font-weight: normal;
1917 margin: 0px 0px 0px 0px;
1918 font-size: 16px;
1919 padding: 5px;
1920 }
1921
1922 #login_form input.inputButton {
1923 background: #F5F091;
1924 border: 1px solid #aaa;
1925 color: #555;
1926 font-family: Georgia, "Times New Roman", Times, serif;
1927 font-weight: normal;
1928 margin: 10px 0px 10px 0px;
1929 font-size: 18px;
1930 }
1931  
1932 #login_form input.formInput {
1933 width: 170px;
1934 float: none;
1935 }
1936  
1937 h1.mobileTitle { display: none; }
1938
1939 #content-left h1 {
1940 color: #883F0A;
1941 font-family: Georgia, "Times New Roman", Times, serif;
1942 font-weight: bold;
1943 margin: 0px 0px 5px 0px;
1944 font-size: 19px;
1945 }
1946
1947 #content-left h2 { display: none; }
1948 #content-left p.sans { display: none; }
1949 #content-left p.sansURL { display: none; }
1950 #content-left p.mobile-tight { margin: 0; }
1951  
1952 #content ul.plain, ul.plain a {
1953 color: #1A3E6F;
1954 font-family: Verdana, Geneva, Arial, sans-serif;
1955 line-height: 1.3em;
1956 list-style: none;
1957 margin: .4em 0em .2em 0em;
1958 padding: 0em 0em 0em 0em;
1959 text-indent: 0em;
1960 font-size: 14px;
1961 }
1962
1963 #content ul.plain li, ul.plain li a {
1964 padding-bottom: 0.8em;
1965 }
1966
1967 #content ul.plain li.disabled {
1968 color: #bbb;
1969 }
1970  
1971 #content ul.plain-serif, ul.plain-serif a {
1972 display: none;
1973 }
1974
1975 #content ul.plain-serif li, ul.plain-serif li a {
1976 padding-bottom: 0.8em;
1977 }
1978
1979 #content ol {
1980 color: #5F5F5F;
1981 font-family: Verdana, Arial, Helvetica, sans;
1982 font-size: 11px;
1983 font-weight: normal;
1984 line-height: 1.8em;
1985 margin: 0px 0px 0px 20px;
1986 padding: 0px 0px 0px 0px;
1987 text-indent: 0em;
1988 }
1989  
1990 #content ol li, ol li a {
1991 padding-bottom: 0.8em;
1992 }
1993 EOT
1994 ;#-
1995 #+
1996 0 <<'EOT';
1997 body {
1998 background-color: #fff;
1999 color: #444;
2000 font-family: "Times New Roman", Times, serif;
2001 margin: 0px;
2002 padding: 0px;
2003 }
2004  
2005 a:link { text-decoration: none; }
2006 a:visited { text-decoration: none; }
2007 a:active { text-decoration: none; }
2008 a:hover { text-decoration: underline; }
2009 .hide { display: none; }
2010 .hideInMobile { display: none; }
2011  
2012 #pagebox {
2013 border: 0px;
2014 background: #fff;
2015 margin: 0px;
2016 width: auto;
2017 height: auto;
2018 box-shadow: none;
2019 -moz-box-shadow: none;
2020 -webkit-box-shadow: none;
2021 }
2022
2023 #headerBox {
2024 border: 0px;
2025 background: #A17F25;
2026 overflow: hidden;
2027 width: auto;
2028 height: auto;
2029 }
2030  
2031 #headerBox h1 { font-size: 14pt; }
2032  
2033 #content-left {
2034 background: #fff;
2035 border: 0px;
2036 margin: 0px;
2037 padding: 15px;
2038 width: auto;
2039 height: auto;
2040 float: none;
2041 }
2042
2043 #content-right {
2044 background: #fff;
2045 border: 0px;
2046 width: auto;
2047 height: auto;
2048 float: none;
2049 margin-left: 85px;
2050 }
2051  
2052 #form-layout { width: auto; }
2053  
2054 #login_form input {
2055 background: #f8f8f8;
2056 border: 1px solid #aaa;
2057 color: #555;
2058 font-family: Verdana, Arial, Helvetica, sans;
2059 font-weight: normal;
2060 margin: 0px 0px 0px 0px;
2061 font-size: 16px;
2062 padding: 5px;
2063 }
2064
2065 #login_form input.inputButton {
2066 background: #F5F091;
2067 border: 1px solid #aaa;
2068 color: #555;
2069 font-family: Georgia, "Times New Roman", Times, serif;
2070 font-weight: normal;
2071 margin: 10px 0px 10px 0px;
2072 font-size: 18px;
2073 }
2074  
2075 #login_form input.formInput {
2076 width: 170px;
2077 float: none;
2078 }
2079  
2080 h1.mobileTitle { display: none; }
2081
2082 #content-left h1 {
2083 color: #883F0A;
2084 font-family: Georgia, "Times New Roman", Times, serif;
2085 font-weight: bold;
2086 margin: 0px 0px 5px 0px;
2087 font-size: 19px;
2088 }
2089
2090 #content-left h2 { display: none; }
2091 #content-left p.sans { display: none; }
2092 #content-left p.sansURL { display: none; }
2093 #content-left p.mobile-tight { margin: 0; }
2094  
2095 #content ul.plain, ul.plain a {
2096 color: #1A3E6F;
2097 font-family: Verdana, Geneva, Arial, sans-serif;
2098 line-height: 1.3em;
2099 list-style: none;
2100 margin: .4em 0em .2em 0em;
2101 padding: 0em 0em 0em 0em;
2102 text-indent: 0em;
2103 font-size: 14px;
2104 }
2105
2106 #content ul.plain li, ul.plain li a {
2107 padding-bottom: 0.8em;
2108 }
2109
2110 #content ul.plain li.disabled {
2111 color: #bbb;
2112 }
2113  
2114 #content ul.plain-serif, ul.plain-serif a {
2115 display: none;
2116 }
2117
2118 #content ul.plain-serif li, ul.plain-serif li a {
2119 padding-bottom: 0.8em;
2120 }
2121
2122 #content ol {
2123 color: #5F5F5F;
2124 font-family: Verdana, Arial, Helvetica, sans;
2125 font-size: 11px;
2126 font-weight: normal;
2127 line-height: 1.8em;
2128 margin: 0px 0px 0px 20px;
2129 padding: 0px 0px 0px 0px;
2130 text-indent: 0em;
2131 }
2132  
2133 #content ol li, ol li a {
2134 padding-bottom: 0.8em;
2135 }
2136 EOT
2137 ;
2138 #-
2139  
2140 }
2141 0 exit;
2142 } # end of sub deliver
2143  
2144 ########################################################################
2145 # Section: Debug Functions
2146  
2147 0 ▶sub _dbg383 { return unless $DebugLevel > 5;
Subroutine _dbg383: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
unless $CGI::AuthRegister::DebugLevel > 5 0 0 0
2148 0 $LogReport.="CAS client: Verification successful.\n"; &store_log; }
2149  
2150 ########################################################################
2151 # Section: End of code; Documentation
2152  
2153 1 1;
2154  
2155 __END__
↑ Summary