def _open(self): try: return TimedRotatingFileHandler._open(self) except IOError as e: # If log file can't be opened then don't log to file sys.stderr.write("warning: %s\n" % e) return open("/dev/null", self.mode)
def _open(self): stream = TimedRotatingFileHandler._open(self) file_stat = os.stat(self.baseFilename) # if file_stat.st_uid == os.geteuid(): curr_mode = file_stat.st_mode os.chmod(self.baseFilename, curr_mode | stat.S_IWOTH | stat.S_IWGRP) return stream
def _open(self): stream = TimedRotatingFileHandler._open(self) file_stat = os.fstat(stream.fileno()) listener_uid = pwd.getpwnam('listener').pw_uid adm_gid = grp.getgrnam('adm').gr_gid if file_stat.st_uid != listener_uid or file_stat.st_gid != adm_gid: old_uid = os.geteuid() try: if old_uid != 0: listener.setuid(0) os.fchown(stream.fileno(), listener_uid, adm_gid) os.fchmod(stream.fileno(), stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP) finally: if old_uid != 0: listener.unsetuid() return stream
def _open(self): prevumask = os.umask(000) rtv = TimedRotatingFileHandler._open(self) os.umask(prevumask) return rtv