1#!/usr/bin/perl -w
2
3#  This code was developped by IDEALX (http://IDEALX.org/) and
4#  contributors (their names can be found in the CONTRIBUTORS file).
5#
6#                 Copyright (C) 2001-2002 IDEALX
7#
8#  This program is free software; you can redistribute it and/or
9#  modify it under the terms of the GNU General Public License
10#  as published by the Free Software Foundation; either version 2
11#  of the License, or (at your option) any later version.
12#
13#  This program is distributed in the hope that it will be useful,
14#  but WITHOUT ANY WARRANTY; without even the implied warranty of
15#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16#  GNU General Public License for more details.
17#
18#  You should have received a copy of the GNU General Public License
19#  along with this program; if not, write to the Free Software
20#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21#  USA.
22
23# Purpose of smbldap-groupdel : group (posix) deletion
24
25use strict;
26use FindBin;
27use FindBin qw($RealBin);
28use lib "$RealBin/";
29use smbldap_tools;
30use smbldap_conf;
31
32#####################
33use Getopt::Std;
34my %Options;
35
36my $ok = getopts('?', \%Options);
37if ( (!$ok) || (@ARGV < 1) || ($Options{'?'}) ) {
38  print "Usage: $0 groupname\n";
39  print "  -?	show this help message\n";
40  exit (1);
41}
42
43my $_groupName = $ARGV[0];
44
45my $dn_line;
46if (!defined($dn_line = get_group_dn($_groupName))) {
47  print "$0: group $_groupName doesn't exist\n";
48  exit (6);
49}
50
51my $dn = get_dn_from_line($dn_line);
52
53group_del($dn);
54
55my $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
56
57if ($nscd_status == 0) {
58  system "/etc/init.d/nscd restart > /dev/null 2>&1";
59}
60
61#if (defined($dn_line = get_group_dn($_groupName))) {
62#    print "$0: failed to delete group\n";
63#    exit (7);
64#}
65
66
67exit (0);
68
69############################################################
70
71=head1 NAME
72
73       smbldap-groupdel.pl - Delete a group
74
75=head1 SYNOPSIS
76
77       smbldap-groupdel.pl group
78
79=head1 DESCRIPTION
80
81       The smbldap-groupdel.pl command modifies the system account files,
82       deleting all entries that refer to group. The named group must exist.
83
84       You must manually check all filesystems to insure that no files remain
85       with the named group as the file group ID.
86
87=head1 SEE ALSO
88
89       groupdel(1)
90
91=cut
92
93#'
94