Add password checking via a python wrapper
[mirror/userdir-ldap-cgi.git] / update.cgi
index de3932a..1a66b75 100755 (executable)
@@ -8,7 +8,7 @@ use lib '.';
 use strict vars;
 #use Apache::Registry;
 use CGI;
-use UUID;
+use Data::UUID;
 use Digest::HMAC_SHA1 qw(hmac_sha1_hex);
 use Util;
 use English;
@@ -129,11 +129,12 @@ if (!($query->param('doupdate'))) {
     my $e = "<tr><td>$hosts</td>
                  <td>$status</td>
                  <td><small>not shown</small></td>
-                 <td><small><code>$uuid</code></small></td>
+                 <!--<td><small><code>$uuid</code></small></td>-->
                  <td><input name=\"sudopassword-delete-$uuid\" type=\"checkbox\" value=\"delete\"> (delete)</td></tr>\n";
     $sudopassword .= $e;
     if ($status eq 'unconfirmed') {
-      my $hmac = hmac_sha1_hex( join(':', 'confirm-new-password', $uuid, $hosts, $crypted), $hmac_key);
+      my $data = join(':', 'confirm-new-password', $uuid, $hosts, $crypted);
+      my $hmac = hmac_sha1_hex( $data, $hmac_key);
       $confirmstring .= "confirm sudopassword $uuid $hosts $hmac\n";
     }
   };
@@ -146,7 +147,7 @@ if (!($query->param('doupdate'))) {
       my $data = $host_entries->{$dn};
       my $host = $data->{'host'}->[0];
       my $hostname = $data->{'hostname'}->[0];
-      $sudopasswordhosts .= "<option value=\"$host\">$hostname\n";
+      $sudopasswordhosts .= "<option value=\"$hostname\">$host\n";
   };
   $sudopasswordhosts .= '</select>';
 
@@ -245,9 +246,8 @@ if (!($query->param('doupdate'))) {
     }
     # create a md5 crypted password
     my $newsudopassword = crypt($query->param('newsudopass'), &Util::CreateCryptSalt(1));
-    my ($uuidbin, $uuid);
-    UUID::generate($uuidbin);
-    UUID::unparse($uuidbin, $uuid);
+    my $ug = new Data::UUID;
+    my $uuid = $ug->create_str();
 
     $newsudo = "$uuid unconfirmed $host $newsudopassword";
     $newsudo_hosts = $host;