source: LATMOS-Accounts/bin/la-passwd @ 493

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