X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap-cgi.git;a=blobdiff_plain;f=update.cgi;h=3cf1900f1ac8e1cd01bac60dc08fc6077ee4cf61;hp=c264eaf72aa9d0c9cdd97db3e89b41a13658f1c2;hb=HEAD;hpb=b407fa1bbfe6dfead1991fe576183acc5053e3d8 diff --git a/update.cgi b/update.cgi index c264eaf..3cf1900 100755 --- a/update.cgi +++ b/update.cgi @@ -3,6 +3,7 @@ # $Id: update.cgi,v 1.13 2006/12/28 02:44:02 rmurray Exp $ # (c) 1999 Randolph Chung. Licensed under the GPL. # (c) 2006 Ryan Murray. Licensed under the GPL. +# Copyright (c) 2008, 2011, 2012, 2014, 2015 Peter Palfrader use lib '.'; use strict vars; @@ -25,13 +26,21 @@ my $proto = ($ENV{HTTPS} ? "https" : "http"); my $id = $query->param('id'); my $authtoken = $query->param('authtoken'); -my $password = &Util::CheckAuthToken($authtoken); -my $editdn = $query->param('editdn'); + +my $password = undef; + +if ($authtoken || $id) { + $password = Util::TouchAuthToken($authtoken, $id); +} else { + $password = ''; + $id = ''; + $authtoken = ''; +} if ($proto eq "http" || !($id && $password)) { print "Location: https://$ENV{SERVER_NAME}/$config{webloginhtml}\n\n"; exit; -} +} my $ldap; @@ -45,6 +54,7 @@ sub DieHandler { } #$SIG{__DIE__} = \&DieHandler; +my $editdn = "uid=$id,$config{basedn}"; $ldap = Net::LDAP->new($config{ldaphost}); &Util::UpgradeConnection($ldap) unless $config{usessl} eq 'False'; @@ -64,7 +74,7 @@ if (!$auth) { $mesg = $ldap->search(base => $editdn, filter => "uid=*"); $mesg->code && &Util::HTMLError($mesg->error); - + my $entries = $mesg->as_struct; if ($mesg->count != 1) { # complain and quit @@ -80,7 +90,7 @@ my $entry = $entries->{$dns[0]}; if (!($query->param('doupdate'))) { # Not yet update, just fill in the form with the current values my %data; - + # Fill in %data # First do the easy stuff - this catches most of the cases foreach (keys(%$entry)) { @@ -88,8 +98,6 @@ if (!($query->param('doupdate'))) { $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... $data{id} = $id; $data{authtoken} = $authtoken; @@ -120,18 +128,9 @@ if (!($query->param('doupdate'))) { } $data{mailcontentinspectionaction} ||= 'reject'; - + $data{email} = CGI::escapeHTML(join(", ", @{$entry->{emailforward}})); - my $genderselect = ''; my $mailcontentselect = '