This file is indexed.

/usr/sbin/remove-ds-admin is in 389-admin 1.1.35-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env perl
# BEGIN COPYRIGHT BLOCK
# 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; version 2 of the License.
# 
# 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.
# 
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#

use lib qw(/usr/lib/x86_64-linux-gnu/dirsrv/perl);

use strict;

use File::Basename;
use File::Path;
use DSUtil;
use Resource;
use DSCreate qw(removeDSInstance);
use AdminServer qw(removeAdminServer);

sub usage {
        print(STDERR "Usage: $0 [-f] [-d -d ...]\n\n");
        print(STDERR " Opts: -f            - force removal\n");
        print(STDERR "       -a            - remove all\n");
        print(STDERR "       -d            - turn on debugging output\n");
        print(STDERR "       -y            - actually do the removal\n");
        print(STDERR "WARNING: This command is extremely destructive!\n");
        print(STDERR "         It will remove all of the data and configuration\n");
        print(STDERR "         of all directory servers and admin servers, with\n");
        print(STDERR "         no chance of recovery.  Therefore, in order to actually\n");
        print(STDERR "         do this, you must give the -y option.\n");
}

my $res = new Resource("/usr/share/dirsrv/properties/setup-ds.res",
                       "/usr/share/dirsrv/properties/setup-ds-admin.res");

my $i = 0;
my $force = "";
my $all = 0;
my $seeny;

# load args from the command line
while ($i <= $#ARGV) {
    if ( "$ARGV[$i]" eq "-f" ) { 
        $force = 1;
    } elsif ("$ARGV[$i]" eq "-a") {
        $all = 1;
    } elsif ("$ARGV[$i]" eq "-d") {
        $DSUtil::debuglevel++;
    } elsif ( "$ARGV[$i]" eq "-y" ) { 
        $seeny = 1;
    } else {
        &usage; exit(1);
    }
    $i++;
}

if (!$seeny) {
    &usage; exit(1);
}

my $baseconfigdir = $ENV{DS_CONFIG_DIR} || "/etc/dirsrv";
my @instances = ();
my @errs;

if ( ! -d $baseconfigdir )
{
    print STDERR "Error: $baseconfigdir does not exist\n";
    exit 1;
}

# get all of our directory server instances
for my $dir (glob("$baseconfigdir/slapd-*")) {
    next if ($dir =~ /\.removed/);
    if (-d $dir) {
        $dir =~ s,$baseconfigdir/,,; # strip off dir part
        $dir =~ s/slapd-//; # strip off slapd part
        push @instances, $dir;
    }
}

# remove all of the directory servers
for my $inst (@instances) {
    my $configdir = "$baseconfigdir/slapd-$inst";
    if ( ! -d $configdir )
    {
        print STDERR "Error: $configdir does not exist\n";
        if (!$force) {
            exit 1;
        }
    }
    @errs = removeDSInstance($inst, $force, $all);
    if (@errs) {
        print STDERR "The following errors occurred during removal of $inst:\n";
        for (@errs) {
            print STDERR $res->getText($_);
        }
        print STDERR "Error: could not remove directory server $inst\n";
        if (!$force) {
            exit 1;
        }
    }
}

# remove the admin server
if (@errs = removeAdminServer($baseconfigdir, $force, $all)) {
    print STDERR "The following errors occurred during removal of the admin server:\n";
    for (@errs) {
        print STDERR $res->getText($_);
    }
    print STDERR "Error: could not remove admin server\n";
    if (!$force) {
        exit 1;
    }
}

# if we got here, report success
print "Removed admin server and all directory server instances\n";
exit 0;

# emacs settings
# Local Variables:
# mode:perl
# indent-tabs-mode: nil
# tab-width: 4
# End: