X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap-cgi.git;a=blobdiff_plain;f=update.cgi;h=3cf1900f1ac8e1cd01bac60dc08fc6077ee4cf61;hp=ae0b6ce2289e93fc42c99464191b0ba8b687444c;hb=HEAD;hpb=449fb36b879fe6aca6347db51f1c00d4865144be diff --git a/update.cgi b/update.cgi index ae0b6ce..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; @@ -10,10 +11,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; @@ -22,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; @@ -41,7 +53,8 @@ sub DieHandler { $ldap->unbind if (defined($ldap)); } -$SIG{__DIE__} = \&DieHandler; +#$SIG{__DIE__} = \&DieHandler; +my $editdn = "uid=$id,$config{basedn}"; $ldap = Net::LDAP->new($config{ldaphost}); &Util::UpgradeConnection($ldap) unless $config{usessl} eq 'False'; @@ -61,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 @@ -77,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)) { @@ -85,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; @@ -107,22 +118,34 @@ 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} = CGI::escapeHTML(join(", ", @{$entry->{emailforward}})); - my $genderselect = ''; + my $mailcontentselect = '