#610 LXDM / LXDE Logout doesn't kill all session

closed
dgod.osa
lxdm (60)
5
2014-09-08
2013-09-26
Sonicle Srl
No

Hi, I recently built and packaged lxde 0.4.1 for our upcoming XStreamOS Desktop, based on illumos kernel.
While it works ok under startx (running compmgr+cairo-dock+startlxde), and it correctly kills back to text console on logout,
I cannot manage to logout correctly via lxdm.
If I start lxdm as root, then login via the graphical ui, my lxde desktop starts (as with startx), and I can see all the processes of this user.
Once I try to logout, the lxsession-logout screen appears, then once I click Logout, it returns back to the desktop, not completely sane:
- lxsession has been killed
- cairo-dock shows wrong icons here and there
- I can still see the processes of the user, no more children of lxsession, but of process 1, lxsession is dead.

Because lxdm.conf and Xsession in /etc/lxdm works running ck-launch-session, I checked with ck-list-sessions while inside the desktop through lxdm,
and I find one session with ACTIVE=FALSE, and no session id.
The same, anyway, happens if I just startx.

What should I investigate?
Thanx
Gabriele.

Discussion

<< < 1 2 3 4 > >> (Page 2 of 4)
  • Sonicle Srl
    Sonicle Srl
    2013-10-03

    Great, I'm merging your changes in my patch (the one I had to do for the bind problem).
    At the moment, compile time, I just had to comment out this:

    #define _XPG4_2

    it would issue a redefine warning on illumos base.

    I'm almost done, I'll tell you what happens ;)

     
  • Sonicle Srl
    Sonicle Srl
    2013-10-03

    Ok, something happened!
    Logging out of LXDE takes me immediately to the Logout choices.

    But I'm not sure if it's your change or something I corrected today on consolekit...

    Anyway, it still doesn't logout :(
    I have to go now, tomorrow I'll enable my own g_messages again to debug what's happening during logout, signals etc.

    Thanx so much again ;)
    Gabriele.

     
  • Sonicle Srl
    Sonicle Srl
    2013-10-04

    Something must be wrong in lxcom_dispatch, now.
    Before applying your changes, the callback was called (even though pid was always 0). Now, the callback is never called: the g_message debugs in lxcom_func never appear. Here is the dispatch function, as it is now:

    static gboolean lxcom_dispatch (GSource *source,GSourceFunc callback,gpointer user_data)
    {
    char buf[4096];
    char ctrl[/*CMSG_SPACE(sizeof(LXDM_CRED))*/1024];
    struct sockaddr_un peer;
    struct iovec v={buf,sizeof(buf)};
    struct msghdr h={&peer,sizeof(peer),&v,1,ctrl,sizeof(ctrl),0};
    struct cmsghdr *cmptr;
    int ret;

    while(1)
    {
    peer.sun_family=0;
    ret=recvmsg(self_server_fd,&h,0);

    if(ret<0) break;
    if(ret>4000) continue;
    buf[ret]=0;
    for(cmptr = CMSG_FIRSTHDR(&h);cmptr!=NULL;cmptr=CMSG_NXTHDR(&h,cmptr))
    {
    LXDM_CRED *c;
    int size;
    int argc;
    char **argv;
    GString *res;

    #if defined(__sun)
    size = ucred_size();
    #elif defined(__NetBSD__)
    if (cmptr->cmsg_len < SOCKCREDSIZE(0)) break;
    size = SOCKCREDSIZE(((cred *)CMSG_DATA(cmptr))->sc_ngroups);
    #else
    size = sizeof(LXDM_CRED);
    #endif

    if (cmptr->cmsg_len != CMSG_LEN(size)) break;
    if (cmptr->cmsg_level != SOL_SOCKET) break;
    if (cmptr->cmsg_type != SCM_CREDS) break;
    c=(LXDM_CRED*)CMSG_DATA(cmptr);
    if(g_shell_parse_argv(buf,&argc,&argv,NULL))
    {
    res=((LXComFunc)callback)(user_data,ucred_geteuid(c),ucred_getpid(c),argc,argv);
    g_strfreev(argv);
    if(res)
    {
    do{
    ret=sendto(self_server_fd,res->str,res->len,0,(struct sockaddr*)&peer,sizeof(peer));
    }while(ret==-1 && errno==EINTR);
    g_string_free(res,TRUE);
    if(ret==-1) perror("sendto");
    }
    }
    break;
    }
    }

    return TRUE;
    }

     
  • Sonicle Srl
    Sonicle Srl
    2013-10-04

    Ok, I had to change lxcom_write like this, and I got lxcom_func messages appearing again, still with pid=0 though :(

    static ssize_t lxcom_write(int s,const void *buf,size_t count)
    {
    struct iovec iov[1] ={{(void*)buf,count,}};
    struct msghdr msg = { 0, 0, iov, 1, 0, 0, 0 };
    /* PROBABLY THIS CODE IS NEEDED on __sun #if !defined(linux) && !defined(__NetBSD__) && !defined(__sun) */
    #if !defined(linux) && !defined(__NetBSD__)

    #if defined(__sun)
    int size = ucred_size();
    #else
    int size = sizeof(LXDM_CRED);
    #endif

    char ctrl[CMSG_SPACE(size)];
    struct cmsghdr *cmptr;
    char *p;
    int i;

    msg.msg_control = ctrl;
    msg.msg_controllen = sizeof(ctrl);

    cmptr = CMSG_FIRSTHDR(&msg);
    cmptr->cmsg_len = CMSG_LEN(size);
    cmptr->cmsg_level = SOL_SOCKET;
    cmptr->cmsg_type = SCM_CREDS;
    p=(char*)CMSG_DATA(cmptr);
    for(i=0;i<ucred_size();i++)
    p[i]=0;
    #endif
    return sendmsg(s,&msg,0);
    }

     
  • dgod.osa
    dgod.osa
    2013-10-04

    maybe ucred_getpid() really do nothing.
    in lxcom_func(), change
    if((pid==-1 && uid==0) || pid==getpid())
    to
    if(uid==0 || pid==getpid())

     
  • Sonicle Srl
    Sonicle Srl
    2013-10-04

    Tried your change, but here is debug messages in lxcom_func:

    ** Message: lxcom_func: arg 0 = SIGNAL

    ** Message: lxcom_func: arg 1 = 18

    ** Message: lxcom_func: pid = 0, uid=-1, getpid()=971

    and before:

    ** Message: Adding child watch on pid 1024

    :(

     
  • dgod.osa
    dgod.osa
    2013-10-04

    18 is the SIGCHLD, so everything is ok, it should waitpid now, and call on_session_stop() later.

     
  • Sonicle Srl
    Sonicle Srl
    2013-10-04

    yes, signal is ok, but getpid (me, not child) is 971, passed pid=0, watched pid is 1024.
    I believe there is something not correct in the cred data manipulation before calling callback, that actually get pid=0 instead of child pid....

     
  • dgod.osa
    dgod.osa
    2013-10-04

    getpid() return pid of lxdm, watched pid is pid of session, so they always not same.
    cred data may not correct, but it not important if not concern security. you should make it work first, in current status, it's possible.

     
<< < 1 2 3 4 > >> (Page 2 of 4)