X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=update.cgi;h=1a66b753b7932faa7883fadffebb7164c241cccd;hb=7186c5b0dbf23f02d1564637b55c5f45fbb44193;hp=d1aa73ab35c6da24a06dae0f38e4839ff46fe1f0;hpb=7f1fadc57026957fd2ea1c0e520a22b047f2aa24;p=mirror%2Fuserdir-ldap-cgi.git diff --git a/update.cgi b/update.cgi index d1aa73a..1a66b75 100755 --- a/update.cgi +++ b/update.cgi @@ -8,7 +8,10 @@ use lib '.'; use strict vars; #use Apache::Registry; use CGI; +use Data::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,39 @@ if (!($query->param('doupdate'))) { . '>male