X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap-cgi.git;a=blobdiff_plain;f=update.cgi;h=5a59a3436be62c5bf7605b42668c977bab6ca954;hp=de3932a30579a37d8f12823e2b6ab15032fe7520;hb=315098762d694e291a67049a1f7fe73b929ed64b;hpb=2639ca03902bc809d5e024926a3eab910eb5f18a diff --git a/update.cgi b/update.cgi index de3932a..5a59a34 100755 --- a/update.cgi +++ b/update.cgi @@ -8,12 +8,13 @@ use lib '.'; use strict vars; #use Apache::Registry; use CGI; -use UUID; +use Data::UUID; use Digest::HMAC_SHA1 qw(hmac_sha1_hex); use Util; use English; use URI::Escape; -use Net::LDAP qw(:all); +use Crypt::PasswdMD5; +use Net::LDAP qw(LDAP_SUCCESS LDAP_PROTOCOL_ERROR); my %config = &Util::ReadConfigFile; @@ -41,7 +42,7 @@ sub DieHandler { $ldap->unbind if (defined($ldap)); } -$SIG{__DIE__} = \&DieHandler; +#$SIG{__DIE__} = \&DieHandler; $ldap = Net::LDAP->new($config{ldaphost}); &Util::UpgradeConnection($ldap) unless $config{usessl} eq 'False'; @@ -82,8 +83,9 @@ if (!($query->param('doupdate'))) { # First do the easy stuff - this catches most of the cases foreach (keys(%$entry)) { $data{$_} = $entry->{$_}->[0]; + $data{$_} = CGI::escapeHTML($data{$_}) if defined $data{$_}; } - + $data{gender} = 9 if not $data{gender}; # Now we have to fill in the rest that needs some processing... @@ -92,6 +94,7 @@ if (!($query->param('doupdate'))) { $data{editdn} = $editdn; $data{staddress} = $entry->{postaladdress}->[0]; $data{staddress} =~ s/\$/\n/; + $data{staddress} = CGI::escapeHTML($data{staddress}); $data{countryname} = &Util::LookupCountry($data{c}); if ($data{mailgreylisting} eq "TRUE") { @@ -105,8 +108,18 @@ if (!($query->param('doupdate'))) { } else { $data{mailcallout} = ""; } + + $data{maildefaultoptions} ||= 'TRUE'; + + if ($data{maildefaultoptions} eq "TRUE") { + $data{maildefaultoptions} = " checked"; + } else { + $data{maildefaultoptions} = ""; + } + + $data{mailcontentinspectionaction} ||= 'reject'; - $data{email} = join(", ", @{$entry->{emailforward}}); + $data{email} = CGI::escapeHTML(join(", ", @{$entry->{emailforward}})); my $genderselect = ''; + my $mailcontentselect = ' (delete)\n"; + + (delete)\n"; $sudopassword .= $e; if ($status eq 'unconfirmed') { - my $hmac = hmac_sha1_hex( join(':', 'confirm-new-password', $uuid, $hosts, $crypted), $hmac_key); - $confirmstring .= "confirm sudopassword $uuid $hosts $hmac\n"; + my $data = join(':', 'confirm-new-password', 'sudo', $data{'uid'}, $uuid, $hosts, $crypted); + my $hmac = hmac_sha1_hex( $data, $hmac_key); + $confirmstring .= CGI::escapeHTML("confirm sudopassword $uuid $hosts $hmac\n"); } }; if ($confirmstring ne '') { @@ -146,7 +179,7 @@ if (!($query->param('doupdate'))) { my $data = $host_entries->{$dn}; my $host = $data->{'host'}->[0]; my $hostname = $data->{'hostname'}->[0]; - $sudopasswordhosts .= "