[PATCH 4/4] vmcore: fail gracefully if dump_dir is not accessible

Jiri Moskovcak jmoskovc at redhat.com
Tue Sep 3 06:41:25 UTC 2013


On 09/02/2013 11:27 AM, Richard Marko wrote:
> Previously os.listdir on inaccessible dump_dir resulted
> in exception. This replaces insufficient os.path.exists check
> (which is already handled in abrt-vmcore.service file) with
> os.access call which checks for dir readability.
>
> Signed-off-by: Richard Marko <rmarko at redhat.com>
> ---
>   src/hooks/abrt_harvest_vmcore.py.in | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
> index 3951307..ea331c0 100644
> --- a/src/hooks/abrt_harvest_vmcore.py.in
> +++ b/src/hooks/abrt_harvest_vmcore.py.in
> @@ -186,8 +186,10 @@ def harvest_vmcore():
>
>       dump_dir = parse_kdump()
>
> -    if not os.path.exists(dump_dir):
> -        sys.exit(0)
> +    if not os.access(dump_dir, os.R_OK):
> +        sys.stderr.write("Dump directory '%s' not accessible. "
> +                         "Exiting.\n" % dump_dir)
> +        sys.exit(1)

- even with this improved code it can throw an exception, because it's 
racy, so the exception should be handled also later when the code is 
accessing the dump_dir (line 219+)

>
>       # Wait for abrtd to start. Give it at least 1 second to initialize.
>       for i in xrange(10):
>



More information about the Crash-catcher mailing list