[systemd-devel] [PATCH 2/3] logind: session: set_controller should fail if prepare_vt fails

Lennart Poettering lennart at poettering.net
Mon Aug 11 09:13:44 PDT 2014


On Mon, 11.08.14 17:17, David Herrmann (dh.herrmann at gmail.com) wrote:

> 
> Hi
> 
> On Fri, Aug 8, 2014 at 8:45 PM, Olivier Brunel <jjk at jjacky.com> wrote:
> > If controllers can expect logind to have "prepared" the VT (e.g. set it to
> > graphics mode, etc) then TakeControl() should fail if said preparation
> > failed (and session_restore_vt() was called).
> > ---
> >  src/login/logind-session.c | 15 +++++++++------
> >  src/login/logind-session.h |  2 +-
> >  2 files changed, 10 insertions(+), 7 deletions(-)
> >
> > diff --git a/src/login/logind-session.c b/src/login/logind-session.c
> > index 905e73f..3f4e177 100644
> > --- a/src/login/logind-session.c
> > +++ b/src/login/logind-session.c
> > @@ -1003,14 +1003,14 @@ static int session_vt_fn(sd_event_source *source, const struct signalfd_siginfo
> >          return 0;
> >  }
> >
> > -void session_prepare_vt(Session *s) {
> > +int session_prepare_vt(Session *s) {
> >          int vt, r;
> >          struct vt_mode mode = { 0 };
> >          sigset_t mask;
> >
> >          vt = session_open_vt(s);
> >          if (vt < 0)
> > -                return;
> > +                return vt;
> 
> This doesn't work. session_open_vt() returns -1 if the session has no

Humm. David, can we please stick to returning errors as negative errno
values, and not make up "-1" as error in some cases? Please uniformly
only return negative errno codes...

So, please session_open_vt() should be fixed to return -EBUSY or -EINVAL
or something, but not "-1"...

And in that case Olivier's patch looks sane to me...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list