Bump version and update Changes
[apache2-authen-passphrase.git] / aap-passwd
CommitLineData
8443f44e
MG
1#!/usr/bin/perl -T
2use 5.014000;
7c87e995 3use strict;
8443f44e
MG
4use warnings;
5
6our $VERSION = 0.002001;
7c87e995
MG
7
8use Apache2::Authen::Passphrase qw/pwset USER_REGEX/;
9
10use IO::Prompter [qw/-e* -stdio/];
11
7838eb58
MG
12die "Usage: aap-passwd [rootdir] username\n" if @ARGV == 0 || @ARGV > 2;
13($Apache2::Authen::Passphrase::rootdir) = (shift =~ /(.*)/s) if @ARGV == 2;
7c87e995
MG
14
15my $username = shift;
8443f44e
MG
16die "Invalid username\n" unless $username =~ USER_REGEX;
17($username) = ($username =~ /(.*)/s);
7c87e995
MG
18
19my $passwd = prompt 'Enter new Apache2::Authen::Passphrase password: ';
20my $confirm = prompt 'Retype new Apache2::Authen::Passphrase password: ';
21
22die "Sorry, passwords do not match\n" unless $passwd eq $confirm;
23pwset $username, $passwd;
8443f44e 24say 'Password updated successfully'; ## no critic (RequireCheckedSyscalls)
7c87e995
MG
25
26__END__
27
28=head1 NAME
29
30aap-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
41aap-passwd updates the password of an Apache2::Authen::Passphrase user.
42
43It is used like this:
44
45 aap-passwd /path/to/rootdir username
46
47where 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
51where 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
59The default Apache2::Authen::Passphrase C<rootdir>, used if the C<rootdir> is not explicitly given.
60
61=back
62
63=head1 AUTHOR
64
65Marius Gavrilescu C<< <marius@ieval.ro> >>
66
67=head1 COPYRIGHT AND LICENSE
68
0fc1719a 69Copyright (C) 2013-2015 by Marius Gavrilescu
7c87e995 70
0fc1719a
MG
71This library is free software; you can redistribute it and/or modify
72it under the same terms as Perl itself, either Perl version 5.14.2 or,
73at your option, any later version of Perl 5 you may have available.
7c87e995
MG
74
75
76=cut
This page took 0.014488 seconds and 4 git commands to generate.