Bump version and update Changes
[apache2-authen-passphrase.git] / aap-passwd
1 #!/usr/bin/perl -T
2 use 5.014000;
3 use strict;
4 use warnings;
5
6 our $VERSION = 0.002001;
7
8 use Apache2::Authen::Passphrase qw/pwset USER_REGEX/;
9
10 use IO::Prompter [qw/-e* -stdio/];
11
12 die "Usage: aap-passwd [rootdir] username\n" if @ARGV == 0 || @ARGV > 2;
13 ($Apache2::Authen::Passphrase::rootdir) = (shift =~ /(.*)/s) if @ARGV == 2;
14
15 my $username = shift;
16 die "Invalid username\n" unless $username =~ USER_REGEX;
17 ($username) = ($username =~ /(.*)/s);
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;
24 say 'Password updated successfully'; ## no critic (RequireCheckedSyscalls)
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 (C) 2013-2015 by Marius Gavrilescu
70
71 This library is free software; you can redistribute it and/or modify
72 it under the same terms as Perl itself, either Perl version 5.14.2 or,
73 at your option, any later version of Perl 5 you may have available.
74
75
76 =cut
This page took 0.024436 seconds and 4 git commands to generate.