# -*-perl-*-

# $id$

# $Log: MakePasswd.plm,v $
# Revision 1.5  2011/08/23 20:36:18  timc
# first pass at using ldap
#
# Revision 1.4  2004/07/06 14:45:16  thomas
# documentation
#
# Revision 1.3  2004/07/02 19:01:48  thomas
# Pass '-s <shell>' to make_passwd command
#
# Revision 1.2  2003/12/15 16:28:35  thomas
# check-in for 0.1.1
#
# Revision 1.1.1.1  2003/12/02 14:47:35  thomas
# Initial version before export to 0.1.1
#

use strict;
use Data::Dumper;

package What::Trigger::MakePasswd;
use base qw(What::Trigger);


my $inits = { sun4x_59 => { crond => 'cron' }};

sub MakePasswd {
  my $trigger = shift;
  my $node = shift;  # The config object
  my $section = shift;
  my $what = shift;
  my $params = shift;

  my ($init, $initdir, @cmd);

  if (-e '/etc/ptmp') {
    $what->err ("/etc/ptmp exists; not updating /etc/passwd\n");
    return 0;
  }

  @cmd = ('/s/lab/bin/make_passwd');
  if (defined ($params->{hostname})) {
    push @cmd, '-h', $params->{hostname};
  }
  if (defined ($params->{shell})) {
    push @cmd, '-s', $params->{shell};
  }
  if (defined ($params->{useldap})) {
    push @cmd, '--useldap';
  }
  $what->debug (1, join (' ', @cmd) . "\n");
  system (@cmd);

  return 1;
}

###############################################################################

=head1 NAME

What::Triggers::MakePasswd -- Remake the password file

=head1 PARAMS

Params that can be passed to this module include:

hostname="B<hostname>"

Will append '-h B<hostname>' to the /s/lab/bin/make_passwd command
line.

shell="B<shell>"

Will append '-s B<shell>' to the /s/lab/bin/make_passwd command line.

shell="B<useldap>"

Will append '--useldap' to the /s/lab/bin/make_passwd command line.

=head1 EXAMPLES

Allow access on this host to anyone with 'kiosk' access, and run the
kamerakiosk program as their shell.

  <node path="/Triggers/apply/make_passwd" >
    <trigger path="/MakePasswd" hostname="kiosk" shell="kamerakiosk" />
  </node>

=cut

###############################################################################

1;
