/[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.2 - (hide annotations)
Mon May 28 06:28:40 2001 UTC (18 years ago) by dpavlin
Branch: MAIN
Changes since 1.1: +11 -8 lines
File MIME type: text/plain
changes from Siviwe Kwatsha <siviwe@plonkers.za.org>:
login and fullname: prompt until you have a "string" (something not enter)
passwd: fixed 2 typos on the variable name which break commandline,
only passwords NOT beginning with auth_ are encrypted
email: require a "word" before and after the '@', change error message to
reflect this can still get away with " name@address" but that's not strictly
wrong as the mua&/mta should strip it.

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

  ViewVC Help
Powered by ViewVC 1.1.26