This file is indexed.

/usr/bin/dspam_notify is in dspam-webfrontend 3.10.2+dfsg-13.

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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/usr/bin/perl
#
# $Id: dspam_notify,v 1.06 2011/11/03 11:58:15 sbajic Exp $

use Net::SMTP;

if (!(-e "/etc/dspam/dspam_notify.conf") || !(-r "/etc/dspam/dspam_notify.conf")) {
  die("Missing configuration file: /etc/dspam/dspam_notify.conf");
}
require "/etc/dspam/dspam_notify.conf";

# Enter the location of you dspam.conf, dspam binary and path to dspam_admin/dspam_stats.
$DSPAMCONF = '/etc/dspam/dspam.conf';
$DSPAM_BINARY = '/usr/bin/dspam';
$BINDIR = '/usr/bin';

######################################
# No need to config below this point.#
######################################


#Build the Quarantine URL
$QUARANTINE_URL = $DSPAM_URL . '/dspam.cgi?template=quarantine';

# Autodetect scale and preference extension support
$LARGE_SCALE = 0;
$DOMAIN_SCALE = 0;
$PREFERENCES_EXTENSION = 0;
do {
  my $x = `$DSPAM_BINARY --version`;
  $PREFERENCES_EXTENSION = 1 if ($x =~ /--enable-preferences-extension/);
  $LARGE_SCALE = 1 if ($x =~ /--enable-large-scale/);
  $DOMAIN_SCALE = 1 if ($x =~ /--enable-domain-scale/) ;
};

# Date Formatting
my ($SEC,$MIN,$HOUR,$MDAY,$MON,$YEAR,$WDAY,$YDAY,$ISDST) = localtime(time);
  
# Array containing Days of the week abreviations
@WEEKDAYS = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
    
# Array containing Month abreviations
@MONTHS = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
    
$D = (localtime)[6];
$M = (localtime)[4];

$DAY_ABR = $WEEKDAYS[$D];
$MONTH_ABR = $MONTHS[$M];
$DAY_NUM = $MDAY; 
$YEAR += 1900;

$TODAY = $DAY_ABR . " " . $MONTH_ABR . " " . sprintf("%2s", $DAY_NUM);

