This file is indexed.

/usr/bin/wiki-toolkit-delete-node is in libwiki-toolkit-perl 0.79-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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/usr/bin/perl -w

eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
    if 0; # not running under some shell
use strict;
use Getopt::Long;

my ($dbtype, $dbname, $dbuser, $dbpass, $dbhost, $dbport, $help, $id, $node_name, $version);
GetOptions( "type=s"         => \$dbtype,
            "name=s"         => \$dbname,
            "user=s"         => \$dbuser,
            "pass=s"         => \$dbpass,
            "host=s"         => \$dbhost,
            "port=s"         => \$dbport,
            "help"           => \$help,
            "id=s"           => \$id,
            "nodename=s"     => \$node_name,
            "version=s"      => \$version,
          );

unless (defined($dbtype)) {
    print "You must supply a database type with the --type option.\n";
    print "Further help can be found by typing 'perldoc $0'\n";
    exit 1;
}

unless (defined($dbname)) {
    print "You must supply a database name with the --name option.\n";
    print "Further help can be found by typing 'perldoc $0'\n";
    exit 1;
}

if(defined($id) and defined($node_name)) {
    print "You should supply either a node name, or an id, but not both.\n";
    print "Further help can be found by typing 'perldoc $0'\n";
    exit 1;
}

if(not defined($id) and not defined($node_name)) {
    print "You must supply the id of the node with the --id option,\n";
    print " or the node name of the node with the --nodename option.\n";
    print "Further help can be found by typing 'perldoc $0'\n";
    exit 1;
}

if ($help) {
    print "Help can be found by typing 'perldoc $0'\n";
    exit 0;
}

my %setup_modules = ( postgres => "Wiki::Toolkit::Store::Pg",
                      mysql    => "Wiki::Toolkit::Store::MySQL",
                      sqlite  => "Wiki::Toolkit::Store::SQLite"
);

unless ( defined($setup_modules{$dbtype}) ) {
    print "dbtype must be one of 'postgres', 'mysql', and 'sqlite'\n";
    print "further help can be found by typing 'perldoc $0'\n";
    exit 1;
}

# Load classes
require Wiki::Toolkit;
my $class = $setup_modules{$dbtype};
eval "require $class";
if ( $@ ) {
    print "Couldn't 'use' $class: $@\n";
    exit 1;
}

# Create a store instance
my $store;
my $args = "dbname=>'$dbname', dbuser=>'$dbuser'";
if($dbpass) {
    $args .= ", dbpass=>'$dbpass'";
}
if($dbhost) {
    $args .= ", dbhost=>'$dbhost'";
}
if($dbport) {
    $args .= ", dbport=>'$dbport'";
}
eval "\$store = $class->new($args);";

# Create a Wiki instance
my $wiki = Wiki::Toolkit->new(store=>$store);

# If they gave the ID, get the name
if($id) {
    $node_name = $wiki->store->node_name_for_id($id);
    unless($node_name) {
        die("No node found with id '$id'\n");
    }
}

# Report what we're going to do
print "Deleting node with name '$node_name'";
if($id) {
    print " (id $id)";
}
if($version) {
    print " at version $version";
}
print "\n";

# Do the delete
$wiki->delete_node(name => $node_name, version => $version);

# All done
print "done.\n";

=head1 NAME

wiki-toolkit-delete-node - Delete a node stored in a Wiki::Toolkit instance.

=head1 SYNOPSIS

  # Delete a node in a Wiki::Toolkit instance

  wiki-toolkit-delete-node --type postgres
           --name mywiki \
           --user wiki  \
           --pass wiki \
           --host 'db.example.com' \
           --port 1234 \
           --nodename MyNodeName 

  wiki-toolkit-delete-node --type postgres
           --name mywiki \
           --user wiki  \
           --pass wiki \
           --host 'db.example.com' \
           --port 1234 \
           --id 2 \
           --version 7

=head1 DESCRIPTION

Takes four mandatory arguments:

=over 4

=item type

The database type.  Should be one of 'postgres', 'mysql' and 'sqlite'.

=item name

The database name.

=item nodename

The name of the node to be deleted.

=item id

The id of the node to be deleted

=back

four optional arguments:

=over 4

=item user

The user that connects to the database. It must have permission
to create and drop tables in the database.

=item pass

The user's database password.

=item host

The hostname of the machine the database server is running on (omit
for local databases).

=item port

The port number that the database server is expecting connections to.

=item version

The version number of the node to delete

=back

=head1 AUTHOR

Nick Burch

=head1 COPYRIGHT

     Copyright (C) 2006 Nick Burch.  All Rights Reserved.

This code is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=head1 SEE ALSO

L<Wiki::Toolkit>

=cut

1;