projects
/
mirror
/
userdir-ldap-cgi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove code duplication
[mirror/userdir-ldap-cgi.git]
/
Util.pm
diff --git
a/Util.pm
b/Util.pm
index
7f19694
..
2b230ab
100644
(file)
--- a/
Util.pm
+++ b/
Util.pm
@@
-7,7
+7,7
@@
package Util;
use strict;
use Date::Manip qw(ParseDate);
use strict;
use Date::Manip qw(ParseDate);
-use Net::LDAP qw(
:all
);
+use Net::LDAP qw(
LDAP_SUCCESS LDAP_PROTOCOL_ERROR
);
use English;
my $blocksize = 8; # A blowfish block is 8 bytes
use English;
my $blocksize = 8; # A blowfish block is 8 bytes
@@
-34,12
+34,16
@@
sub CreateKey {
sub CreateCryptSalt {
# this can create either a DES type salt or a MD5 salt
sub CreateCryptSalt {
# this can create either a DES type salt or a MD5 salt
- my $md5 = shift; # do we want a MD5 salt?
+ # 0 for DES, 1 for MD5 salt and 2 for apache MD5 salt
+ my $type = shift;
my $validstr = './0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
my @valid = split(//,$validstr);
my ($in, $out);
my $validstr = './0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
my @valid = split(//,$validstr);
my ($in, $out);
- my $cryptsaltlen = ($md5 ? 8 : 2);
+ my $cryptsaltlen = 2;
+ if (($type == 1)||($type == 2)) {
+ $cryptsaltlen = 8;
+ }
open (F, "</dev/urandom") || die &HTMLError("No /dev/urandom found!");
foreach (1..$cryptsaltlen) {
open (F, "</dev/urandom") || die &HTMLError("No /dev/urandom found!");
foreach (1..$cryptsaltlen) {
@@
-47,7
+51,9
@@
sub CreateCryptSalt {
$out .= $valid[ord($in) % ($#valid + 1)];
}
close F;
$out .= $valid[ord($in) % ($#valid + 1)];
}
close F;
- return ($md5 ? "\$1\$$out\$" : $out);
+ my $md5 = $out;
+ if ($type == 1) { $md5 = "\$1\$$out\$"; }
+ return $md5
}
sub Encrypt {
}
sub Encrypt {
@@
-228,16
+234,21
@@
sub FormatLastSeen {
my ($d1, $d2, $lastseen);
return "<b>No activity detected</b>" if (!$lastseenpgp && !$lastseenfrom);
my ($d1, $d2, $lastseen);
return "<b>No activity detected</b>" if (!$lastseenpgp && !$lastseenfrom);
+ $lastseen = $lastseenpgp;
$lastseen = $lastseenfrom if (!$lastseenpgp);
if ($lastseenfrom && $lastseenpgp) {
$lastseen = $lastseenfrom if (!$lastseenpgp);
if ($lastseenfrom && $lastseenpgp) {
- ($d1) = ($lastseenpgp =~ /^\[(.+?)\]/); $d1 = ParseDate($d1);
+ ($d1) = ($lastseenpgp =~ /^\[(.+?)\]/); $d1 = ParseDate($d1);
($d2) = ($lastseenfrom =~ /^\[(.+?)\]/); $d2 = ParseDate($d2);
$lastseen = (($d1 gt $d2) ? $lastseenpgp : $lastseenfrom);
}
($d2) = ($lastseenfrom =~ /^\[(.+?)\]/); $d2 = ParseDate($d2);
$lastseen = (($d1 gt $d2) ? $lastseenpgp : $lastseenfrom);
}
- my ($date,$user,$list,$msgid) = ($lastseen =~ /^\[(.+?)\]\s+"(.+?)"\s+"(?:<(.+?)>.*?|\-)"\s+"
<(.+?)>
"/);
+ my ($date,$user,$list,$msgid) = ($lastseen =~ /^\[(.+?)\]\s+"(.+?)"\s+"(?:<(.+?)>.*?|\-)"\s+"
(<.+?>)
"/);
$list = "on $list" if ($list);
$list = "on $list" if ($list);
+ $date = CGI::escapeHTML($date);
+ $user = CGI::escapeHTML($user);
+ $list = CGI::escapeHTML($list);
+ $msgid = CGI::escapeHTML($msgid);
return "$date $list<br> Message ID: $msgid";
}
return "$date $list<br> Message ID: $msgid";
}
@@
-354,7
+365,7
@@
sub UpgradeConnection($) {
$mesg->sync;
if ($mesg->code != LDAP_SUCCESS) {
print "Content-type: text/html; charset=utf-8\n\n";
$mesg->sync;
if ($mesg->code != LDAP_SUCCESS) {
print "Content-type: text/html; charset=utf-8\n\n";
- print "<html><body><h1>STARTTLS failed: ".
.
$mesg->error."</h1></body></html>\n";
+ print "<html><body><h1>STARTTLS failed: ".$mesg->error."</h1></body></html>\n";
exit(1);
};
};
exit(1);
};
};