Utilise esmith::AccountsDB pour la génération des scripts netlogon

tags/0.2.8
Daniel Berteaud 13 years ago
parent 22fca83f58
commit 3451b56329
  1. 39
      root/sbin/e-smith/generate_netlogon

@ -17,7 +17,7 @@ die "Time argument missing.\n" unless defined ($time);
package esmith; package esmith;
use strict; use strict;
use esmith::AccountsDB;
use esmith::util; use esmith::util;
BEGIN BEGIN
@ -33,9 +33,8 @@ BEGIN
esmith::util::setRealToEffective (); esmith::util::setRealToEffective ();
my %accounts; my $a = esmith::AccountsDB->open_ro() ||
tie %accounts, 'esmith::config', '/home/e-smith/db/accounts'; die "Couldn't open AccountsDB\n";
# ------------------------------------------------ # ------------------------------------------------
# Open and read in the template netlogon.bat file. # Open and read in the template netlogon.bat file.
@ -84,7 +83,7 @@ foreach $line ( @infile )
{ {
if ( !$activelevels[ $level ] ) if ( !$activelevels[ $level ] )
{ {
$activelevels[ $level ] = isInGroup($curUser, $group); $activelevels[ $level ] = $a->is_user_in_group($curUser, $group);
} }
} }
@ -207,33 +206,3 @@ chmod ( 0744, "$netlogonFile" );
exit (0); exit (0);
# --------------------------------------------------
# Subroutine to check if a given user is in a group:
# --------------------------------------------------
sub isInGroup($$)
{
my ($user, $group) = @_;
my $value = $accounts{$group};
if ( defined ($value) )
{
my ($type, %properties) = split (/\|/, $value);
if ($type eq 'group')
{
my @members = split (/,/, $properties {'Members'});
my $member;
# TODO: grep (/^$user$/, @members)
foreach $member ( @members )
{
if ( $member eq $user )
{
return 1;
}
}
}
}
return 0;
}

Loading…
Cancel
Save