From fcd7b3409b79ebeb4567e461ef20a4564da8e8cc Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Wed, 20 Sep 2000 20:09:59 +0000 Subject: [PATCH] Overhaul of dbmmanage to allow a groups arg (as in Apache 1.2) as well as a comment arg to the add, adduser and update cmds. update allows the user to clear or preserve pw/groups/comment. Fixed a bug in dbmmanage that prevented the check option from parsing a password followed by :group... text. Corrected the seed calcualation for Win32 systems, and added -lsdbm support. PR: 3810, 5527 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86268 13f79535-47bb-0310-9956-ffa450edef68 --- support/dbmmanage | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/support/dbmmanage b/support/dbmmanage index da6852761e..0617496009 100644 --- a/support/dbmmanage +++ b/support/dbmmanage @@ -68,7 +68,7 @@ use strict; use Fcntl; use AnyDBM_File (); -my($file,$command,$key,$crypted_pwd) = @ARGV; +my($file,$command,$key,$crypted_pwd,$groups,$comment) = @ARGV; usage() unless $file and $command and defined &{$dbmc::{$command}}; @@ -98,17 +98,33 @@ untie %DB; sub usage { my $cmds = join "|", sort keys %dbmc::; - die "usage: $0 filename [$cmds] [username]\n"; + die </dev/null`; - $psf = $_, last unless $?; + if ($Is_Win32) { + srand (time ^ $$ or time ^ ($$ + ($$ << 15))); + } + else { + for (qw(-xlwwa -le)) { + `ps $_ 2>/dev/null`; + $psf = $_, last unless $?; + } + srand (time ^ $$ ^ unpack("%L*", `ps $psf | gzip -f`)); } - srand (time ^ $$ ^ unpack("%L*", `ps $psf | gzip -f`)); @range = (qw(. /), '0'..'9','a'..'z','A'..'Z'); $x = int scalar @range; } @@ -147,7 +163,15 @@ sub getpass { sub dbmc::update { die "Sorry, user `$key' doesn't exist!\n" unless $DB{$key}; - dbmc->adduser; + $crypted_pwd = (split /:/, $DB{$key}, 4)[0] if $crypted_pwd eq '.'; + $groups = (split /:/, $DB{$key}, 4)[1] if !$groups || $groups eq '.'; + $comment = (split /:/, $DB{$key}, 4)[2] if !$comment || $comment eq '.'; + if (!$crypted_pwd || $crypted_pwd eq '-') { + dbmc->adduser; + } + else { + dbmc->add; + } } sub dbmc::add { @@ -155,6 +179,10 @@ sub dbmc::add { unless($is_update) { die "Sorry, user `$key' already exists!\n" if $DB{$key}; } + $groups = '' if $groups eq '-'; + $comment = '' if $comment eq '-'; + $groups .= ":" . $comment if $comment; + $crypted_pwd .= ":" . $groups if $groups; $DB{$key} = $crypted_pwd; my $action = $is_update ? "updated" : "added"; print "User $key $action with password encrypted to $DB{$key}\n"; @@ -178,13 +206,13 @@ sub dbmc::view { sub dbmc::check { die "Sorry, user `$key' doesn't exist!\n" unless $DB{$key}; - my $chkpass = (split /:/, $DB{$key})[0]; + my $chkpass = (split /:/, $DB{$key},4)[0]; print crypt(getpass(), $chkpass) eq $chkpass ? "password ok\n" : "password mismatch\n"; } sub dbmc::import { while(defined($_ = ) and chomp) { - ($key,$crypted_pwd) = split /:/, $_, 2; + ($key,$crypted_pwd,$groups,$comment) = split /:/, $_, 4; dbmc->add; } } -- 2.50.1