X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=update.cgi;h=ae0b6ce2289e93fc42c99464191b0ba8b687444c;hb=449fb36b879fe6aca6347db51f1c00d4865144be;hp=de3932a30579a37d8f12823e2b6ab15032fe7520;hpb=2639ca03902bc809d5e024926a3eab910eb5f18a;p=mirror%2Fuserdir-ldap-cgi.git diff --git a/update.cgi b/update.cgi index de3932a..ae0b6ce 100755 --- a/update.cgi +++ b/update.cgi @@ -8,7 +8,7 @@ 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; @@ -82,8 +82,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 +93,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") { @@ -106,7 +108,7 @@ if (!($query->param('doupdate'))) { $data{mailcallout} = ""; } - $data{email} = join(", ", @{$entry->{emailforward}}); + $data{email} = CGI::escapeHTML(join(", ", @{$entry->{emailforward}})); my $genderselect = ''; my $confirmstring = ''; my $sudopassword = ''; - for my $entry (@{$entry->{'sudopassword'}}) { - my ($uuid, $status, $hosts, $crypted) = ($entry =~ /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}) (confirmed:[0-9a-f]{40}|unconfirmed) ([a-z0-9.,*]+) ([^ ]+)$/); + for my $e(@{$entry->{'sudopassword'}}) { + my ($uuid, $status, $hosts, $crypted) = ($e =~ /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}) (confirmed:[0-9a-f]{40}|unconfirmed) ([a-z0-9.,*]+) ([^ ]+)$/); unless (defined $uuid) { $sudopassword .= "Unparseable line!\n"; next; } - $status =~ s/:.*//; # remove verification hmac, it's just noise here. - my $e = "$hosts - $status + if ($status =~ /^confirmed:/) { + my $data = join(':', 'password-is-confirmed', 'sudo', $data{'uid'}, $uuid, $hosts, $crypted); + my $hmac = hmac_sha1_hex( $data, $hmac_key); + if ($status eq "confirmed:$hmac") { + $status = 'confirmed'; + } else { + $status = 'INVALID'; + } + } + my $e = "".CGI::escapeHTML($hosts)." + ".CGI::escapeHTML($status)." not shown - $uuid - (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 +157,7 @@ if (!($query->param('doupdate'))) { my $data = $host_entries->{$dn}; my $host = $data->{'host'}->[0]; my $hostname = $data->{'hostname'}->[0]; - $sudopasswordhosts .= "