Description

Whenever a wiki page is updated, the page's ../cache/pagelinks file permissions is set to a umask of 0600. It should have the umask defined in config.umask (default is 0770).

The invalid umask may cause problems for users trying to make backups of their wiki data.

Steps to reproduce

On any *nix os, create or update a wiki page and check the file permissions of ../cache/pagelinks.

Component selection

The bug is in the update method of caching.py -- moin 1.5.7.

Details

This can be fixed by adding a os.chmod to the update method as shown below. The problem is caused by the use of tempfile.mkstemp which is designed to create a temporary file with a umask of 0600. The alternative mktemp method is deprecated.

   1     def update(self, content, encode=False):
   2         fname = self._filename()
   3         if encode:
   4             content = content.encode(config.charset)
   5         if self.wlock.acquire(1.0):
   6             try:
   7                 # we do not write content to old inode, but to a new file
   8                 # se we don't need to lock when we just want to read the file
   9                 # (at least on POSIX, this works)
  10                 tmp_handle, tmp_fname = tempfile.mkstemp('.tmp', self.key, self.arena_dir)
  11                 os.write(tmp_handle, content)
  12                 os.close(tmp_handle)
  13                 # this is either atomic or happening with real locks set:
  14                 filesys.rename(tmp_fname, fname)
  15                 os.chmod(fname,config.umask) # @@@@@@ fix the file permissions to that set in config.umask
  16             finally:
  17                 self.wlock.release()
  18         else:
  19             self.request.log("Can't acquire write lock in %s" % self.lock_dir)

Workaround

See above.

Discussion

Thanks for the patch!

Plan


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/PagelinksFileHasInvalidPermissions (last edited 2007-10-29 19:21:15 by localhost)