[systemd-devel] [PATCH 2/2] logind: do not continue when runtime creation path fails

Lennart Poettering lennart at poettering.net
Tue Feb 10 03:34:55 PST 2015


On Tue, 10.02.15 12:30, Lennart Poettering (lennart at poettering.net) wrote:

> On Sun, 08.02.15 22:21, Philippe De Swert (philippedeswert at gmail.com) wrote:
> 
> > In user_mkdir_runtime_path() there is no need to continue if the
> > creation of the directory fails for whatever reason, as subsequent
> > actions on that directory will fail anyway.
> > 
> > Found with Coverity. Fixes: CID#1237538
> > ---
> >  src/login/logind-user.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/login/logind-user.c b/src/login/logind-user.c
> > index 7b40ef5..a329457 100644
> > --- a/src/login/logind-user.c
> > +++ b/src/login/logind-user.c
> > @@ -322,7 +322,8 @@ static int user_mkdir_runtime_path(User *u) {
> >          if (path_is_mount_point(p, false) <= 0) {
> >                  _cleanup_free_ char *t = NULL;
> >  
> > -                mkdir(p, 0700);
> > +                if(mkdir(p, 0700) < 0)
> > +                         goto fail;
> 
> No, it's completely OK if this fails, and it is very likely that it
> *will* fail, since the dir might already exist, and we thus get
> EEXIST.
> 
> This is a candidate for prefixing with (void), to tell Coverity that
> we knowingly ignore the return value.

Prefixed it now like this, in git.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list