This file is indexed.

/usr/lib/amanda/application/script-email is in amanda-client 1:3.3.3-2ubuntu1.

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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/usr/bin/perl
# Copyright (c) 2008-2012 Zmanda, Inc.  All Rights Reserved.
#
# 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
#
# Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com

use lib '/usr/lib/amanda/perl';
use strict;
use warnings;
use Getopt::Long;

package Amanda::Script::Script_email;
use base qw(Amanda::Script);
use Amanda::Config qw( :getconf :init );
use Amanda::Debug qw( :logging );
use Amanda::Util qw( :constants );
use Amanda::Paths;
use Amanda::Constants;


sub new {
    my $class = shift;
    my ($execute_where, $config, $host, $disk, $device, $level, $index, $message, $collection, $record, $mailto) = @_;
    my $self = $class->SUPER::new($execute_where, $config);

    $self->{execute_where} = $execute_where;
    $self->{config}        = $config;
    $self->{host}          = $host;
    $self->{disk}          = $disk;
    $self->{device}        = $device;
    $self->{level}         = [ @{$level} ]; # Copy the array
    $self->{index}         = $index;
    $self->{message}       = $message;
    $self->{collection}    = $collection;
    $self->{record}        = $record;
    $self->{mailto}        = [ @{$mailto} ]; # Copy the array

    return $self;
}

sub command_support {
   my $self = shift;

   print "CONFIG YES\n";
   print "HOST YES\n";
   print "DISK YES\n";
   print "MESSAGE-LINE YES\n";
   print "MESSAGE-XML NO\n";
   print "EXECUTE-WHERE YES\n";
}

#define a execute_on_* function for every execute_on you want the script to do
#something
sub command_pre_dle_amcheck {
   my $self = shift;

   $self->sendmail("pre-dle-amcheck");
}

sub command_pre_host_amcheck {
   my $self = shift;

   $self->sendmail("pre-host-amcheck");
}

sub command_post_dle_amcheck {
   my $self = shift;

   $self->sendmail("post-dle-amcheck");
}

sub command_post_host_amcheck {
   my $self = shift;

   $self->sendmail("post-host-amcheck");
}

sub command_pre_dle_estimate {
   my $self = shift;

   $self->sendmail("pre-dle-estimate");
}

sub command_pre_host_estimate {
   my $self = shift;

   $self->sendmail("pre-host-estimate");
}

sub command_post_dle_estimate {
   my $self = shift;

   $self->sendmail("post-dle-estimate");
}

sub command_post_host_estimate {
   my $self = shift;

   $self->sendmail("post-host-estimate");
}

sub command_pre_dle_backup {
   my $self = shift;

   $self->sendmail("pre-dle-backup");
}

sub command_pre_host_backup {
   my $self = shift;

   $self->sendmail("pre-host-backup");
}

sub command_post_dle_backup {
   my $self = shift;

   $self->sendmail("post-dle-backup");
}

sub command_post_host_backup {
   my $self = shift;

   $self->sendmail("post-host-backup");
}

sub command_pre_recover {
   my $self = shift;

   $self->sendmail("pre-recover");
}

sub command_post_recover {
   my $self = shift;

   $self->sendmail("post-recover");
}

sub command_pre_level_recover {
   my $self = shift;

   $self->sendmail("pre-level-recover");
}

sub command_post_level_recover {
   my $self = shift;

   $self->sendmail("post-level-recover");
}

sub command_inter_level_recover {
   my $self = shift;

   $self->sendmail("inter-level-recover");
}

sub sendmail {
   my $self = shift;
   my($function) = @_;
   my $dest;
   if ($self->{mailto}) {
      my $destcheck = join ',', @{$self->{mailto}};
      $destcheck =~ /^([a-zA-Z,]*)$/;
      $dest = $1;
   } else {
      $dest = "root";
   }
   my @args = ( "-s", "$self->{config} $function $self->{host} $self->{disk} $self->{device} " . join (" ", @{$self->{level}}), $dest );
   my $args = join(" ", @args);
   debug("cmd: $Amanda::Constants::MAILER $args\n");
   my $mail;
   open $mail, '|-', $Amanda::Constants::MAILER, @args;
   print $mail "$self->{action} $self->{config} $function $self->{host} $self->{disk} $self->{device} ", join (" ", @{$self->{level}}), "\n";
   close $mail;
}

package main;

sub usage {
    print <<EOF;
Usage: script-email <command> --execute-where=<client|server> --config=<config> --host=<host> --disk=<disk> --device=<device> --level=<level> --index=<yes|no> --message=<text> --collection=<no> --record=<yes|no> --mailto=<email>.
EOF
    exit(1);
}

my $opt_execute_where;
my $opt_config;
my $opt_host;
my $opt_disk;
my $opt_device;
my @opt_level;
my $opt_index;
my $opt_message;
my $opt_collection;
my $opt_record;
my @opt_mailto;

Getopt::Long::Configure(qw{bundling});
GetOptions(
    'execute-where=s' => \$opt_execute_where,
    'config=s'        => \$opt_config,
    'host=s'          => \$opt_host,
    'disk=s'          => \$opt_disk,
    'device=s'        => \$opt_device,
    'level=s'         => \@opt_level,
    'index=s'         => \$opt_index,
    'message=s'       => \$opt_message,
    'collection=s'    => \$opt_collection,
    'record=s'        => \$opt_record,
    'mailto=s'        => \@opt_mailto
) or usage();

my $script = Amanda::Script::Script_email->new($opt_execute_where, $opt_config, $opt_host, $opt_disk, $opt_device, \@opt_level, $opt_index, $opt_message, $opt_collection, $opt_record, \@opt_mailto);

$script->do($ARGV[0]);