SF.net SVN: tmda: [2041] trunk/tmda

[email protected] Thu, 28 Sep 2006 15:30:12 -0700
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Revision: 2041
          http://svn.sourceforge.net/tmda/?rev=2041&view=rev
Author:   jasonrm
Date:     2006-09-28 15:30:10 -0700 (Thu, 28 Sep 2006)

Log Message:
-----------
Defer incoming deliveries if the sticky bit is set on $HOME.  This allows users 
and processes to safely edit the contents of ~/.tmda/.  This idea comes from 
qmail (See "SAFE QMAIL EDITING" at http://www.qmail.org/man/man5/dot-qmail.html)

This is checked for after $HOME is set for virtual users, but before Defaults is 
imported.

Modified Paths:
--------------
    trunk/tmda/NEWS
    trunk/tmda/bin/tmda-rfilter

Modified: trunk/tmda/NEWS
===================================================================
--- trunk/tmda/NEWS	2006-09-28 20:19:22 UTC (rev 2040)
+++ trunk/tmda/NEWS	2006-09-28 22:30:10 UTC (rev 2041)
@@ -7,6 +7,17 @@
 
 TMDA 1.1.6 "Glen Albyn" --
 
+* tmda-filter will defer incoming deliveries if the sticky bit is set
+  on your home directory (as determined by the $HOME variable).  This
+  allows you to safely edit the contents of ~/.tmda/ on a live system
+  if you need to.  Set the sticky bit with:
+
+  % chmod +t $HOME
+
+  And make sure to remove it when you are done (chmod -t $HOME).  This
+  idea comes from qmail-local.  See "SAFE QMAIL EDITING" at
+  http://www.qmail.org/man/man5/dot-qmail.html
+
 * tmda-ofmipd now has "one-session" mode through the '--one-session'
   command-line option, courtesy of Stephen Warren.  This allows you to
   use xinetd or tcpserver, possibly in conjunction with stunnel, to

Modified: trunk/tmda/bin/tmda-rfilter
===================================================================
--- trunk/tmda/bin/tmda-rfilter	2006-09-28 20:19:22 UTC (rev 2040)
+++ trunk/tmda/bin/tmda-rfilter	2006-09-28 22:30:10 UTC (rev 2041)
@@ -87,6 +87,7 @@
 import getopt
 import os
 import sys
+import stat
 
 try:
     import paths
@@ -172,6 +173,18 @@
             setvuserhomedir(arg)
 
 
+# Defer the delivery if the sticky bit is set on $HOME (chmod +t).
+# This allows users and processes to safely edit the contents of
+# ~/.tmda/.  Remove sticky bit with chmod -t $HOME.  This idea comes
+# from qmail.  Check for the sticky bit here, after $HOME is set for
+# virtual users, but before Defaults is imported.
+homestat = os.stat(os.path.expanduser('~'))
+homesticky = homestat[stat.ST_MODE] & stat.S_ISVTX
+if homesticky:
+    sys.stdout.write('tmda-filter: home directory is sticky.')
+    sys.exit(75)
+
+
 from TMDA import Defaults
 from TMDA import Address
 from TMDA import Cookie


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.