Skip to content

Fix handle FileNotFoundError from os.getcwd()#828

Open
nathan9513-aps wants to merge 1 commit into
abrt:masterfrom
nathan9513-aps:Bug_2477455
Open

Fix handle FileNotFoundError from os.getcwd()#828
nathan9513-aps wants to merge 1 commit into
abrt:masterfrom
nathan9513-aps:Bug_2477455

Conversation

@nathan9513-aps
Copy link
Copy Markdown

@nathan9513-aps nathan9513-aps commented May 15, 2026

Description
Related Bugzilla issue: https://bugzilla.redhat.com/show_bug.cgi?id=2477455

What this PR does: This PR fixes a crash occurring at startup in reporter-bugzilla when the process is invoked from a directory that no longer exists.

Root Cause: When reporter-bugzilla is started, it attempts to fetch the current working directory using os.getcwd() (line 379). However, if the reporter is spawned from a temporary directory (e.g. an ABRT spool directory) that gets deleted before the Python process is fully initialized, the underlying getcwd(2) syscall fails with ENOENT, which in Python raises a FileNotFoundError. This causes the script to crash immediately.

python
Traceback (most recent call last):
File "/usr/bin/reporter-bugzilla", line 379, in
dump_dir_name = os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
Fix: Wrapped the os.getcwd() call in a try/except block to catch the FileNotFoundError. If the error occurs, it falls back to / as a safe placeholder directory.

This is perfectly safe because dump_dir_name will be properly overridden shortly after by the required -d DIR option during argument parsing (or it will fail gracefully downstream with a proper libreport error if no dump directory is provided).

Testing done:

Verified that reporter-bugzilla no longer crashes with a traceback when run from a deleted directory.
Checked that normal execution via the -d parameter continues to work flawlessly.

When the process is started from a directory that has been deleted
(e.g. a temporary ABRT spool directory removed before the reporter
is invoked), os.getcwd() raises FileNotFoundError (ENOENT).

Wrap the call in a try/except and fall back to '/' as a safe
placeholder. The real dump directory is always supplied via the
-d option and will override this default during argument parsing.
@nathan9513-aps
Copy link
Copy Markdown
Author

@msrb Could you take a look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant