2 ################################################################################
4 # File: $RCSfile: MAPSDeliver,v $
5 # Revision: $Revision: 1.1 $
6 # Description: This script simply delivers the mail. It is separated out so
7 # it can be the only portion that is setgid to the group mail
8 # for the purposes of being able to deliver the mail to the users
10 # Author: Andrew@DeFaria.com
11 # Created: Fri Nov 29 14:17:21 2002
12 # Modified: $Date: 2013/06/12 14:05:47 $
15 # (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
17 ################################################################################
24 # Untaint $FindBin::Bin
28 if ($FindBin::Bin =~ /^(.*)$/) {
39 sub DeliverMail ($$) {
40 my ($userid, $msgfileName) = @_;
42 # Switch to group mail
43 $EGID = getgrnam "mail";
46 if ($userid =~ /^([-\@\w.]+)$/) {
51 open my $maildrop, '>>', "/var/mail/$userid"
52 or return "Unable to open maildrop file (/var/mail/$userid): $!";
55 open my $msgfile, '<', $msgfileName
56 or return "Unable to open msgfile ($msgfileName): $!";
61 # Write msgfile -> $maildrop
77 die 'User id not specified' unless $ARGV [0];
78 die 'Msgfile not specified' unless $ARGV [1];
80 my $userid = shift @ARGV;
81 my $msgfile = shift @ARGV;
83 my $err = DeliverMail $userid, $msgfile;
86 OpenDB 'mapsadmin', 'mapsadmin';
88 MAPSDB::SetContext $userid;