You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rob Hartill <ha...@ooo.lanl.gov> on 1995/11/15 22:39:08 UTC

patch for dbmmanage

Below is a patch for dbmmanage that allows the group to be added
when a password is added. I've been using this feature and find it
useful; others might too.

It also returns 0 or 1 when called with the "view" argument so that
you can call it to test if a username is in the db or not.


*** Apache/apache_0.8.15/support/dbmmanage	Fri Oct 13 07:01:25 1995
--- dbmmanage	Wed Nov 15 14:28:00 1995
***************
*** 71,79 ****
--- 71,81 ----
  $command=$ARGV[1];
  $key=$ARGV[2];
  $value=$ARGV[3];
+ $group=$ARGV[4];
  
  if ($command eq "add") {
          dbmopen(%DB, $file, 0664) || die "Error: $!\n";
+         $value .= ":$group" if $group ne "";
          $DB{$key} = $value;
          dbmclose(%DB);
  	print "Entry $key added with value $value.\n";
***************
*** 83,88 ****
--- 85,92 ----
  if ($command eq "adduser") {
  	$hash = crypt($value, "$salt");
          dbmopen(%DB, $file, 0664) || die "Error: $!\n";
+         $hash .= ":$group" if $group ne "";
+         $value .= ":$group" if $group ne "";
          $DB{$key} = $hash;
          dbmclose(%DB);
  	print "User $key added with password $value, encrypted to $hash\n";
***************
*** 98,112 ****
  
  if ($command eq "view") {
          dbmopen(%DB, $file, undef) || die "Error: $!\n";
          unless ($key) {
                  while (($nkey,$val) = each %DB) {
                          print "$nkey = $val\n";
                  }
          } else {
                  print "$key = $DB{$key}\n";
          } 
          dbmclose(%DB);
! 	exit;
  }
  
  print "Command unrecognized - must be one of: view, add, adduser, delete.\n";
--- 102,118 ----
  
  if ($command eq "view") {
          dbmopen(%DB, $file, undef) || die "Error: $!\n";
+         $return_status = 1;
          unless ($key) {
                  while (($nkey,$val) = each %DB) {
                          print "$nkey = $val\n";
                  }
          } else {
+                 $return_status = 0 if defined $DB{$key};
                  print "$key = $DB{$key}\n";
          } 
          dbmclose(%DB);
! 	exit($return_status);
  }
  
  print "Command unrecognized - must be one of: view, add, adduser, delete.\n";