From a14b5fea59ba8188ddc5d913a57b73b7ceddbb68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez?= Date: Fri, 11 Jul 2014 14:32:48 +0000 Subject: [PATCH] Needs for uds actor to detect session open/close by user on XRDP --- .../org.python.pydev.PyDevBuilder.launch | 7 ++++ linuxActorXRDP/.project | 22 ++++++++++ linuxActorXRDP/.pydevproject | 8 ++++ linuxActorXRDP/src/Makefile | 13 ++++++ linuxActorXRDP/src/build-stamp | 0 linuxActorXRDP/src/configure-stamp | 0 linuxActorXRDP/src/debian/changelog | 3 ++ linuxActorXRDP/src/debian/compat | 1 + linuxActorXRDP/src/debian/control | 14 +++++++ linuxActorXRDP/src/debian/copyright | 26 ++++++++++++ linuxActorXRDP/src/debian/dirs | 0 linuxActorXRDP/src/debian/docs | 1 + linuxActorXRDP/src/debian/files | 1 + linuxActorXRDP/src/debian/postinst | 39 ++++++++++++++++++ linuxActorXRDP/src/debian/postrm | 28 +++++++++++++ linuxActorXRDP/src/debian/rules | 41 +++++++++++++++++++ linuxActorXRDP/src/pam-sesman-line | 1 + linuxActorXRDP/src/readme.txt | 1 + linuxActorXRDP/src/uds-sesman.sh | 13 ++++++ linuxActorXRDP/src/uds-wait-session.sh | 12 ++++++ 20 files changed, 231 insertions(+) create mode 100644 linuxActorXRDP/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch create mode 100644 linuxActorXRDP/.project create mode 100644 linuxActorXRDP/.pydevproject create mode 100644 linuxActorXRDP/src/Makefile create mode 100644 linuxActorXRDP/src/build-stamp create mode 100644 linuxActorXRDP/src/configure-stamp create mode 100644 linuxActorXRDP/src/debian/changelog create mode 100644 linuxActorXRDP/src/debian/compat create mode 100644 linuxActorXRDP/src/debian/control create mode 100644 linuxActorXRDP/src/debian/copyright create mode 100644 linuxActorXRDP/src/debian/dirs create mode 100644 linuxActorXRDP/src/debian/docs create mode 100644 linuxActorXRDP/src/debian/files create mode 100644 linuxActorXRDP/src/debian/postinst create mode 100644 linuxActorXRDP/src/debian/postrm create mode 100755 linuxActorXRDP/src/debian/rules create mode 100644 linuxActorXRDP/src/pam-sesman-line create mode 100644 linuxActorXRDP/src/readme.txt create mode 100755 linuxActorXRDP/src/uds-sesman.sh create mode 100755 linuxActorXRDP/src/uds-wait-session.sh diff --git a/linuxActorXRDP/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch b/linuxActorXRDP/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch new file mode 100644 index 00000000..92f20514 --- /dev/null +++ b/linuxActorXRDP/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch @@ -0,0 +1,7 @@ + + + + + + + diff --git a/linuxActorXRDP/.project b/linuxActorXRDP/.project new file mode 100644 index 00000000..81e37cfc --- /dev/null +++ b/linuxActorXRDP/.project @@ -0,0 +1,22 @@ + + + linuxActorXRDP + + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/org.python.pydev.PyDevBuilder.launch + + + + + + org.python.pydev.pythonNature + + diff --git a/linuxActorXRDP/.pydevproject b/linuxActorXRDP/.pydevproject new file mode 100644 index 00000000..4a7965b9 --- /dev/null +++ b/linuxActorXRDP/.pydevproject @@ -0,0 +1,8 @@ + + +Default +python 2.7 + +/${PROJECT_DIR_NAME}/src + + diff --git a/linuxActorXRDP/src/Makefile b/linuxActorXRDP/src/Makefile new file mode 100644 index 00000000..321b59b5 --- /dev/null +++ b/linuxActorXRDP/src/Makefile @@ -0,0 +1,13 @@ +BINDIR = $(DESTDIR)/usr/bin + +clean: + echo "Clean" +install: + mkdir -p $(BINDIR) + cp uds-sesman.sh $(BINDIR)/uds-sesman + cp uds-wait-session.sh $(BINDIR)/uds-wait-session + + chmod 0755 $(BINDIR)/uds-sesman + chmod 0755 $(BINDIR)/uds-wait-session +uninstall: + echo "Uninstall" diff --git a/linuxActorXRDP/src/build-stamp b/linuxActorXRDP/src/build-stamp new file mode 100644 index 00000000..e69de29b diff --git a/linuxActorXRDP/src/configure-stamp b/linuxActorXRDP/src/configure-stamp new file mode 100644 index 00000000..e69de29b diff --git a/linuxActorXRDP/src/debian/changelog b/linuxActorXRDP/src/debian/changelog new file mode 100644 index 00000000..6f5bb6ad --- /dev/null +++ b/linuxActorXRDP/src/debian/changelog @@ -0,0 +1,3 @@ +udsactor-xrdp (1.1) stable; urgency=low + * Initial version + -- Adolfo Gómez García Thu, 10 jul 2014 15:31:18 +0100 \ No newline at end of file diff --git a/linuxActorXRDP/src/debian/compat b/linuxActorXRDP/src/debian/compat new file mode 100644 index 00000000..c7930257 --- /dev/null +++ b/linuxActorXRDP/src/debian/compat @@ -0,0 +1 @@ +7 \ No newline at end of file diff --git a/linuxActorXRDP/src/debian/control b/linuxActorXRDP/src/debian/control new file mode 100644 index 00000000..899071a6 --- /dev/null +++ b/linuxActorXRDP/src/debian/control @@ -0,0 +1,14 @@ +Source: udsactor-xrdp +Section: contrib/net +Priority: extra +Maintainer: Adolfo Gómez García +Build-Depends: debhelper (>= 7) +Standards-Version: 3.9.2 +Homepage: http://www.udsenterprise.com + +Package: udsactor-xrdp +Architecture: all +Depends: xrdp (>= 0.6.0), udsactor (>= 1.1), libpam-modules-bin (>=1.0), ${misc:Depends} +Description: UDS Actor component for xrdp + This package provides connection between uds actor and xrdp + diff --git a/linuxActorXRDP/src/debian/copyright b/linuxActorXRDP/src/debian/copyright new file mode 100644 index 00000000..1fb2df20 --- /dev/null +++ b/linuxActorXRDP/src/debian/copyright @@ -0,0 +1,26 @@ +Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135 +Name: udsactor-xrdp +Maintainer: Adolfo Gómez García +Source: http://www.udsenterprise.com/ + +Copyright: 2014 Virtual Cable S.L. +License: BSD-3-clause + +License: GPL-2+ +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. +. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +. +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +. +On Debian systems, the full text of the GNU General Public +License version 2 can be found in the file +`/usr/share/common-licenses/GPL-2'. \ No newline at end of file diff --git a/linuxActorXRDP/src/debian/dirs b/linuxActorXRDP/src/debian/dirs new file mode 100644 index 00000000..e69de29b diff --git a/linuxActorXRDP/src/debian/docs b/linuxActorXRDP/src/debian/docs new file mode 100644 index 00000000..b2b2a781 --- /dev/null +++ b/linuxActorXRDP/src/debian/docs @@ -0,0 +1 @@ +readme.txt diff --git a/linuxActorXRDP/src/debian/files b/linuxActorXRDP/src/debian/files new file mode 100644 index 00000000..4d82f2ae --- /dev/null +++ b/linuxActorXRDP/src/debian/files @@ -0,0 +1 @@ +udsactor-xrdp_1.1_all.deb contrib/net extra diff --git a/linuxActorXRDP/src/debian/postinst b/linuxActorXRDP/src/debian/postinst new file mode 100644 index 00000000..a64df536 --- /dev/null +++ b/linuxActorXRDP/src/debian/postinst @@ -0,0 +1,39 @@ +#!/bin/sh + +SESMANFILE=/etc/pam.d/sesman + +. /usr/share/debconf/confmodule + +set -e + +case "$1" in + configure) + trap "cp $SESMANFILE $SESMANFILE.uds.old" 0 + + TMPFILE=$(mktemp /tmp/sesman.XXXXX) + trap "rm -f $TMPFILE" 0 + grep -v uds $SESMANFILE > $TMPFILE # Removes all UDS lines from sesman if they exists + + echo >> $TMPFILE + echo "# Added by udsactor-xrdp" >> $TMPFILE + echo "session optional pam_exec.so /usr/bin/uds-sesman" >> $TMPFILE + cp $TMPFILE $SESMANFILE + trap "rm -f $TMPFILE" 0 + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +# Don't know why, but descriptors get "weird" when launched daemon, so we tell here to debconf to stop. +# Solved not starting the service right now, defered to next reboot + + +exit 0 \ No newline at end of file diff --git a/linuxActorXRDP/src/debian/postrm b/linuxActorXRDP/src/debian/postrm new file mode 100644 index 00000000..4e390d74 --- /dev/null +++ b/linuxActorXRDP/src/debian/postrm @@ -0,0 +1,28 @@ +#!/bin/sh + +SESMANFILE=/etc/pam.d/sesman + +. /usr/share/debconf/confmodule + +set -e + +case "$1" in + purge) + ;; + remove) + TMPFILE=$(mktemp /tmp/sesman.XXXXX) + trap "rm -f $TMPFILE" 0 + grep -v uds $SESMANFILE > $TMPFILE # Removes all UDS lines from sesman if they exists + cp $TMPFILE $SESMANFILE + trap "rm -f $TMPFILE" 0 + ;; + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# diff --git a/linuxActorXRDP/src/debian/rules b/linuxActorXRDP/src/debian/rules new file mode 100755 index 00000000..a550cfe1 --- /dev/null +++ b/linuxActorXRDP/src/debian/rules @@ -0,0 +1,41 @@ +#!/usr/bin/make -f +# -*- makefile -*- +configure: configure-stamp +configure-stamp: + dh_testdir + touch configure-stamp +build: build-arch build-indep +build-arch: build-stamp +build-indep: build-stamp +build-stamp: configure-stamp + dh_testdir + $(MAKE) + touch $@ +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + dh_clean +install: build + dh_testdir + dh_testroot + dh_prep + dh_installdirs + $(MAKE) DESTDIR=$(CURDIR)/debian/udsactor-xrdp install +binary-arch: build install + # emptyness +binary-indep: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_compress + dh_link + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb +binary: binary-indep +.PHONY: build clean binary-indep binary install configure diff --git a/linuxActorXRDP/src/pam-sesman-line b/linuxActorXRDP/src/pam-sesman-line new file mode 100644 index 00000000..6e7daaf8 --- /dev/null +++ b/linuxActorXRDP/src/pam-sesman-line @@ -0,0 +1 @@ +session optional pam_exec.so /usr/bin/uds-sesman diff --git a/linuxActorXRDP/src/readme.txt b/linuxActorXRDP/src/readme.txt new file mode 100644 index 00000000..b7af2b9e --- /dev/null +++ b/linuxActorXRDP/src/readme.txt @@ -0,0 +1 @@ +This package provides the interaction between xrdp and uds diff --git a/linuxActorXRDP/src/uds-sesman.sh b/linuxActorXRDP/src/uds-sesman.sh new file mode 100755 index 00000000..bb8de2e7 --- /dev/null +++ b/linuxActorXRDP/src/uds-sesman.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +env > /tmp/env.txt + +if [ "$PAM_TYPE" = "open_session" ]; then + nohup /usr/bin/udsactor login $PAM_USER & + # Wait in backgroud to TTY to close (close_session is not being invoked right now) + nohup /usr/bin/uds-wait-session & +elif [ "$PAM_TYPE" = "close_session" ]; then + nohup /usr/bin/udsactor logout $PAM_USER & +fi + +return 0 diff --git a/linuxActorXRDP/src/uds-wait-session.sh b/linuxActorXRDP/src/uds-wait-session.sh new file mode 100755 index 00000000..93839e17 --- /dev/null +++ b/linuxActorXRDP/src/uds-wait-session.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +while : +do + sleep 5 # Wait 5 seconds between checks + found=`ps -f -u$PAM_USER | grep -v grep | grep -v uds-wait-session | grep "$PAM_TTY" | wc -l` + + if [ "$found" = "0" ]; then + /usr/bin/udsactor logout $PAM_USER + exit 0 + fi +done