Commit | Line | Data |
---|---|---|
de45f55a AM |
1 | #!/usr/bin/perl |
2 | ||
3 | # Stitched together by Andreas Metzler, really too trivial to be copyrightable. | |
4 | ||
5 | use strict; | |
6 | use warnings; | |
7 | my $user; | |
8 | my $passwd; | |
9 | my $file; | |
10 | my $rand; | |
11 | ||
12 | if (@ARGV == 0) { | |
13 | $file="/etc/exim4/passwd"; | |
14 | } else { | |
15 | $file=$ARGV[0]; | |
16 | } | |
17 | ||
18 | open(PWDFILE,">>$file") || die("Couldn't append to file '$file': $!"); | |
19 | ||
20 | print "User: "; | |
21 | chop($user = <STDIN>); | |
22 | print "Password: "; | |
23 | chop($passwd = <STDIN>); | |
24 | ||
25 | $rand = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64, rand 64, rand 64]; | |
26 | print PWDFILE $user . ":" . crypt($passwd, q{$1$} . $rand . q{$}) . ":" . $passwd . "\n"; | |
27 | close(PWDFILE); | |
28 | ||
29 | __END__ | |
30 | ||
31 | =head1 NAME | |
32 | ||
33 | exim-adduser - Add username/password to exim password-file. | |
34 | ||
35 | =head1 USAGE | |
36 | ||
37 | exim-adduser [filename] | |
38 | ||
39 | exim-adduser prompts for username and password and adds | |
40 | ||
41 | username:crypted-password:cleartext-password | |
42 | ||
43 | to the given file, if no filename is given /etc/exim4/passwd is used. | |
44 | ||
45 | =head1 BUGS | |
46 | ||
47 | Probably many, this really is just example code. | |
48 | ||
49 | =head1 SEE ALSO | |
50 | ||
51 | /usr/share/doc/exim4-base/*, | |
52 | exim4(8) |