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