Skip to content

Commit

Permalink
Fix incorrect error when logfile exists and is writeable in non-write…
Browse files Browse the repository at this point in the history
…able dir

Ref #937, ref #941, ref #666
  • Loading branch information
mxsasha committed Jan 14, 2025
1 parent e8086cd commit 8997ca7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions irrd/daemon/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,15 @@ def main():
os.setegid(gid)
os.seteuid(uid)
if staged_logfile_path:
staged_logfile_dir = Path(staged_logfile_path).parent
if not os.access(staged_logfile_dir, os.W_OK, effective_ids=True):
logging.critical(
f"Unable to start: logfile {staged_logfile_path} not writable by UID {uid} / GID {gid}"
)
return
# First check if a writable file already exists, if not,
# if we have permission to create the file.
if not os.access(staged_logfile_path, os.W_OK, effective_ids=True):
staged_logfile_dir = Path(staged_logfile_path).parent
if not os.access(staged_logfile_dir, os.W_OK, effective_ids=True):
logging.critical(
f"Unable to start: logfile {staged_logfile_path} not writable by UID {uid} / GID {gid}"
)
return

with daemon.DaemonContext(**daemon_kwargs):
config_init(args.config_file_path)
Expand Down

0 comments on commit 8997ca7

Please sign in to comment.