X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap-cgi.git;a=blobdiff_plain;f=update.cgi;h=c264eaf72aa9d0c9cdd97db3e89b41a13658f1c2;hp=3077e6a70cdbc8f613552086e9efc898aa3adb3a;hb=5cea731d1b6f9504bd695fd2f201761c35f71a2c;hpb=40370d4d18e676d84988530673ce69f6193aab4a diff --git a/update.cgi b/update.cgi index 3077e6a..c264eaf 100755 --- a/update.cgi +++ b/update.cgi @@ -10,10 +10,13 @@ use strict vars; use CGI; use Data::UUID; use Digest::HMAC_SHA1 qw(hmac_sha1_hex); +use Digest::MD5 qw(md5_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); +use Net::LDAP::Util qw(ldap_explode_dn); my %config = &Util::ReadConfigFile; @@ -41,7 +44,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 +85,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 +96,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 +110,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 +181,7 @@ if (!($query->param('doupdate'))) { my $data = $host_entries->{$dn}; my $host = $data->{'host'}->[0]; my $hostname = $data->{'hostname'}->[0]; - $sudopasswordhosts .= "