Date: Wednesday, July 29, 2015 @ 18:15:33 Author: bgyorgy Revision: 137597
upgpkg: lxdm 0.5.1-2 Kill user processes on logout (fix second login with systemd >= 222); update Xsession file with changes from LightDM Added: lxdm/trunk/lxdm.git-2abf1d971198d224c68b20c56862df2fe7c6a648.patch lxdm/trunk/lxdm.git-4dfe7924a220643600be58861b01f186225fe251.patch Modified: lxdm/trunk/PKGBUILD lxdm/trunk/Xsession ---------------------------------------------------------+ PKGBUILD | 14 + Xsession | 11 + lxdm.git-2abf1d971198d224c68b20c56862df2fe7c6a648.patch | 118 ++++++++++++++ lxdm.git-4dfe7924a220643600be58861b01f186225fe251.patch | 64 +++++++ 4 files changed, 202 insertions(+), 5 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2015-07-29 08:59:12 UTC (rev 137596) +++ PKGBUILD 2015-07-29 16:15:33 UTC (rev 137597) @@ -6,7 +6,7 @@ pkgname=lxdm pkgver=0.5.1 -pkgrel=1 +pkgrel=2 pkgdesc='Lightweight X11 Display Manager' arch=('i686' 'x86_64') url="https://sourceforge.net/projects/lxdm/" @@ -24,15 +24,23 @@ source=(http://downloads.sourceforge.net/lxdm/$pkgname-$pkgver.tar.xz default-config.patch lxdm.pam - Xsession) + Xsession + lxdm.git-2abf1d971198d224c68b20c56862df2fe7c6a648.patch + lxdm.git-4dfe7924a220643600be58861b01f186225fe251.patch) md5sums=('9e03ce5f6d303bc9b689732401934dc6' 'f0ae6c072f151104c53a030fd7757821' 'c941ef896248bc7c03901b513490425c' - 'd9c8f8c9e6de52dbc389696454c8f572') + '6ff73570368501a06ee7badc8e415d0a' + '54c3de1d6108f8d68dea31622dd976e1' + '2522db72aeddffc22e349bfea24ae48e') prepare(){ cd "$srcdir/$pkgname-$pkgver" + # Kill user processes on logout (fix second login with systemd >= 222) + patch -Np1 -i ../lxdm.git-2abf1d971198d224c68b20c56862df2fe7c6a648.patch + patch -Np1 -i ../lxdm.git-4dfe7924a220643600be58861b01f186225fe251.patch + # Adjust Arch-specific settings patch -Np1 -i ../default-config.patch Modified: Xsession =================================================================== --- Xsession 2015-07-29 08:59:12 UTC (rev 137596) +++ Xsession 2015-07-29 16:15:33 UTC (rev 137597) @@ -23,7 +23,7 @@ for file in "/etc/X11/Xresources" "$HOME/.Xresources"; do if [ -f "$file" ]; then echo "Loading resource: $file" - xrdb -nocpp -merge "$file" + xrdb -merge "$file" fi done @@ -48,7 +48,7 @@ unset XKB_IN_USE -# Run all system xinitrc shell scripts. +# Run all system xinitrc shell scripts xinitdir="/etc/X11/xinit/xinitrc.d" if [ -d "$xinitdir" ]; then for script in $xinitdir/*; do @@ -59,6 +59,13 @@ done fi +# Run user xsession shell script +script="$HOME/.xsession" +if [ -x "$script" -a ! -d "$script" ]; then + echo "Loading xsession script $script" + . "$script" +fi + echo "X session wrapper complete, running session $LXSESSION" exec $LXSESSION Added: lxdm.git-2abf1d971198d224c68b20c56862df2fe7c6a648.patch =================================================================== --- lxdm.git-2abf1d971198d224c68b20c56862df2fe7c6a648.patch (rev 0) +++ lxdm.git-2abf1d971198d224c68b20c56862df2fe7c6a648.patch 2015-07-29 16:15:33 UTC (rev 137597) @@ -0,0 +1,118 @@ +From 2abf1d971198d224c68b20c56862df2fe7c6a648 Mon Sep 17 00:00:00 2001 +From: dgod <dgod....@gmail.com> +Date: Fri, 24 Jul 2015 20:25:05 +0800 +Subject: [PATCH] try kill left process when session end, by check the + XDG_SESSION_ID + +--- + src/pam.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 72 insertions(+) + +diff --git a/src/pam.c b/src/pam.c +index 43bd687..940fdd2 100644 +--- a/src/pam.c ++++ b/src/pam.c +@@ -42,6 +42,7 @@ + #include <errno.h> + #include <poll.h> + #include <sys/stat.h> ++#include <sys/wait.h> + + #include <pwd.h> + #include <grp.h> +@@ -300,12 +301,72 @@ int lxdm_auth_session_begin(LXDM_AUTH *a,const char *name,int tty,int display,ch + } + err = pam_open_session(a->handle, 0); /* FIXME pam session failed */ + if( err != PAM_SUCCESS ) ++ { + g_warning( "pam open session error \"%s\"\n", pam_strerror(a->handle, err)); ++ } + else ++ { + a->in_session=1; ++ } + return 0; + } + ++static int proc_filter(const struct dirent *d) ++{ ++ int c=d->d_name[0]; ++ return c>='1' && c<='9'; ++} ++ ++static int check_process_sid(int pid,const char *sid) ++{ ++ char path[128]; ++ FILE *fp; ++ gchar *env_data,*p; ++ gsize env_len; ++ int res=0; ++ ++ sprintf(path,"/proc/%d/environ",pid); ++ if(!g_file_get_contents(path,&env_data,&env_len,NULL)) ++ { ++ return 0; ++ } ++ for(p=env_data;p!=NULL && p-env_data<env_len;) ++ { ++ if(!strncmp(p,"XDG_SESSION_ID=",15)) ++ { ++ if(!strcmp(sid,p+15)) ++ res=1; ++ break; ++ } ++ p=strchr(p,'\0'); ++ if(!p) break;p++; ++ } ++ g_free(env_data); ++ ++ return res; ++} ++ ++static void kill_left_process(const char *sid) ++{ ++ int self=getpid(); ++ struct dirent **list; ++ int i,n; ++ ++ n=scandir("/proc",&list,proc_filter,0); ++ if(n<0) return; ++ for(i=0;i<n;i++) ++ { ++ int pid=atoi(list[i]->d_name); ++ if(pid==self || pid<=1) ++ continue; ++ if(check_process_sid(pid,sid)) ++ { ++ kill(pid,SIGKILL); ++ } ++ } ++ free(list); ++} ++ + int lxdm_auth_session_end(LXDM_AUTH *a) + { + int err; +@@ -313,8 +374,19 @@ int lxdm_auth_session_end(LXDM_AUTH *a) + return 0; + if(a->in_session) + { ++ char xdg_session_id[32]={0}; ++ const char *p=pam_getenv(a->handle,"XDG_SESSION_ID"); ++ if(p!=NULL) snprintf(xdg_session_id,32,"%s",p); + err = pam_close_session(a->handle, 0); ++ if( err != PAM_SUCCESS ) ++ { ++ g_warning( "pam close session error \"%s\"\n", pam_strerror(a->handle, err)); ++ } + a->in_session=0; ++ if(p!=NULL) ++ { ++ kill_left_process(xdg_session_id); ++ } + } + pam_end(a->handle, err); + a->handle = NULL; +-- +2.1.3 + Added: lxdm.git-4dfe7924a220643600be58861b01f186225fe251.patch =================================================================== --- lxdm.git-4dfe7924a220643600be58861b01f186225fe251.patch (rev 0) +++ lxdm.git-4dfe7924a220643600be58861b01f186225fe251.patch 2015-07-29 16:15:33 UTC (rev 137597) @@ -0,0 +1,64 @@ +From 4dfe7924a220643600be58861b01f186225fe251 Mon Sep 17 00:00:00 2001 +From: dgod <dgod....@gmail.com> +Date: Sun, 26 Jul 2015 09:59:29 +0800 +Subject: [PATCH] close left processes more graceful + +--- + src/pam.c | 4 +++- + src/xconn.c | 4 ++-- + 2 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/src/pam.c b/src/pam.c +index 940fdd2..8020b51 100644 +--- a/src/pam.c ++++ b/src/pam.c +@@ -372,6 +372,7 @@ int lxdm_auth_session_end(LXDM_AUTH *a) + int err; + if(!a->handle) + return 0; ++ killpg(a->child,SIGTERM); + if(a->in_session) + { + char xdg_session_id[32]={0}; +@@ -385,6 +386,7 @@ int lxdm_auth_session_end(LXDM_AUTH *a) + a->in_session=0; + if(p!=NULL) + { ++ usleep(100*1000); + kill_left_process(xdg_session_id); + } + } +@@ -472,7 +474,7 @@ void switch_user(struct passwd *pw, const char *run, char **env) + g_spawn_command_line_sync ("/etc/lxdm/PreLogin",NULL,NULL,NULL,NULL); + + if( !pw || initgroups(pw->pw_name, pw->pw_gid) || +- setgid(pw->pw_gid) || setuid(pw->pw_uid)/* || setsid() == -1 */) ++ setgid(pw->pw_gid) || setuid(pw->pw_uid) || setpgid(0,0)==-1/* || setsid() == -1 */) + exit(EXIT_FAILURE); + chdir(pw->pw_dir); + fd=open(".xsession-errors",O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR); +diff --git a/src/xconn.c b/src/xconn.c +index 5c62d4b..df4824f 100644 +--- a/src/xconn.c ++++ b/src/xconn.c +@@ -172,7 +172,7 @@ void xconn_close(xconn_t c) + free(c); + } + +-#if 0 ++#if 1 + static xcb_window_t xconn_get_root(xconn_t c) + { + const xcb_setup_t *setup; +@@ -185,7 +185,7 @@ static xcb_window_t xconn_get_root(xconn_t c) + + void xconn_clean(xconn_t c) + { +-#if 0 ++#if 1 + xcb_query_tree_cookie_t wintree; + xcb_query_tree_reply_t *rep; + xcb_window_t *children; +-- +2.1.3 +