source: trunk/LATMOS-Accounts/bin/la-passwd @ 1634

Last change on this file since 1634 was 861, checked in by nanardon, 13 years ago
  • reimport missing files from previous svn
  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts;
6use Getopt::Long;
7use Pod::Usage;
8use 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 -c|--config configdir
23
24Use this configuration directory instead of the default one.
25
26=item -b|--base basename
27
28Query this specific base instead of the default one.
29
30=item -s|--sync syncname
31
32Use this synchronisation
33
34=item -t|--test
35
36Don't change the password but check its validity using CrackLib.
37
38=back
39
40=cut
41
42GetOptions(
43    'c|config=s' => \my $config,
44    'b|base=s'   => \my $base,
45    't|test'     => \my $test,
46    's|sync=s'   => \my $sync,
47    'help'       => sub { pod2usage(0) },
48) or pod2usage();
49
50if (!$ARGV[0]) {warn "You must specify 'userid', aborting\n"; pod2usage(); }
51
52my $otype = 'user';
53
54my $LA = LATMOS::Accounts->new($config, noacl => 1);
55my $labase = $base ? $LA->base($base) : $LA->sync_access($sync);
56$labase && $labase->load or die "Cannot load base";
57
58$labase->wexported(1);
59
60my $obj = $labase->get_object($otype, $ARGV[0]) or do {
61    die "Object $otype $ARGV[0] not found\n";
62};
63
64ReadMode('noecho');
65print "Enter password: ";
66my $password = ReadLine(0);
67ReadMode 0;
68print "\n";
69chomp($password);
70
71print "Password quality: " . $obj->check_password($password) . "\n";
72
73exit(0)  if($test);
74
75if ($obj->set_password($password)) {
76    print "Password succefully changed\n";
77    $labase->commit;
78    exit 0;
79} else {
80    warn "Error when trying to change password\n";
81    exit 1;
82}
Note: See TracBrowser for help on using the repository browser.