# Get the location of DSPAM home and if AllowOverride is set for dailyQuarantineSummary
$DSPAMHOME = "";
$ALLOW_OVERRIDE = "";
$DEFAULT_PREF = "";
open(DCONF, $DSPAMCONF) || die("Could not open " . $DSPAMCONF . " file!");
while(<DCONF>) {
  chomp;
  my($directive, $value) = split(/\s+/);
  $DSPAMHOME = $value if ($directive eq "Home");
  $ALLOW_OVERRIDE = "on" if ($directive eq "AllowOverride" && $value eq "dailyQuarantineSummary");
  if ($directive eq "Preference") {
    if ($value =~ /^\s*[\"\']?dailyQuarantineSummary[\t ]*=[\t ]*on[\"\']?/) {
      $DEFAULT_PREF = "on";
    } else {
      $DEFAULT_PREF = "off";
    }
  }
  last if($DSPAMHOME ne "" && $ALLOW_OVERRIDE ne "" && $DEFAULT_PREF ne "");
}
close(DCONF);
$ALLOW_OVERRIDE = "off" if($ALLOW_OVERRIDE eq "");
$DEFAULT_PREF = "off" if($DEFAULT_PREF eq "");
if (! -d $DSPAMHOME) {
  die("Could not determine DSPAM home!");
}

# Create list of users having TP bigger then zero
open(IN, "$BINDIR/dspam_stats|");
while(<IN>) {
  chomp;
  s/:/ /g;
  my($username, $tp, $tn, $fp, $fn, $sc, $nc) = (split(/\s+/))[0,2,4,6,8,10,12];
  if ($tp eq "") {
    $_ = <IN>;
    s/:/ /g;
    ($tp, $tn, $fp, $fn, $sc, $nc) = (split(/\s+/))[2,4,6,8,10,12];
  }
  push(@RECIPIENT_LIST, $username) if $tp != 0;
}
close(IN);

# Get default user preference for dailyQuarantineSummary
if ($PREF_CHECK == 1 && $PREFERENCES_EXTENSION == 1) {
  open(PIPE, "$BINDIR/dspam_admin agg pref 'default'|");
  while(<PIPE>) {
    chomp;
    my($directive, $value) = split(/\=/);
    if ($directive eq "dailyQuarantineSummary") {
      $DEFAULT_PREF = $value;
      last;
    }
  }
  close(PIPE);
}

# Gather Recipient Quarantine Info
foreach $RECIPIENT (@RECIPIENT_LIST) {

  # Get User Preference from dspam_admin
  if ($ALLOW_OVERRIDE eq "on") {						# Check for Allow Overides
    open(PIPE, "$BINDIR/dspam_admin li pref " . quotemeta($RECIPIENT) . "|");
    while(<PIPE>) {
      chomp;
      my($directive, $value) = split(/\=/);
      if ($directive eq "dailyQuarantineSummary") {
        if ($value ne "on" && $value ne "off") {
          $USER_PREF = $DEFAULT_PREF;						# User Preference in valid, use default preference
        } else {
          $USER_PREF = $value;
        }
        last;
      }
    }
    close(PIPE);
  } else {
    $USER_PREF = $DEFAULT_PREF;							# Overrides off, use default preference
  }

   # Build path to Quarantine .mbox
  if ($DOMAIN_SCALE == 1) {							# Format Quarantine path for Domain Scale
    my($u, $D) = (split(/@/, $RECIPIENT));
    $MBOX = $DSPAMHOME . "/data/" . $D . "/" . $u . "/" . $u . ".mbox";
  } elsif ($LARGE_SCALE == 1) {							# Format Quarantine path for Large Scale
    $u = substr($RECIPIENT, 0, 1);
    $s = substr($RECIPIENT, 1, 1);
    $MBOX = $DSPAMHOME . "/data/" . $u . "/" . $s . "/" . $RECIPIENT . "/" . $RECIPIENT . ".mbox";
  } else {									# Format Quarantine path for Normal Scale
    $MBOX = $DSPAMHOME . "/data/" . $RECIPIENT . "/" . $RECIPIENT . ".mbox";
  }

  # Get total amount of quarantine messages and their signature
  $NEW = 0;
  $TOTAL = 0;
  $SIG = '';
  @Q_SIG = ();
  @Q_SUBJECT = ();
  if ($USER_PREF ne "off" && -e $MBOX) {					# Check if .mbox file exists and user pref
    open(MBOX, "<$MBOX") || die("Could not open " . $MBOX . " file!");
    while(<MBOX>) {
      s/\r?\n//;
      next if ($_ !~ /^From QUARANTINE/);
      $TOTAL++;									# Count Total messages in Quarantine
      $NEW++ if ($_ =~ /^From QUARANTINE $TODAY/);				# Count New messages in Quarantine
      $QSUBJECT = '<None Specified>';
      while(<MBOX>) {
        s/\r?\n//;
        last if ($_ eq "");
        my($key, $val) = split(/\: ?/, $_, 2);
        if ($key =~ /^Subject$/i) {
          $val =~ s/^\s+//;
          $val =~ s/\s+$//;
          $QSUBJECT = $val if ($val ne "");
        }
        if ($key =~ /^X\-DSPAM\-Signature$/) {
          push(@Q_SIG, $val);
          $QSUBJECT =~ s/</&lt;/g;
          $QSUBJECT =~ s/>/&gt;/g;
          $QSUBJECT = substr($QSUBJECT, 0, 50) . "..." if (length($QSUBJECT)>50);
          push(@Q_SUBJECT, $QSUBJECT);
          last;
        }
      }
    }
    close(MBOX);
  }
  push(@Q_SUBJECT_ITEMS, join("\n", @Q_SUBJECT));
  push(@Q_SIG_ITEMS, join("\n", @Q_SIG));
  push(@Q_NEW_ITEMS, $NEW);							# Send Count to Array for later use
  push(@Q_TOTAL_ITEMS, $TOTAL);							# Send Count to Array for later use
  @Q_SUBJECT = ();
  @Q_SIG = ();
}


# Send some emails
@Q_ROW_COLOR=('CCCCCC','FFFFFF');
$SMTP = Net::SMTP->new(								# Establish SMTP Connection
	Host => $SERVER . ":" . $PORT,
	Timeout => 30) || die ("Could not connect to SMTP server " . $SERVER . ":" . $PORT . "; $!");
for ($I = 0; $I <= $#RECIPIENT_LIST; $I++) {					# Loop through Recipients List and send the message
  if (@Q_TOTAL_ITEMS[$I] != 0) {						# Don't send reminders to users with empty quarantines
    $SMTP->mail($FROM_EMAIL);
    $SMTP->to($RECIPIENT_LIST[$I]);
    $SMTP->data();
    $SMTP->datasend("From: $FROM_NAME <$FROM_EMAIL>\n");
    $SMTP->datasend("To: $RECIPIENT_LIST[$I]\n");
    $SMTP->datasend("Subject: $SUBJECT\n");
    $SMTP->datasend("Mime-Version: 1.0\n");
    $SMTP->datasend("Content-Type: text/html; charset=UTF-8\n");
    $SMTP->datasend("\n");
    $SMTP->datasend("<HTML>\n");
    $SMTP->datasend("<HEAD>\n");
    $SMTP->datasend("<TITLE>DSPAM Quarantine Summary for $RECIPIENT_LIST[$I]</TITLE>\n");
    $SMTP->datasend("<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=utf-8'>\n");
    $SMTP->datasend("</HEAD>\n");
    $SMTP->datasend("<BODY>\n");
    $SMTP->datasend($BODY ."\n");
    $SMTP->datasend("<TABLE>\n");
    $SMTP->datasend("<TR><TD>Quarantine Summary for</TD><TD>$RECIPIENT_LIST[$I]</TD></TR>\n");
    $SMTP->datasend("<TR><TD>Date</TD><TD>$TODAY, $YEAR</TD></TR>\n");
    $SMTP->datasend("<TR><TD COLSPAN='2'>&nbsp;</TD></TR>\n");
    $SMTP->datasend("<TR><TD>New Messages</TD><TD>@Q_NEW_ITEMS[$I]</TD></TR>\n");
    $SMTP->datasend("<TR><TD>Total Messages</TD><TD>@Q_TOTAL_ITEMS[$I]</TD></TR>\n");
    $SMTP->datasend("</TABLE>\n");
    $SMTP->datasend("<BR>\n");
    $SMTP->datasend("<TABLE>\n");
    @Q_SUBJECT = split(/\n/,@Q_SUBJECT_ITEMS[$I]);
    @Q_SIG = split(/\n/,@Q_SIG_ITEMS[$I]);
    for ($J = 0; $J <= $#Q_SIG; $J++) {
      my $QCOMMAND = $QUARANTINE_URL . "&user=" . $RECIPIENT_LIST[$I] . "&signatureID=" . @Q_SIG[$J];
      my $QROW_COLOR = 0;
      $QROW_COLOR = 1 if(($J % 2) != 0);
      $SMTP->datasend("<TR>");
      if ($J >= $MAX_ITEMS) {
        $SMTP->datasend("<TD COLSPAM='3' STYLE='background-color:" . @Q_ROW_COLOR[$QROW_COLOR] . ";'>To display more then " . $MAX_ITEMS . " messages, please visit the DSPAM Control Center.</TD>\n");
        $SMTP->datasend("</TR>\n");
        last;
      }
      $SMTP->datasend("<TD STYLE='background-color:" . @Q_ROW_COLOR[$QROW_COLOR] . ";'>" . @Q_SUBJECT[$J] . "</TD>");
      $SMTP->datasend("<TD STYLE='background-color:" . @Q_ROW_COLOR[$QROW_COLOR] . ";'><A HREF='" . $QCOMMAND . "&command=viewMessage' TARGET='_blank'>View</A></TD>");
      $SMTP->datasend("<TD STYLE='background-color:" . @Q_ROW_COLOR[$QROW_COLOR] . ";'><A HREF='" . $QCOMMAND . "&command=processFalsePositive' TARGET='_blank'>Release</A></TD>");
      $SMTP->datasend("</TR>\n");
    }
    $SMTP->datasend("</TABLE>\n");
    $SMTP->datasend("<BR>\n");
    $SMTP->datasend("Please remember to check <A HREF='$QUARANTINE_URL' TARGET='_blank'>Your Quarantine</A> regularly.\n");
    $SMTP->datasend("</BODY>\n");
    $SMTP->datasend("</HTML>\n");
    $SMTP->dataend();
  }
}
$SMTP->quit;									# Close SMTP Connection