CVS: tmda/TMDA FilterParser.py,1.54,1.55

"Jason R. Mastaler" <[email protected]>
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Update of /cvsroot/tmda/tmda/TMDA
In directory sc8-pr-cvs1:/tmp/cvs-serv7925/TMDA

Modified Files:
	FilterParser.py 
Log Message:
Bugfix.  The underlying utimes() system call will fail if the caller
isn't the owner of the file and we specify a specific time argument.
However, if the time argument is null (meaning current time), the
caller only needs permission to write the file.

utimes(2) on FreeBSD explains better:

     The access and modification times of the file named by path or
     referenced by fd are changed as specified by the argument times.

     If times is NULL, the access and modification times are set to
     the current time.  The caller must be the owner of the file,
     have permission to write the file, or be the super-user.

     If times is non-NULL, it is assumed to point to an array of two
     timeval structures.  The access time is set to the value of the
     first element, and the modification time is set to the value of
     the second element.  The caller must be the owner of the file or
     be the super-user.

     In either case, the inode-change-time of the file is set to the
     current time.

A simple python experiment validates this:

Python 2.1.3 (#1, Aug  9 2002, 23:10:42) 
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "copyright", "credits" or "license" for more information.
>>> import os, time
>>> now = time.time()
>>> os.utime('file', (now, now))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OSError: [Errno 1] Operation not permitted: 'file'
>>> os.utime('file', None)
>>> 

This cropped up when using the -autodbm option to rebuild a db owned
by another user.  The fix is to simply specify 'None' as the times
argument to os.utime().  This doesn't change anything as we were using
the current time before anyway.  The ability to use 'None' was added
in Python 2.0 which is why I suspect that we didn't implement it this
way in the first place.

Thanks to Chris Hardie for catching this.


Index: FilterParser.py
===================================================================
RCS file: /cvsroot/tmda/tmda/TMDA/FilterParser.py,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- FilterParser.py	27 Apr 2003 07:58:17 -0000	1.54
+++ FilterParser.py	8 May 2003 02:30:15 -0000	1.55
@@ -819,8 +819,7 @@
             if db_mtime <= txt_mtime:
                 if build_func(basename):
                     if os.path.exists(surrogate):
-                        mtime = time.time()
-                        os.utime(surrogate, (mtime, mtime))
+                        os.utime(surrogate, None)
                     else:
                         os.close(os.open(surrogate, os.O_CREAT, 0600))
                 else:

_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.