X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=update.cgi;h=de3932a30579a37d8f12823e2b6ab15032fe7520;hb=2639ca03902bc809d5e024926a3eab910eb5f18a;hp=e1f7c969a26dce81ef92f13c2314334ba72db517;hpb=54948353056429140304d847b56f9036053c0dfd;p=mirror%2Fuserdir-ldap-cgi.git diff --git a/update.cgi b/update.cgi index e1f7c96..de3932a 100755 --- a/update.cgi +++ b/update.cgi @@ -8,7 +8,10 @@ use lib '.'; use strict vars; #use Apache::Registry; use CGI; +use UUID; +use Digest::HMAC_SHA1 qw(hmac_sha1_hex); use Util; +use English; use URI::Escape; use Net::LDAP qw(:all); @@ -29,6 +32,11 @@ if ($proto eq "http" || !($id && $password)) { my $ldap; +open (F, "<$config{passdir}/key-hmac-$UID") || &Util::HTMLError($!); +my $hmac_key = ; +close(F); +chomp($hmac_key); + sub DieHandler { $ldap->unbind if (defined($ldap)); } @@ -36,6 +44,7 @@ sub DieHandler { $SIG{__DIE__} = \&DieHandler; $ldap = Net::LDAP->new($config{ldaphost}); +&Util::UpgradeConnection($ldap) unless $config{usessl} eq 'False'; my $auth = 0; my $mesg; $mesg = $ldap->bind($editdn, password => $password); @@ -57,7 +66,11 @@ my $entries = $mesg->as_struct; if ($mesg->count != 1) { # complain and quit } - + +$mesg = $ldap->search(base => $config{hostbasedn}, filter => 'host=*'); +$mesg->code && &Util::HTMLError($mesg->error); +my $host_entries = $mesg->as_struct; + my @dns = keys(%$entries); my $entry = $entries->{$dns[0]}; @@ -104,6 +117,38 @@ if (!($query->param('doupdate'))) { . '>male