diff --git a/SickBeard.py b/SickBeard.py index 1dd4a99bb1..f529503fb0 100755 --- a/SickBeard.py +++ b/SickBeard.py @@ -94,10 +94,6 @@ def daemonize(): os.setsid() # @UndefinedVariable - only available in UNIX - # Make sure I can read my own files and shut out others - prev = os.umask(0) - os.umask(prev and int('077', 8)) - # Make the child a session-leader by detaching from the terminal try: pid = os.fork() # @UndefinedVariable - only available in UNIX diff --git a/lib/configobj.py b/lib/configobj.py index 3d343553b6..19640d4d22 100644 --- a/lib/configobj.py +++ b/lib/configobj.py @@ -2057,7 +2057,11 @@ def write(self, outfile=None, section=None): if self.BOM and ((self.encoding is None) or match_utf8(self.encoding)): # Add the UTF8 BOM output = BOM_UTF8 + output - + + # Protect our configuration file so we can read the configuration file, and others can not. + prev = os.umask(0) + os.umask(prev and int('077', 8)) + if not output.endswith(newline): output += newline if outfile is not None: @@ -2066,6 +2070,8 @@ def write(self, outfile=None, section=None): h = open(self.filename, 'wb') h.write(output) h.close() + # Reset the umask to the original setting + os.umask(prev) def validate(self, validator, preserve_errors=False, copy=False,