/[docman2]/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.1.1.1 - (show annotations) (vendor branch)
Fri Jul 19 20:53:12 2002 UTC (21 years, 8 months ago) by dpavlin
Branch: MAIN, DbP
CVS Tags: alpha, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
initial import (not working)

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

  ViewVC Help
Powered by ViewVC 1.1.26