equal
deleted
inserted
replaced
18 # Matthias Förste <foerste@schlittermann.de> |
18 # Matthias Förste <foerste@schlittermann.de> |
19 |
19 |
20 use strict; |
20 use strict; |
21 use warnings; |
21 use warnings; |
22 |
22 |
23 use Ius::Dav::Htpasswd qw(mkpasswd readconfig useradd usage); |
23 use Ius::Dav::Htpasswd; |
24 |
24 |
25 use Getopt::Long; |
25 use Getopt::Long; |
26 use Pod::Usage; |
26 use Pod::Usage; |
27 |
27 |
28 my ( $user, $expiry, $pass ); |
28 my ( $user, $expiry, $pass ); |
29 |
29 |
30 GetOptions( |
30 GetOptions( |
31 'u|user=s' => \$user, |
31 'u|user=s' => \$user, |
32 'e|expiry=i' => \$expiry, |
32 'e|expiry=i' => \$expiry, |
33 'h|help' => sub { usage( -exit => 0, -verbose => 1 ) }, |
33 'h|help' => sub { Ius::Dav::Htpasswd::usage( -exit => 0, -verbose => 1 ) }, |
34 'm|man' => sub { |
34 'm|man' => sub { |
35 usage( |
35 Ius::Dav::Htpasswd::usage( |
36 -exit => 0, |
36 -exit => 0, |
37 |
37 |
38 # "system('perldoc -V &>/dev/null')" appears shorter, but may not |
38 # "system('perldoc -V &>/dev/null')" appears shorter, but may not |
39 # do what you expect ( it still returns 0 on debian squeeze with |
39 # do what you expect ( it still returns 0 on debian squeeze with |
40 # dash as system shell even if cannot find the command in $PATH) |
40 # dash as system shell even if cannot find the command in $PATH) |
42 -verbose => 2 |
42 -verbose => 2 |
43 ); |
43 ); |
44 }, |
44 }, |
45 ) |
45 ) |
46 and defined $user |
46 and defined $user |
47 or usage; |
47 or Ius::Dav::Htpasswd::usage; |
48 |
48 |
49 $pass = useradd readconfig, $user, mkpasswd, $expiry; |
49 my $h = Ius::Dav::Htpasswd->new; |
|
50 $h->readconfig or die "Can't readconfig"; |
|
51 $pass = $h->useradd($user, Ius::Dav::Htpasswd::mkpasswd, $expiry); |
50 print "$pass\n"; |
52 print "$pass\n"; |