/[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

Annotation of /adduser.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Thu Sep 6 09:32:55 2001 UTC (17 years, 10 months ago) by dpavlin
Branch: MAIN
Changes since 1.3: +5 -0 lines
File MIME type: text/plain
added -h flag to show help

1 dpavlin 1.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 dpavlin 1.4 if ($htpasswd eq "-h") {
10     print "Usage: $0 [htusers file] [login] [full name] [password] [email]\n";
11     exit;
12     }
13    
14 dpavlin 1.1 my $login = shift @ARGV;
15 dpavlin 1.2 while (! $login) {
16 dpavlin 1.1 print "login: ";
17     $login=<STDIN>; chomp $login;
18     }
19    
20     my $fullname = shift @ARGV;
21 dpavlin 1.2 while (! $fullname) {
22 dpavlin 1.1 print "full name: ";
23     $fullname=<STDIN>; chomp $fullname;
24     }
25    
26 dpavlin 1.2 my $passwd = shift @ARGV;
27     if (! $passwd) {
28 dpavlin 1.1 print "password [auth_pop3]: ";
29     $passwd=<STDIN>; chomp $passwd;
30     if ($passwd eq "") {
31     $passwd="auth_pop3";
32 dpavlin 1.2 }
33     }
34 dpavlin 1.3 if (substr($passwd,0,5) ne "auth_") {
35 dpavlin 1.1 $passwd=md5_hex($login.$passwd);
36     }
37    
38     my $email = shift @ARGV;
39 dpavlin 1.2 while (! $email || $email !~ /\w@\w/) {
40 dpavlin 1.1 print "e-mail: ";
41     $email=<STDIN>; chomp $email;
42 dpavlin 1.2 print "e-mail address needs to have user\@domain for auth_pop3",
43     " to work!\n" if ($email !~ /\w@\w/);
44 dpavlin 1.1 }
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 dpavlin 1.2
53 dpavlin 1.1 print HTPASSWD "$login:$fullname:$passwd:$email\n";
54     close(HTPASSWD);

  ViewVC Help
Powered by ViewVC 1.1.26