X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=update.cgi;h=f1f82f9e81ae38e8d62fd6bfa6fdd3246fdbb654;hb=03a2094f69b5b8d37b6d8d3734c46788a76292f2;hp=3077e6a70cdbc8f613552086e9efc898aa3adb3a;hpb=40370d4d18e676d84988530673ce69f6193aab4a;p=mirror%2Fuserdir-ldap-cgi.git diff --git a/update.cgi b/update.cgi index 3077e6a..f1f82f9 100755 --- a/update.cgi +++ b/update.cgi @@ -13,7 +13,8 @@ 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; @@ -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 .= "