VirtualMailManager/handler.py
branchv0.6.x
changeset 493 30365a87650d
parent 470 807ad4df0774
child 505 3da8c919584f
equal deleted inserted replaced
492:e5c2b3647971 493:30365a87650d
   288         """Create a directory for the `domain` and its accounts."""
   288         """Create a directory for the `domain` and its accounts."""
   289         cwd = os.getcwd()
   289         cwd = os.getcwd()
   290         hashdir, domdir = domain.directory.split(os.path.sep)[-2:]
   290         hashdir, domdir = domain.directory.split(os.path.sep)[-2:]
   291         dir_created = False
   291         dir_created = False
   292         os.chdir(self._cfg.dget('misc.base_directory'))
   292         os.chdir(self._cfg.dget('misc.base_directory'))
       
   293         old_umask = os.umask(0022)
   293         if not os.path.exists(hashdir):
   294         if not os.path.exists(hashdir):
   294             os.mkdir(hashdir, 0711)
   295             os.mkdir(hashdir, 0711)
   295             os.chown(hashdir, 0, 0)
   296             os.chown(hashdir, 0, 0)
   296             dir_created = True
   297             dir_created = True
   297         if not dir_created and not lisdir(hashdir):
   298         if not dir_created and not lisdir(hashdir):
   301             raise VMMError(_(u"The file/directory '%s' already exists.") %
   302             raise VMMError(_(u"The file/directory '%s' already exists.") %
   302                            domain.directory, VMM_ERROR)
   303                            domain.directory, VMM_ERROR)
   303         os.mkdir(os.path.join(hashdir, domdir),
   304         os.mkdir(os.path.join(hashdir, domdir),
   304                  self._cfg.dget('domain.directory_mode'))
   305                  self._cfg.dget('domain.directory_mode'))
   305         os.chown(domain.directory, 0, domain.gid)
   306         os.chown(domain.directory, 0, domain.gid)
       
   307         os.umask(old_umask)
   306         os.chdir(cwd)
   308         os.chdir(cwd)
   307 
   309 
   308     def _make_home(self, account):
   310     def _make_home(self, account):
   309         """Create a home directory for the new Account *account*."""
   311         """Create a home directory for the new Account *account*."""
   310         domdir = account.domain.directory
   312         domdir = account.domain.directory