X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=Util.pm;h=3a9841683dcd24cdb33446345f604698c776b373;hb=b0f8e57cce2bf0ab7a693ffac1ab1cc62f59b13c;hp=87ace99b36a35c5dc2eb81a7ee0a26c0f2a61062;hpb=a6e38208b7538082ebb16db9fb3d4093daa9702b;p=mirror%2Fuserdir-ldap-cgi.git
diff --git a/Util.pm b/Util.pm
index 87ace99..3a98416 100644
--- a/Util.pm
+++ b/Util.pm
@@ -1,8 +1,14 @@
# -*- perl -*-x
+
+# Copyright (c) 1999-2006 Debian Admin Team Members and Developers (taken from debian/copyright in 2008 by weasel)
+# Copyright (c) 2002, 2003, 2004, 2008 Peter Palfrader
+
package Util;
use strict;
use Date::Manip qw(ParseDate);
+use Net::LDAP qw(LDAP_SUCCESS LDAP_PROTOCOL_ERROR);
+use English;
my $blocksize = 8; # A blowfish block is 8 bytes
my $configfile = "/etc/userdir-ldap/userdir-ldap.conf";
@@ -27,21 +33,26 @@ sub CreateKey {
}
sub CreateCryptSalt {
+ # CreateCryptSalt(type = 0, skip_header = 0)
# this can create either a DES type salt or a MD5 salt
+ # 0 for DES, 1 for MD5 salt
+ # if skip_header is 0, does not add $1$ for md5 salts.
my $md5 = shift; # do we want a MD5 salt?
+ my $no_crypttype_header = shift;
my $validstr = './0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
my @valid = split(//,$validstr);
my ($in, $out);
-
+
my $cryptsaltlen = ($md5 ? 8 : 2);
-
+
open (F, "No activity detected" if (!$lastseenpgp && !$lastseenfrom);
+ $lastseen = $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);
}
- my ($date,$user,$list,$msgid) = ($lastseen =~ /^\[(.+?)\]\s+"(.+?)"\s+"(?:<(.+?)>.*?|\-)"\s+"<(.+?)>"/);
+ my ($date,$user,$list,$msgid) = ($lastseen =~ /^\[(.+?)\]\s+"(.+?)"\s+"(?:<(.+?)>.*?|\-)"\s+"(<.+?>)"/);
$list = "on $list" if ($list);
+ $date = CGI::escapeHTML($date);
+ $user = CGI::escapeHTML($user);
+ $list = CGI::escapeHTML($list);
+ $msgid = CGI::escapeHTML($msgid);
return "$date $list
Message ID: $msgid";
}
@@ -256,7 +273,7 @@ sub LookupCountry {
my $htmlhdrsent = 0;
sub HTMLSendHeader {
- print "Content-type: text/html\n\n" if (!$htmlhdrsent);
+ print "Content-type: text/html; charset=utf-8\n\n" if (!$htmlhdrsent);
$htmlhdrsent = 1;
}
@@ -325,7 +342,8 @@ sub ReadConfigFile {
if ((!/^\s*#/) && ($_ ne "")) {
# Chop off any trailing comments
s/#.*//;
- ($attr, $setting) = split(/=/, $_, 2);
+ /([^=]+)=(.*)/;
+ ($attr, $setting) = ($1, $2);
$setting =~ s/"//g; #"
$setting =~ s/;$//;
$attr =~ s/^\s+//; $attr =~ s/\s+$//;
@@ -337,4 +355,138 @@ sub ReadConfigFile {
return %config;
}
+sub UpgradeConnection($) {
+ my ($ldap) = @_;
+ my $mesg = $ldap->start_tls(
+ verify => 'require',
+ # Cannot specify the server cert, must specify the CA cert
+ #cafile => '/etc/ssl/servicecerts/db.debian.org.crt'
+ #cafile => '/etc/ssl/certs/UTN_USERFirst_Hardware_Root_CA.pem'
+ cafile => '/usr/share/ca-certificates/mozilla/AddTrust_External_Root.crt'
+ );
+ $mesg->sync;
+ if ($mesg->code != LDAP_SUCCESS) {
+ print "Content-type: text/html; charset=utf-8\n\n";
+ print "