/[docman]/adduser.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /adduser.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations)
Thu Sep 6 10:48:20 2001 UTC (22 years, 6 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +1 -1 lines
File MIME type: text/plain
small fix for undef var

1 #!/usr/bin/perl -w
2
3 # perl script to add users to Document Manager's .htusers file
4
5 use Digest::MD5 qw(md5_hex);
6
7 my $htpasswd = shift @ARGV || ".htusers";
8
9 if (defined $htpasswd && $htpasswd eq "-h") {
10 print "Usage: $0 [htusers file] [login] [full name] [password] [email]\n";
11 exit;
12 }
13
14 my $login = shift @ARGV;
15 while (! $login) {
16 print "login: ";
17 $login=<STDIN>; chomp $login;
18 }
19
20 my $fullname = shift @ARGV;
21 while (! $fullname) {
22 print "full name: ";
23 $fullname=<STDIN>; chomp $fullname;
24 }
25
26 my $passwd = shift @ARGV;
27 if (! $passwd) {
28 print "password [auth_pop3]: ";
29 $passwd=<STDIN>; chomp $passwd;
30 if ($passwd eq "") {
31 $passwd="auth_pop3";
32 }
33 }
34 if (substr($passwd,0,5) ne "auth_") {
35 $passwd=md5_hex($login.$passwd);
36 }
37
38 my $email = shift @ARGV;
39 while (! $email || $email !~ /\w@\w/) {
40 print "e-mail: ";
41 $email=<STDIN>; chomp $email;
42 print "e-mail address needs to have user\@domain for auth_pop3",
43 " to work!\n" if ($email !~ /\w@\w/);
44 }
45
46 if (! -e "$htpasswd") {
47 print "creating $htpasswd\n";
48 open(HTPASSWD,"> $htpasswd") || die "open $htpasswd: $!";
49 } else {
50 open(HTPASSWD,">> $htpasswd") || die "append $htpasswd: $!";
51 }
52
53 print HTPASSWD "$login:$fullname:$passwd:$email\n";
54 close(HTPASSWD);

  ViewVC Help
Powered by ViewVC 1.1.26