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