Last change
on this file since 591 was
584,
checked in by nanardon, 15 years ago
|
- add function to check password over cracklib
|
-
Property svn:executable set to
*
|
File size:
1.1 KB
|
Line | |
---|
1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use LATMOS::Accounts; |
---|
6 | use Getopt::Long; |
---|
7 | use Pod::Usage; |
---|
8 | use Term::ReadKey; |
---|
9 | |
---|
10 | =head1 NAME |
---|
11 | |
---|
12 | la-passwd - set user password |
---|
13 | |
---|
14 | =head1 SYNOPSIS |
---|
15 | |
---|
16 | la-passwd [options] userid |
---|
17 | |
---|
18 | =head1 OPTIONS |
---|
19 | |
---|
20 | =over 4 |
---|
21 | |
---|
22 | =item -t --test |
---|
23 | |
---|
24 | Don't change password but check it validity using CrackLib. |
---|
25 | |
---|
26 | =back |
---|
27 | |
---|
28 | =cut |
---|
29 | |
---|
30 | GetOptions( |
---|
31 | 'c|config=s' => \my $config, |
---|
32 | 'b|base=s' => \my $base, |
---|
33 | 't|test' => \my $test, |
---|
34 | 'help' => sub { pod2usage(0) }, |
---|
35 | ) or pod2usage(); |
---|
36 | |
---|
37 | my $otype = 'user'; |
---|
38 | |
---|
39 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
40 | my $labase = $base ? $LA->base($base) : $LA->default_base; |
---|
41 | $labase && $labase->load or die "Cannot load base"; |
---|
42 | |
---|
43 | my $obj = $labase->get_object($otype, $ARGV[0]) or do { |
---|
44 | die "Object $otype $ARGV[0] not found\n"; |
---|
45 | }; |
---|
46 | |
---|
47 | ReadMode('noecho'); |
---|
48 | print "Enter password: "; |
---|
49 | my $password = ReadLine(0); |
---|
50 | ReadMode 0; |
---|
51 | print "\n"; |
---|
52 | |
---|
53 | print $obj->check_password($password) . "\n"; |
---|
54 | |
---|
55 | exit(0) if($test); |
---|
56 | |
---|
57 | if ($obj->set_password($password)) { |
---|
58 | print "Password succefully changed\n"; |
---|
59 | $labase->commit; |
---|
60 | exit 0; |
---|
61 | } else { |
---|
62 | warn "Error when trying to change password\n"; |
---|
63 | exit 1; |
---|
64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.