Commit | Line | Data |
---|---|---|
7c87e995 MG |
1 | #!/usr/bin/perl -wT |
2 | use v5.14; | |
3 | use strict; | |
4 | ||
5 | use Apache2::Authen::Passphrase qw/pwset USER_REGEX/; | |
6 | ||
7 | use IO::Prompter [qw/-e* -stdio/]; | |
8 | ||
9 | die "Usage: aap-passwd [rootdir] username\n" unless $#ARGV >= 0 && $#ARGV <= 1; | |
10 | ($Apache2::Authen::Passphrase::rootdir) = (shift =~ /(.*)/) if $#ARGV == 1; | |
11 | ||
12 | my $username = shift; | |
13 | die "Invalid username" unless $username =~ USER_REGEX; | |
14 | ($username) = ($username =~ /(.*)/); | |
15 | ||
16 | my $passwd = prompt 'Enter new Apache2::Authen::Passphrase password: '; | |
17 | my $confirm = prompt 'Retype new Apache2::Authen::Passphrase password: '; | |
18 | ||
19 | die "Sorry, passwords do not match\n" unless $passwd eq $confirm; | |
20 | pwset $username, $passwd; | |
21 | say "Password updated successfully"; | |
22 | ||
23 | __END__ | |
24 | ||
25 | =head1 NAME | |
26 | ||
27 | aap-passwd - passwd utility for Apache2::Authen::Passphrase | |
28 | ||
29 | =head1 SYNOPSIS | |
30 | ||
31 | user@hostname:~$ aap-passwd /path/to/rootdir marius | |
32 | Enter new Apache2::Authen::Passphrase password: *** | |
33 | Retype new Apache2::Authen::Passphrase password: *** | |
34 | Password updated successfully | |
35 | ||
36 | =head1 DESCRIPTION | |
37 | ||
38 | aap-passwd updates the password of an Apache2::Authen::Passphrase user. | |
39 | ||
40 | It is used like this: | |
41 | ||
42 | aap-passwd /path/to/rootdir username | |
43 | ||
44 | where the C<rootdir> is the first argument and the username whose password is to be changed is the second argument, or like this: | |
45 | ||
46 | aap-passwd username | |
47 | ||
48 | where the C<rootdir> is taken from the environment and the username is the only argument. | |
49 | ||
50 | =head1 ENVIRONMENT | |
51 | ||
52 | =over | |
53 | ||
54 | =item AAP_ROOTDIR | |
55 | ||
56 | The default Apache2::Authen::Passphrase C<rootdir>, used if the C<rootdir> is not explicitly given. | |
57 | ||
58 | =back | |
59 | ||
60 | =head1 AUTHOR | |
61 | ||
62 | Marius Gavrilescu C<< <marius@ieval.ro> >> | |
63 | ||
64 | =head1 COPYRIGHT AND LICENSE | |
65 | ||
66 | Copyright 2013 Marius Gavrilescu | |
67 | ||
68 | This file is part of fonbotd. | |
69 | ||
70 | fonbotd is free software: you can redistribute it and/or modify | |
71 | it under the terms of the GNU Affero General Public License as published by | |
72 | the Free Software Foundation, either version 3 of the License, or | |
73 | (at your option) any later version. | |
74 | ||
75 | fonbotd is distributed in the hope that it will be useful, | |
76 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
77 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
78 | GNU Affero General Public License for more details. | |
79 | ||
80 | You should have received a copy of the GNU Affero General Public License | |
81 | along with fonbotd. If not, see <http://www.gnu.org/licenses/> | |
82 | ||
83 | ||
84 | =cut | |
85 |