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