only add apache to trusted-users file if its not already in there
[myplc.git] / plc.d / mail
index 65b0723..01441b7 100755 (executable)
@@ -7,7 +7,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id: mail,v 1.2 2006/04/25 21:18:19 mlhuang Exp $
+# $Id$
 #
 
 # Source function library and configuration
@@ -26,7 +26,14 @@ case "$1" in
        MESSAGE=$"Starting mail server"
        dialog "$MESSAGE"
 
-       service sendmail start
+       # Add apache to list of users that can send mail as others
+       # without a warning, so that the API can send out mail.
+       count=$(grep ^apache /etc/mail/trusted-users|wc -l)
+       if [ $count -eq 0 ] ; then
+               echo "apache" >>/etc/mail/trusted-users
+       fi
+
+       (exec 3>&- 4>&- ; service sendmail start)
        check
 
        result "$MESSAGE"