[systemd-devel] [PATCH 1/3] core: check return value of rm_rf_dangerous and warn if it fails

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Wed Mar 27 09:07:14 PDT 2013


On Wed, Mar 27, 2013 at 03:16:35PM +0100, Vaclav Pavlin wrote:
> From: Václav Pavlín <vpavlin at redhat.com>
> 
> ---
>  src/core/execute.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/core/execute.c b/src/core/execute.c
> index bc876a3..936e7d8 100644
> --- a/src/core/execute.c
> +++ b/src/core/execute.c
> @@ -1559,10 +1559,16 @@ void exec_context_tmp_dirs_done(ExecContext *c) {
>  
>          for(dirp = dirs; *dirp; dirp++) {
>                  char *dir;
> -                rm_rf_dangerous(*dirp, false, true, false);
> +                int r=0;
>  
> +                r = rm_rf_dangerous(*dirp, false, true, false);
>                  dir = dirname(*dirp);
> -                rmdir(dir);
> +                if (r<0)
> +                        log_warning("Failed to remove content of tmp_dir %s.", dir);
> +                else {
> +                        dir = dirname(*dirp);
> +                        rmdir(dir);
> +                }
>  
>                  free(*dirp);
>          }
Applied this one with a tweak to check rmdir return value too.

Zbyszek


More information about the systemd-devel mailing list