diff --git a/irrd/daemon/main.py b/irrd/daemon/main.py index a4a07613..9e436c4e 100755 --- a/irrd/daemon/main.py +++ b/irrd/daemon/main.py @@ -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)