This file is indexed.

/usr/bin/mha-dbrecover is in mhonarc 2.6.19-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
207
208
209
#!/usr/bin/perl
use lib qw(/usr/share/mhonarc);
#!/usr/bin/perl
##---------------------------------------------------------------------------##
##  File:
##	$Id: mha-dbrecover,v 1.9 2009/05/03 20:11:27 ehood Exp $
##  Author:
##      Earl Hood       mhonarc@mhonarc.org
##  Description:
##      Program to rebuild the MHonArc database file from message files.
##---------------------------------------------------------------------------##
##    MHonArc -- Internet mail-to-HTML converter
##    Copyright (C) 1998,2001	Earl Hood, mhonarc@mhonarc.org
##
##    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
##---------------------------------------------------------------------------##

package mha_dbrecover;

use Getopt::Long;

##---------------------------------------------------------------------------##
##				Main routine				     ##
##---------------------------------------------------------------------------##

MAIN: {
    unshift(@INC, 'lib');	# Should I leave this line in?

    ## Grab options from @ARGV unique to this program
    my %opts = ( );
    Getopt::Long::Configure('pass_through');
    GetOptions(\%opts,
      'dbr-startnum=i',
      'dbr-endnum=i'
    );
    my $startnum = $opts{'dbr-startnum'} || 0;
    my $endnum   = $opts{'dbr-endnum'}   || -1;

    ## Reset pass-through of options
    Getopt::Long::Configure('no_pass_through');

    ## Initialize MHonArc
    require 'mhamain.pl' || die qq/ERROR: Unable to require "mhamain.pl"\n/;
    mhonarc::initialize();

    ## Load library for reading message files
    require 'mhmsgfile.pl' ||
    	die qq/ERROR: Unable to require "mhmsgfile.pl"\n/;

    ## Open archive: We use special -noarg option to tell mhonarc
    ## to not do any processing, just open archive and lock it.
    unshift(@ARGV, '-noarg', '-lock');
    if (!mhonarc::open_archive()) {
	# unable to open, so abort processing
	die "ERROR: Unable to open archive\n";
    }

    ## do it
    eval {
	local(*DIR);
	if (!opendir(DIR, $mhonarc::OUTDIR)) {
	    # unable to open archive directory
	    die qq/ERROR: Unable to open "$mhonarc::OUTDIR": $!\n"/;
	}

	print STDOUT "Rebuilding database in $mhonarc::OUTDIR ...\n"
	    unless $mhonarc::QUIET;

	## Define regular expressing for matching message files:
	## we use message prefix and extension settings as defined
	## by mhonarc.  Make sure to capture message number from
	## filename.
	my $msgrex = '^'.
		     "\Q$mhonarc::MsgPrefix".
		     '(\d+)\.'.
		     "\Q$mhonarc::HtmlExt".
		     '$';
	local($_);
	my(@file);
	foreach (readdir(DIR)) {
	    # skip if not a message file
	    next  unless /$msgrex/o;
	    # skip if number less than start
	    next  if $1 < $startnum;
	    # skip if number greater than end
	    next  if ($endnum >= 0) && ($1 > $endnum);

	    # add file to list to process
	    push @file, $_;
	}
	closedir(DIR);
	if (!@file) {
	    # nothing found to process
	    die qq/ERROR: No message files found\n/;
	}

	## Read files.  Use function in mhmsgfile.pl to extract data.
	my($file, $num);
	foreach (@file) {
	    # get number for loading into mhonarc data structures
	    ($num) = $_ =~ /$msgrex/o;
	    print STDOUT "."  unless $mhonarc::QUIET;
	    $file = join($mhonarc::DIRSEP, $mhonarc::OUTDIR, $_);
	    # load date from message file into mhonarc
	    mhonarc::load_data_from_msg_file($file, $num);
	}

	## Define other data structures that need to be recovered.
	$mhonarc::NumOfMsgs = scalar(@file);
	@mhonarc::MListOrder = mhonarc::sort_messages();
        $mhonarc::LastMsgNum = mhonarc::get_last_msg_num();
	mhonarc::compute_follow_ups(\@mhonarc::MListOrder);
	mhonarc::compute_threads();

	## Output recovered database file
	print STDOUT "\nWriting database ...\n"
	    unless $mhonarc::QUIET;
	mhonarc::output_db($mhonarc::DBPathName);
    };
    my $ec = 0;
    if ($@) { warn $@; $ec = 1; }

    mhonarc::close_archive();
    exit($ec);
}

##---------------------------------------------------------------------------##
1;

__END__

=head1 NAME

mha-dbrecover - rebuild a MHonArc archive database

=head1 SYNOPSIS

S<B<mha-dbrecover> [I<options>]>

=head1 DESCRIPTION

B<mha-dbrecover> is a utility program that is part of the B<MHonArc>
software package.  The program allows can be used to rebuild a
B<MHonArc> archive database from the HTML message files.  This allows
database recovery if the database gets corrupted or accidentally
deleted.

The documentation for B<MHonArc> is distributed in HTML format.
Due to its size and organization, it is not suited for manpage
format.  Consult your system administrator for where the documentation
has been installed, or see L<"AVAILABILITY"> on where you can
access the documentation on the web.

=head1 OPTIONS

B<mha-dbrecover> takes all the options available to B<mhonarc> along
with the following additional options:

=over

=item C<-dbr-startnum> I<#>

The starting message number to recover data from.  This option is
useful if you have many message files in a directory, but you only
want to recover a subset of the files.

If this option is not specified, the starting number is 0.

=item C<-dbr-endnum> I<#>

The ending message number to recover data from.  This option is
useful if you have many message files in a directory, but you only
want to recover a subset of the files.

If this option is not specified, all messages starting from
C<-dbr-startnum> will be recovered.

=back

B<NOTE:> Only a subset of the options available to B<mhonarc>
are actually supported since many options are not applicable for
recovering operations.

=head1 AVAILABILITY

E<lt>I<http://www.mhonarc.org/>E<gt>

=head1 AUTHOR

Earl Hood, mhonarc@mhonarc.org

MHonArc comes with ABSOLUTELY NO WARRANTY and MHonArc may be copied only
under the terms of the GNU General Public License, which may be found in
the MHonArc distribution.

=cut