#!/usr/bin/perl -w #---------------------------------------------------------------------- # Copyright (C) 2002 Mitel Networks Corp. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Technical support for this program is available from Mitel Networks. # For details, please visit our web site at www.mitel.com/sme/ #---------------------------------------------------------------------- use strict; use esmith::event; use esmith::AccountsDB; use User::grent; shift @ARGV; my $userName = shift @ARGV or die "Must supply username"; my $acctdb = esmith::AccountsDB->open() or die "Unable to open accounts db: $!"; # Make a list of system groups that this user is a member of my ($user, $colon, @old_groups) = split(' ', `/usr/bin/groups $userName`); # Now add in the list of groups the user is a member of according to # the accounts db, and remove duplicates. The do the group-modify # actions for all these groups my %modified_groups = map { $_, 1 } @old_groups, $acctdb->user_group_list($userName); # but omit "shared" and user private group foreach ('shared', $userName) { delete $modified_groups{$_} if exists $modified_groups{$_}; } exit 0 unless (scalar %modified_groups); event_signal("group-modify", keys %modified_groups);