diff --git a/supervisor/options.py b/supervisor/options.py index aa0c8a5c4..4f226c1fd 100644 --- a/supervisor/options.py +++ b/supervisor/options.py @@ -1495,6 +1495,7 @@ def mktempfile(self, suffix, prefix, dir): os._urandomfd = None fd, filename = tempfile.mkstemp(suffix, prefix, dir) os.close(fd) + os.chmod(filename, 0o666 ^ self.configroot.supervisord.umask) return filename def remove(self, path): diff --git a/supervisor/tests/test_options.py b/supervisor/tests/test_options.py index c9f3192a1..84813da37 100644 --- a/supervisor/tests/test_options.py +++ b/supervisor/tests/test_options.py @@ -429,6 +429,22 @@ def test_version(self): self.assertRaises(SystemExit, options.version, None) self.assertEqual(options.stdout.getvalue(), VERSION + '\n') + def test_mktempfile(self): + text = lstrip(""" + [supervisord] + identifier=foo ;comment should not be in identifier + """) + instance = self._makeOne() + instance.configfile = StringIO(text) + instance.realize(args=[]) + options = instance.configroot.supervisord + filename = instance.mktempfile('', 'tmp', None) + try: + mode = os.stat(filename).st_mode & 0o777 + self.assertEqual(oct(mode), oct(0o666 ^ options.umask)) + finally: + os.remove(filename) + def test_options(self): s = lstrip("""[inet_http_server] port=127.0.0.1:8999 @@ -2908,10 +2924,11 @@ def test_clear_autochildlogdir(self): dn = tempfile.mkdtemp() try: instance = self._makeOne() + instance.configroot.supervisord.umask = 0o022 instance.childlogdir = dn sid = 'supervisor' instance.identifier = sid - logfn = instance.get_autochildlog_name('foo', sid,'stdout') + logfn = instance.get_autochildlog_name('foo', sid, 'stdout') first = logfn + '.1' second = logfn + '.2' f1 = open(first, 'w')