Last change
on this file since 376 was
312,
checked in by nanardon, 15 years ago
|
- query password from console w/o printing it
|
-
Property svn:executable set to
*
|
File size:
904 bytes
|
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 | =cut |
---|
19 | |
---|
20 | GetOptions( |
---|
21 | 'c|config=s' => \my $config, |
---|
22 | 'b|base=s' => \my $base, |
---|
23 | 'help' => sub { pod2usage(0) }, |
---|
24 | ) or pod2usage(); |
---|
25 | |
---|
26 | my $otype = 'user'; |
---|
27 | |
---|
28 | my $LA = LATMOS::Accounts->new($config); |
---|
29 | my $labase = $base ? $LA->base($base) : $LA->default_base; |
---|
30 | $labase && $labase->load or die "Cannot load base"; |
---|
31 | |
---|
32 | my $obj = $labase->get_object($otype, $ARGV[0]) or do { |
---|
33 | die "Object $otype $ARGV[0] not found\n"; |
---|
34 | }; |
---|
35 | |
---|
36 | ReadMode('noecho'); |
---|
37 | print "Enter password: "; |
---|
38 | my $password = ReadLine(0); |
---|
39 | ReadMode 0; |
---|
40 | print "\n"; |
---|
41 | |
---|
42 | if ($obj->set_password($password)) { |
---|
43 | print "Password succefully changed\n"; |
---|
44 | exit 0; |
---|
45 | } else { |
---|
46 | warn "Error when trying to change password\n"; |
---|
47 | exit 1; |
---|
48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.