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