X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fpolicy.py;h=cdff56a7e0fe2a306b58b41fe3db7c922d4d36f4;hb=abcd0f018dc49a218ce70d22e97fc7b654fcf1c8;hp=151cc9b6afc38677798542059844de6cefa06e40;hpb=a767b0167a7ed2bda154a200114187fabbaae207;p=dak.git diff --git a/daklib/policy.py b/daklib/policy.py index 151cc9b6..cdff56a7 100644 --- a/daklib/policy.py +++ b/daklib/policy.py @@ -39,7 +39,7 @@ class UploadCopy(object): given by the C{directory} attribute. The copy will be removed on leaving the with-block. """ - def __init__(self, upload): + def __init__(self, upload, group=None): """initializer @type upload: L{daklib.dbconn.PolicyQueueUpload} @@ -48,6 +48,7 @@ class UploadCopy(object): self.directory = None self.upload = upload + self.group = group def export(self, directory, mode=None, symlink=True, ignore_existing=False): """export a copy of the upload @@ -97,9 +98,17 @@ class UploadCopy(object): def __enter__(self): assert self.directory is None + mode = 0o0700 + symlink = True + if self.group is not None: + mode = 0o2750 + symlink = False + cnf = Config() - self.directory = tempfile.mkdtemp(dir=cnf.get('Dir::TempPath')) - self.export(self.directory, symlink=True) + self.directory = utils.temp_dirname(parent=cnf.get('Dir::TempPath'), + mode=mode, + group=self.group) + self.export(self.directory, symlink=symlink) return self def __exit__(self, *args): @@ -196,7 +205,7 @@ class PolicyQueueUploadHandler(object): fn = os.path.join(self.upload.policy_queue.path, 'COMMENTS', fn1) try: - fh = os.open(fn, os.O_CREAT | os.O_EXCL | os.O_WRONLY) + fh = os.open(fn, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o644) os.write(fh, 'NOTOK\n') os.write(fh, 'From: {0} <{1}>\n\n'.format(utils.whoami(), cnf['Dinstall::MyAdminAddress'])) os.write(fh, reason)