From 4efe900f2d3ba4a2a3d60d2b68b1a90b739b9c2d Mon Sep 17 00:00:00 2001 From: Bart Warmerdam Date: Sun, 20 Jan 2013 11:45:19 +0100 Subject: [PATCH 01/23] Use correct RGB byte odering for uncompressed bitmaps (ms-rdpbcgr p192), RED=lsB, BLUE=msB --- libxrdp/xrdp_orders.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index bb95aa71..7a17759c 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -1872,9 +1872,9 @@ xrdp_orders_send_raw_bitmap(struct xrdp_orders *self, if (Bpp == 3) { pixel = GETPIXEL32(data, j, i, width); - out_uint8(self->out_s, pixel >> 16); - out_uint8(self->out_s, pixel >> 8); out_uint8(self->out_s, pixel); + out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel >> 16); } else if (Bpp == 2) { @@ -2093,9 +2093,9 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self, if (Bpp == 3) { pixel = GETPIXEL32(data, j, i, width); - out_uint8(self->out_s, pixel >> 16); - out_uint8(self->out_s, pixel >> 8); out_uint8(self->out_s, pixel); + out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel >> 16); } else if (Bpp == 2) { From 69a721f7cbc40960524a4d4ec567a95b02d48b63 Mon Sep 17 00:00:00 2001 From: Bart Warmerdam Date: Sun, 20 Jan 2013 11:50:27 +0100 Subject: [PATCH 02/23] Revert "Use correct RGB byte odering for uncompressed bitmaps (ms-rdpbcgr p192), RED=lsB, BLUE=msB" This reverts commit 4efe900f2d3ba4a2a3d60d2b68b1a90b739b9c2d. --- libxrdp/xrdp_orders.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index 7a17759c..bb95aa71 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -1872,9 +1872,9 @@ xrdp_orders_send_raw_bitmap(struct xrdp_orders *self, if (Bpp == 3) { pixel = GETPIXEL32(data, j, i, width); - out_uint8(self->out_s, pixel); - out_uint8(self->out_s, pixel >> 8); out_uint8(self->out_s, pixel >> 16); + out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel); } else if (Bpp == 2) { @@ -2093,9 +2093,9 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self, if (Bpp == 3) { pixel = GETPIXEL32(data, j, i, width); - out_uint8(self->out_s, pixel); - out_uint8(self->out_s, pixel >> 8); out_uint8(self->out_s, pixel >> 16); + out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel); } else if (Bpp == 2) { From 8fa8d90641d4e94f74da8ca2efccdefb6367b7d8 Mon Sep 17 00:00:00 2001 From: Bart Warmerdam Date: Sun, 20 Jan 2013 11:53:02 +0100 Subject: [PATCH 03/23] Use correct RGB byte odering for uncompressed bitmaps (ms-rdpbcgr p192), RED=lsB, BLUE=msB --- libxrdp/xrdp_orders.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index bb95aa71..7a17759c 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -1872,9 +1872,9 @@ xrdp_orders_send_raw_bitmap(struct xrdp_orders *self, if (Bpp == 3) { pixel = GETPIXEL32(data, j, i, width); - out_uint8(self->out_s, pixel >> 16); - out_uint8(self->out_s, pixel >> 8); out_uint8(self->out_s, pixel); + out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel >> 16); } else if (Bpp == 2) { @@ -2093,9 +2093,9 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self, if (Bpp == 3) { pixel = GETPIXEL32(data, j, i, width); - out_uint8(self->out_s, pixel >> 16); - out_uint8(self->out_s, pixel >> 8); out_uint8(self->out_s, pixel); + out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel >> 16); } else if (Bpp == 2) { From 4c24a5605daa66b1ff265a9848862f4beeb9efc0 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Mon, 18 Mar 2013 22:06:10 +0000 Subject: [PATCH 04/23] Changes related to integration --- configure.ac | 2 + genkeymap/dump-keymaps.sh | 4 + instfiles/Makefile.am | 9 +- instfiles/default/Makefile.am | 3 + instfiles/default/xrdp | 5 + instfiles/init.d/Makefile.am | 4 + instfiles/init.d/xrdp | 160 +++++++++ instfiles/km-0816.ini | 659 ++++++++++++++++++++++++++++++++++ 8 files changed, 843 insertions(+), 3 deletions(-) create mode 100644 instfiles/default/Makefile.am create mode 100644 instfiles/default/xrdp create mode 100644 instfiles/init.d/Makefile.am create mode 100755 instfiles/init.d/xrdp create mode 100644 instfiles/km-0816.ini diff --git a/configure.ac b/configure.ac index d4315133..b8c03445 100644 --- a/configure.ac +++ b/configure.ac @@ -129,6 +129,8 @@ AC_CONFIG_FILES([Makefile docs/man/Makefile instfiles/Makefile instfiles/pam.d/Makefile + instfiles/init.d/Makefile + instfiles/default/Makefile genkeymap/Makefile xrdpapi/Makefile xrdpvr/Makefile diff --git a/genkeymap/dump-keymaps.sh b/genkeymap/dump-keymaps.sh index 7f13b73e..e0f3b3b2 100755 --- a/genkeymap/dump-keymaps.sh +++ b/genkeymap/dump-keymaps.sh @@ -27,5 +27,9 @@ setxkbmap -model pc104 -layout ru setxkbmap -model pc104 -layout se ./xrdp-genkeymap ../instfiles/km-041d.ini +# Portuguese -PT 'pt-pt' 0x0816 +setxkbmap -model pc104 -layout pt +./xrdp-genkeymap ../instfiles/km-0816.ini + # set back to en-us setxkbmap -model pc104 -layout us diff --git a/instfiles/Makefile.am b/instfiles/Makefile.am index 4cabd942..f41bb841 100644 --- a/instfiles/Makefile.am +++ b/instfiles/Makefile.am @@ -1,9 +1,11 @@ -EXTRA_DIST = xrdp.sh km-0407.ini km-0409.ini km-040c.ini km-0410.ini km-0419.ini km-041d.ini \ +EXTRA_DIST = xrdp.sh km-0407.ini km-0409.ini km-040c.ini km-0410.ini km-0419.ini km-041d.ini km-0816.ini \ xrdp-sesman.service \ xrdp.service SUBDIRS = \ - pam.d + pam.d \ + init.d \ + default if HAVE_SYSTEMD systemdsystemunit_DATA = \ @@ -20,7 +22,8 @@ startscript_DATA = \ km-040c.ini \ km-0410.ini \ km-0419.ini \ - km-041d.ini + km-041d.ini \ + km-0816.ini # must be tab below install-data-hook: diff --git a/instfiles/default/Makefile.am b/instfiles/default/Makefile.am new file mode 100644 index 00000000..6a7f4f2b --- /dev/null +++ b/instfiles/default/Makefile.am @@ -0,0 +1,3 @@ +EXTRA_DIST = xrdp +startscriptdir=$(sysconfdir)/default +startscript_DATA = xrdp diff --git a/instfiles/default/xrdp b/instfiles/default/xrdp new file mode 100644 index 00000000..bc51ce82 --- /dev/null +++ b/instfiles/default/xrdp @@ -0,0 +1,5 @@ +# Do we need to start sesman ? +SESMAN_START=yes +# Do we restart xrdp on upgrade ? If not set to no, any xrdp session will +# be shutdown on upgrade. +# RESTART_ON_UPGRADE=no diff --git a/instfiles/init.d/Makefile.am b/instfiles/init.d/Makefile.am new file mode 100644 index 00000000..ae411c20 --- /dev/null +++ b/instfiles/init.d/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST = xrdp +startscriptdir=$(sysconfdir)/init.d +startscript_DATA = xrdp + diff --git a/instfiles/init.d/xrdp b/instfiles/init.d/xrdp new file mode 100755 index 00000000..d51862d8 --- /dev/null +++ b/instfiles/init.d/xrdp @@ -0,0 +1,160 @@ +#!/bin/sh -e +# +# start/stop xrdp and sesman daemons +# +### BEGIN INIT INFO +# Provides: xrdp +# Required-Start: $network $remote_fs +# Required-Stop: $network $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start xrdp and sesman daemons +# Description: XRDP uses the Remote Desktop Protocol to present a +# graphical login to a remote client allowing connection +# to a VNC server or another RDP server. +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/sbin/xrdp +PIDDIR=/var/run/xrdp/ +SESMAN_START=yes +USERID=root +RSAKEYS=/etc/xrdp/rsakeys.ini +NAME=xrdp +DESC="Remote Desktop Protocol server" + +test -x $DAEMON || exit 0 + +. /lib/lsb/init-functions + +check_root() { + if [ "$(id -u)" != "0" ]; then + log_failure_msg "You must be root to start, stop or restart $NAME." + exit 4 + fi +} + +if [ -r /etc/default/$NAME ]; then + . /etc/default/$NAME +fi + +# Tasks that can only be run as root +if [ "$(id -u)" = "0" ]; then + # Check for pid dir + if [ ! -d $PIDDIR ] ; then + mkdir $PIDDIR + fi + chown $USERID:$USERID $PIDDIR + + # Check for rsa key + if [ ! -f $RSAKEYS ] || cmp $RSAKEYS /usr/share/doc/xrdp/rsakeys.ini > /dev/null; then + log_action_begin_msg "Generating xrdp RSA keys..." + (umask 077 ; xrdp-keygen xrdp $RSAKEYS) + chown $USERID:$USERID $RSAKEYS + if [ ! -f $RSAKEYS ] ; then + log_action_end_msg 1 "could not create $RSAKEYS" + exit 1 + fi + log_action_end_msg 0 "done" + fi +fi + + +case "$1" in + start) + check_root + exitval=0 + log_daemon_msg "Starting $DESC " + if pidofproc -p $PIDDIR/$NAME.pid $DAEMON > /dev/null; then + log_progress_msg "$NAME apparently already running" + log_end_msg 0 + exit 0 + fi + log_progress_msg $NAME + start-stop-daemon --start --quiet --oknodo --pidfile $PIDDIR/$NAME.pid \ + --chuid $USERID:$USERID --exec $DAEMON + exitval=$? + if [ "$SESMAN_START" = "yes" ] ; then + log_progress_msg "sesman" + start-stop-daemon --start --quiet --oknodo --pidfile $PIDDIR/xrdp-sesman.pid \ + --exec /usr/sbin/xrdp-sesman + value=$? + [ $value -gt 0 ] && exitval=$value + fi + # Make pidfile readables for all users (for status to work) + [ -e $PIDDIR/xrdp-sesman.pid ] && chmod 0644 $PIDDIR/xrdp-sesman.pid + [ -e $PIDDIR/$NAME.pid ] && chmod 0644 $PIDDIR/$NAME.pid + # Note: Unfortunately, xrdp currently takes too long to create + # the pidffile unless properly patched + log_end_msg $exitval + ;; + stop) + check_root + [ -n "$XRDP_UPGRADE" -a "$RESTART_ON_UPGRADE" = "no" ] && { + echo "Upgrade in progress, no restart of xrdp." + exit 0 + } + exitval=0 + log_daemon_msg "Stopping RDP Session manager " + log_progress_msg "sesman" + if pidofproc -p $PIDDIR/xrdp-sesman.pid /usr/sbin/xrdp-sesman > /dev/null; then + start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/xrdp-sesman.pid \ + --chuid $USERID:$USERID --exec /usr/sbin/xrdp-sesman + exitval=$? + else + log_progress_msg "apparently not running" + fi + log_progress_msg $NAME + if pidofproc -p $PIDDIR/$NAME.pid $DAEMON > /dev/null; then + start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/$NAME.pid \ + --exec $DAEMON + value=$? + [ $value -gt 0 ] && exitval=$value + else + log_progress_msg "apparently not running" + fi + log_end_msg $exitval + ;; + restart|force-reload) + check_root + $0 stop + # Wait for things to settle down + sleep 1 + $0 start + ;; + reload) + log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon" + log_warning_msg "cannot re-read the config file (use restart)." + ;; + status) + exitval=0 + log_daemon_msg "Checking status of $DESC" "$NAME" + if pidofproc -p $PIDDIR/$NAME.pid $DAEMON > /dev/null; then + log_progress_msg "running" + log_end_msg 0 + else + log_progress_msg "apparently not running" + log_end_msg 1 || true + exitval=1 + fi + if [ "$SESMAN_START" = "yes" ] ; then + log_daemon_msg "Checking status of RDP Session Manager" "sesman" + if pidofproc -p $PIDDIR/xrdp-sesman.pid /usr/sbin/xrdp-sesman > /dev/null; then + log_progress_msg "running" + log_end_msg 0 + else + log_progress_msg "apparently not running" + log_end_msg 1 || true + exitval=1 + fi + fi + exit $exitval + ;; + *) + N=/etc/init.d/$NAME + echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/instfiles/km-0816.ini b/instfiles/km-0816.ini new file mode 100644 index 00000000..bf3def89 --- /dev/null +++ b/instfiles/km-0816.ini @@ -0,0 +1,659 @@ +[noshift] +Key8=0:0 +Key9=65307:27 +Key10=49:49 +Key11=50:50 +Key12=51:51 +Key13=52:52 +Key14=53:53 +Key15=54:54 +Key16=55:55 +Key17=56:56 +Key18=57:57 +Key19=48:48 +Key20=39:39 +Key21=171:171 +Key22=65288:8 +Key23=65289:9 +Key24=113:113 +Key25=119:119 +Key26=101:101 +Key27=114:114 +Key28=116:116 +Key29=121:121 +Key30=117:117 +Key31=105:105 +Key32=111:111 +Key33=112:112 +Key34=43:43 +Key35=65105:180 +Key36=65293:13 +Key37=65507:0 +Key38=97:97 +Key39=115:115 +Key40=100:100 +Key41=102:102 +Key42=103:103 +Key43=104:104 +Key44=106:106 +Key45=107:107 +Key46=108:108 +Key47=231:231 +Key48=186:186 +Key49=92:92 +Key50=65505:0 +Key51=65107:126 +Key52=122:122 +Key53=120:120 +Key54=99:99 +Key55=118:118 +Key56=98:98 +Key57=110:110 +Key58=109:109 +Key59=44:44 +Key60=46:46 +Key61=45:45 +Key62=65506:0 +Key63=65450:42 +Key64=65513:0 +Key65=32:32 +Key66=65509:0 +Key67=65470:0 +Key68=65471:0 +Key69=65472:0 +Key70=65473:0 +Key71=65474:0 +Key72=65475:0 +Key73=65476:0 +Key74=65477:0 +Key75=65478:0 +Key76=65479:0 +Key77=65407:0 +Key78=65300:0 +Key79=65429:0 +Key80=65431:0 +Key81=65434:0 +Key82=65453:45 +Key83=65430:0 +Key84=65437:0 +Key85=65432:0 +Key86=65451:43 +Key87=65436:0 +Key88=65433:0 +Key89=65435:0 +Key90=65438:0 +Key91=65439:0 +Key92=0:0 +Key93=65406:0 +Key94=60:60 +Key95=65480:0 +Key96=65481:0 +Key97=65360:0 +Key98=65362:0 +Key99=65365:0 +Key100=65361:0 +Key101=0:0 +Key102=65363:0 +Key103=65367:0 +Key104=65364:0 +Key105=65366:0 +Key106=65379:0 +Key107=65535:127 +Key108=65421:13 +Key109=65508:0 +Key110=65299:0 +Key111=65377:0 +Key112=65455:47 +Key113=65027:0 +Key114=0:0 +Key115=65515:0 +Key116=65312:0 +Key117=65383:0 +Key118=0:0 +Key119=0:0 +Key120=0:0 +Key121=0:0 +Key122=0:0 +Key123=0:0 +Key124=65027:0 +Key125=0:0 +Key126=65469:61 +Key127=0:0 +Key128=0:0 +Key129=269025170:0 +Key130=0:0 +Key131=0:0 +Key132=0:0 +Key133=269025166:0 +Key134=0:0 +Key135=65382:0 +Key136=65381:0 +Key137=0:0 + +[shift] +Key8=0:0 +Key9=65307:27 +Key10=33:33 +Key11=34:34 +Key12=35:35 +Key13=36:36 +Key14=37:37 +Key15=38:38 +Key16=47:47 +Key17=40:40 +Key18=41:41 +Key19=61:61 +Key20=63:63 +Key21=187:187 +Key22=65288:8 +Key23=65056:0 +Key24=81:81 +Key25=87:87 +Key26=69:69 +Key27=82:82 +Key28=84:84 +Key29=89:89 +Key30=85:85 +Key31=73:73 +Key32=79:79 +Key33=80:80 +Key34=42:42 +Key35=65104:96 +Key36=65293:13 +Key37=65507:0 +Key38=65:65 +Key39=83:83 +Key40=68:68 +Key41=70:70 +Key42=71:71 +Key43=72:72 +Key44=74:74 +Key45=75:75 +Key46=76:76 +Key47=199:199 +Key48=170:170 +Key49=124:124 +Key50=65505:0 +Key51=65106:94 +Key52=90:90 +Key53=88:88 +Key54=67:67 +Key55=86:86 +Key56=66:66 +Key57=78:78 +Key58=77:77 +Key59=59:59 +Key60=58:58 +Key61=95:95 +Key62=65506:0 +Key63=65450:42 +Key64=65511:0 +Key65=32:32 +Key66=65509:0 +Key67=65470:0 +Key68=65471:0 +Key69=65472:0 +Key70=65473:0 +Key71=65474:0 +Key72=65475:0 +Key73=65476:0 +Key74=65477:0 +Key75=65478:0 +Key76=65479:0 +Key77=65273:0 +Key78=65300:0 +Key79=65463:55 +Key80=65464:56 +Key81=65465:57 +Key82=65453:45 +Key83=65460:52 +Key84=65461:53 +Key85=65462:54 +Key86=65451:43 +Key87=65457:49 +Key88=65458:50 +Key89=65459:51 +Key90=65456:48 +Key91=65454:46 +Key92=0:0 +Key93=65406:0 +Key94=62:62 +Key95=65480:0 +Key96=65481:0 +Key97=65360:0 +Key98=65362:0 +Key99=65365:0 +Key100=65361:0 +Key101=0:0 +Key102=65363:0 +Key103=65367:0 +Key104=65364:0 +Key105=65366:0 +Key106=65379:0 +Key107=65535:127 +Key108=65421:13 +Key109=65508:0 +Key110=65299:0 +Key111=65377:0 +Key112=65455:47 +Key113=65027:0 +Key114=0:0 +Key115=65515:0 +Key116=65312:0 +Key117=65383:0 +Key118=0:0 +Key119=0:0 +Key120=0:0 +Key121=0:0 +Key122=0:0 +Key123=0:0 +Key124=65027:0 +Key125=65513:0 +Key126=65469:61 +Key127=65515:0 +Key128=65517:0 +Key129=269025170:0 +Key130=0:0 +Key131=0:0 +Key132=0:0 +Key133=269025166:0 +Key134=0:0 +Key135=65382:0 +Key136=65381:0 +Key137=0:0 + +[altgr] +Key8=0:0 +Key9=65307:27 +Key10=185:185 +Key11=64:64 +Key12=163:163 +Key13=167:167 +Key14=189:189 +Key15=172:172 +Key16=123:123 +Key17=91:91 +Key18=93:93 +Key19=125:125 +Key20=92:92 +Key21=65115:184 +Key22=65288:8 +Key23=65289:9 +Key24=64:64 +Key25=435:322 +Key26=8364:8364 +Key27=182:182 +Key28=956:359 +Key29=2299:8592 +Key30=2302:8595 +Key31=2301:8594 +Key32=248:248 +Key33=254:254 +Key34=65111:168 +Key35=65107:126 +Key36=65293:13 +Key37=65507:0 +Key38=230:230 +Key39=223:223 +Key40=240:240 +Key41=496:273 +Key42=959:331 +Key43=689:295 +Key44=106:106 +Key45=930:312 +Key46=435:322 +Key47=65105:180 +Key48=65106:94 +Key49=172:172 +Key50=65505:0 +Key51=65104:96 +Key52=171:171 +Key53=187:187 +Key54=162:162 +Key55=2770:8220 +Key56=2771:8221 +Key57=110:110 +Key58=181:181 +Key59=2211:0 +Key60=183:183 +Key61=65120:0 +Key62=65506:0 +Key63=65450:42 +Key64=65513:0 +Key65=32:32 +Key66=65509:0 +Key67=65470:0 +Key68=65471:0 +Key69=65472:0 +Key70=65473:0 +Key71=65474:0 +Key72=65475:0 +Key73=65476:0 +Key74=65477:0 +Key75=65478:0 +Key76=65479:0 +Key77=65407:0 +Key78=65300:0 +Key79=65429:0 +Key80=65431:0 +Key81=65434:0 +Key82=65453:45 +Key83=65430:0 +Key84=65437:0 +Key85=65432:0 +Key86=65451:43 +Key87=65436:0 +Key88=65433:0 +Key89=65435:0 +Key90=65438:0 +Key91=65439:0 +Key92=0:0 +Key93=65406:0 +Key94=124:124 +Key95=65480:0 +Key96=65481:0 +Key97=65360:0 +Key98=65362:0 +Key99=65365:0 +Key100=65361:0 +Key101=0:0 +Key102=65363:0 +Key103=65367:0 +Key104=65364:0 +Key105=65366:0 +Key106=65379:0 +Key107=65535:127 +Key108=65421:13 +Key109=65508:0 +Key110=65299:0 +Key111=65377:0 +Key112=65455:47 +Key113=65027:0 +Key114=0:0 +Key115=65515:0 +Key116=65312:0 +Key117=65383:0 +Key118=0:0 +Key119=0:0 +Key120=0:0 +Key121=0:0 +Key122=0:0 +Key123=0:0 +Key124=65027:0 +Key125=0:0 +Key126=65469:61 +Key127=0:0 +Key128=0:0 +Key129=269025170:0 +Key130=0:0 +Key131=0:0 +Key132=0:0 +Key133=269025166:0 +Key134=0:0 +Key135=65382:0 +Key136=65381:0 +Key137=0:0 + +[capslock] +Key8=0:0 +Key9=65307:27 +Key10=49:49 +Key11=50:50 +Key12=51:51 +Key13=52:52 +Key14=53:53 +Key15=54:54 +Key16=55:55 +Key17=56:56 +Key18=57:57 +Key19=48:48 +Key20=39:39 +Key21=171:171 +Key22=65288:8 +Key23=65289:9 +Key24=81:81 +Key25=87:87 +Key26=69:69 +Key27=82:82 +Key28=84:84 +Key29=89:89 +Key30=85:85 +Key31=73:73 +Key32=79:79 +Key33=80:80 +Key34=43:43 +Key35=65105:180 +Key36=65293:13 +Key37=65507:0 +Key38=65:65 +Key39=83:83 +Key40=68:68 +Key41=70:70 +Key42=71:71 +Key43=72:72 +Key44=74:74 +Key45=75:75 +Key46=76:76 +Key47=199:199 +Key48=186:186 +Key49=92:92 +Key50=65505:0 +Key51=65107:126 +Key52=90:90 +Key53=88:88 +Key54=67:67 +Key55=86:86 +Key56=66:66 +Key57=78:78 +Key58=77:77 +Key59=44:44 +Key60=46:46 +Key61=45:45 +Key62=65506:0 +Key63=65450:42 +Key64=65513:0 +Key65=32:32 +Key66=65509:0 +Key67=65470:0 +Key68=65471:0 +Key69=65472:0 +Key70=65473:0 +Key71=65474:0 +Key72=65475:0 +Key73=65476:0 +Key74=65477:0 +Key75=65478:0 +Key76=65479:0 +Key77=65407:0 +Key78=65300:0 +Key79=65429:0 +Key80=65431:0 +Key81=65434:0 +Key82=65453:45 +Key83=65430:0 +Key84=65437:0 +Key85=65432:0 +Key86=65451:43 +Key87=65436:0 +Key88=65433:0 +Key89=65435:0 +Key90=65438:0 +Key91=65439:0 +Key92=0:0 +Key93=65406:0 +Key94=60:60 +Key95=65480:0 +Key96=65481:0 +Key97=65360:0 +Key98=65362:0 +Key99=65365:0 +Key100=65361:0 +Key101=0:0 +Key102=65363:0 +Key103=65367:0 +Key104=65364:0 +Key105=65366:0 +Key106=65379:0 +Key107=65535:127 +Key108=65421:13 +Key109=65508:0 +Key110=65299:0 +Key111=65377:0 +Key112=65455:47 +Key113=65027:0 +Key114=0:0 +Key115=65515:0 +Key116=65312:0 +Key117=65383:0 +Key118=0:0 +Key119=0:0 +Key120=0:0 +Key121=0:0 +Key122=0:0 +Key123=0:0 +Key124=65027:0 +Key125=0:0 +Key126=65469:61 +Key127=0:0 +Key128=0:0 +Key129=269025170:0 +Key130=0:0 +Key131=0:0 +Key132=0:0 +Key133=269025166:0 +Key134=0:0 +Key135=65382:0 +Key136=65381:0 +Key137=0:0 + +[shiftcapslock] +Key8=0:0 +Key9=65307:27 +Key10=33:33 +Key11=34:34 +Key12=35:35 +Key13=36:36 +Key14=37:37 +Key15=38:38 +Key16=47:47 +Key17=40:40 +Key18=41:41 +Key19=61:61 +Key20=63:63 +Key21=187:187 +Key22=65288:8 +Key23=65056:0 +Key24=113:113 +Key25=119:119 +Key26=101:101 +Key27=114:114 +Key28=116:116 +Key29=121:121 +Key30=117:117 +Key31=105:105 +Key32=111:111 +Key33=112:112 +Key34=42:42 +Key35=65104:96 +Key36=65293:13 +Key37=65507:0 +Key38=97:97 +Key39=115:115 +Key40=100:100 +Key41=102:102 +Key42=103:103 +Key43=104:104 +Key44=106:106 +Key45=107:107 +Key46=108:108 +Key47=231:231 +Key48=170:170 +Key49=124:124 +Key50=65505:0 +Key51=65106:94 +Key52=122:122 +Key53=120:120 +Key54=99:99 +Key55=118:118 +Key56=98:98 +Key57=110:110 +Key58=109:109 +Key59=59:59 +Key60=58:58 +Key61=95:95 +Key62=65506:0 +Key63=65450:42 +Key64=65511:0 +Key65=32:32 +Key66=65509:0 +Key67=65470:0 +Key68=65471:0 +Key69=65472:0 +Key70=65473:0 +Key71=65474:0 +Key72=65475:0 +Key73=65476:0 +Key74=65477:0 +Key75=65478:0 +Key76=65479:0 +Key77=65273:0 +Key78=65300:0 +Key79=65463:55 +Key80=65464:56 +Key81=65465:57 +Key82=65453:45 +Key83=65460:52 +Key84=65461:53 +Key85=65462:54 +Key86=65451:43 +Key87=65457:49 +Key88=65458:50 +Key89=65459:51 +Key90=65456:48 +Key91=65454:46 +Key92=0:0 +Key93=65406:0 +Key94=62:62 +Key95=65480:0 +Key96=65481:0 +Key97=65360:0 +Key98=65362:0 +Key99=65365:0 +Key100=65361:0 +Key101=0:0 +Key102=65363:0 +Key103=65367:0 +Key104=65364:0 +Key105=65366:0 +Key106=65379:0 +Key107=65535:127 +Key108=65421:13 +Key109=65508:0 +Key110=65299:0 +Key111=65377:0 +Key112=65455:47 +Key113=65027:0 +Key114=0:0 +Key115=65515:0 +Key116=65312:0 +Key117=65383:0 +Key118=0:0 +Key119=0:0 +Key120=0:0 +Key121=0:0 +Key122=0:0 +Key123=0:0 +Key124=65027:0 +Key125=65513:0 +Key126=65469:61 +Key127=65515:0 +Key128=65517:0 +Key129=269025170:0 +Key130=0:0 +Key131=0:0 +Key132=0:0 +Key133=269025166:0 +Key134=0:0 +Key135=65382:0 +Key136=65381:0 +Key137=0:0 From ec0f41df3c0210894270a311aee9bdb51ca5a25b Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 11:57:16 +0000 Subject: [PATCH 05/23] fix xrdp init script permissions --- instfiles/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/instfiles/Makefile.am b/instfiles/Makefile.am index f41bb841..7ba86d3d 100644 --- a/instfiles/Makefile.am +++ b/instfiles/Makefile.am @@ -28,3 +28,4 @@ startscript_DATA = \ # must be tab below install-data-hook: chmod 755 $(DESTDIR)$(sysconfdir)/xrdp/xrdp.sh + chmod 755 $(DESTDIR)$(sysconfdir)/init.d/xrdp From 18fd0537f5d9816ce16546c3a7ab6f912700b108 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 15:57:21 +0000 Subject: [PATCH 06/23] use a simple default for startwm.sh --- sesman/startwm.sh | 96 +++-------------------------------------------- 1 file changed, 5 insertions(+), 91 deletions(-) diff --git a/sesman/startwm.sh b/sesman/startwm.sh index 02fc7956..2b19ba45 100755 --- a/sesman/startwm.sh +++ b/sesman/startwm.sh @@ -1,93 +1,7 @@ #!/bin/sh +if [ -r /etc/default/locale ]; then + . /etc/default/locale + export LANG LANGUAGE +fi +. /etc/X11/Xsession -# change the order in line below to run to run whatever window manager you -# want, default to kde - -SESSIONS="gnome-session blackbox fluxbox startxfce4 startkde xterm" - -#start the window manager -wm_start() -{ - for WindowManager in $SESSIONS - do - which $WindowManager - if test $? -eq 0 - then - echo "Starting $WindowManager" - $WindowManager - return 0 - fi - done - return 0 -} - -#Execution sequence for interactive login shell -#Following pseudo code explains the sequence of execution of these files. -#execute /etc/profile -#IF ~/.bash_profile exists THEN -# execute ~/.bash_profile -#ELSE -# IF ~/.bash_login exist THEN -# execute ~/.bash_login -# ELSE -# IF ~/.profile exist THEN -# execute ~/.profile -# END IF -# END IF -#END IF -pre_start() -{ - if [ -f /etc/profile ] - then - . /etc/profile - fi - if [ -f ~/.bash_profile ] - then - . ~/.bash_profile - else - if [ -f ~/.bash_login ] - then - . ~/.bash_login - else - if [ -f ~/.profile ] - then - . ~/.profile - fi - fi - fi - return 0 -} - -#When you logout of the interactive shell, following is the -#sequence of execution: -#IF ~/.bash_logout exists THEN -# execute ~/.bash_logout -#END IF -post_start() -{ - if [ -f ~/.bash_logout ] - then - . ~/.bash_logout - fi - return 0 -} - -#. /etc/environment -#export PATH=$PATH -#export LANG=$LANG - -# change PATH to be what your environment needs usually what is in -# /etc/environment -#PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" -#export PATH=$PATH - -# for PATH and LANG from /etc/environment -# pam will auto process the environment file if /etc/pam.d/xrdp-sesman -# includes -# auth required pam_env.so readenv=1 - -pre_start -wm_start -post_start - -exit 1 From 276675a23562a4c527c0ff5764748e587a6218ba Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 16:29:58 +0000 Subject: [PATCH 07/23] add FORCE flag to ensure the service really stops (overridable by system administraor) --- instfiles/init.d/xrdp | 139 ++++++++++-------------------------------- 1 file changed, 31 insertions(+), 108 deletions(-) diff --git a/instfiles/init.d/xrdp b/instfiles/init.d/xrdp index d51862d8..33eeb861 100755 --- a/instfiles/init.d/xrdp +++ b/instfiles/init.d/xrdp @@ -1,158 +1,81 @@ -#!/bin/sh -e +#! /bin/sh # # start/stop xrdp and sesman daemons -# + ### BEGIN INIT INFO # Provides: xrdp # Required-Start: $network $remote_fs # Required-Stop: $network $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: Start xrdp and sesman daemons -# Description: XRDP uses the Remote Desktop Protocol to present a -# graphical login to a remote client allowing connection -# to a VNC server or another RDP server. +# Short-Description: start xrdp daemon ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/xrdp -PIDDIR=/var/run/xrdp/ -SESMAN_START=yes -USERID=root +PIDDIR=/var/run/xrdp +USERID=xrdp RSAKEYS=/etc/xrdp/rsakeys.ini NAME=xrdp -DESC="Remote Desktop Protocol server" +DESC=xrdp test -x $DAEMON || exit 0 -. /lib/lsb/init-functions - -check_root() { - if [ "$(id -u)" != "0" ]; then - log_failure_msg "You must be root to start, stop or restart $NAME." - exit 4 - fi -} - if [ -r /etc/default/$NAME ]; then . /etc/default/$NAME fi -# Tasks that can only be run as root -if [ "$(id -u)" = "0" ]; then - # Check for pid dir - if [ ! -d $PIDDIR ] ; then +# Check for pid dir +if [ ! -d $PIDDIR ] ; then mkdir $PIDDIR - fi - chown $USERID:$USERID $PIDDIR +fi +chown $USERID:$USERID $PIDDIR - # Check for rsa key - if [ ! -f $RSAKEYS ] || cmp $RSAKEYS /usr/share/doc/xrdp/rsakeys.ini > /dev/null; then - log_action_begin_msg "Generating xrdp RSA keys..." +# Check for rsa key +if [ ! -f $RSAKEYS ] || cmp $RSAKEYS /usr/share/doc/xrdp/rsakeys.ini > /dev/null; then + echo "Generating xrdp RSA keys..." (umask 077 ; xrdp-keygen xrdp $RSAKEYS) chown $USERID:$USERID $RSAKEYS - if [ ! -f $RSAKEYS ] ; then - log_action_end_msg 1 "could not create $RSAKEYS" - exit 1 - fi - log_action_end_msg 0 "done" - fi fi +set -e + case "$1" in start) - check_root - exitval=0 - log_daemon_msg "Starting $DESC " - if pidofproc -p $PIDDIR/$NAME.pid $DAEMON > /dev/null; then - log_progress_msg "$NAME apparently already running" - log_end_msg 0 - exit 0 - fi - log_progress_msg $NAME + echo -n "Starting $DESC: " start-stop-daemon --start --quiet --oknodo --pidfile $PIDDIR/$NAME.pid \ --chuid $USERID:$USERID --exec $DAEMON - exitval=$? - if [ "$SESMAN_START" = "yes" ] ; then - log_progress_msg "sesman" + echo -n "$NAME" + [ "$SESMAN_START" = "yes" ] && { \ start-stop-daemon --start --quiet --oknodo --pidfile $PIDDIR/xrdp-sesman.pid \ --exec /usr/sbin/xrdp-sesman - value=$? - [ $value -gt 0 ] && exitval=$value - fi - # Make pidfile readables for all users (for status to work) - [ -e $PIDDIR/xrdp-sesman.pid ] && chmod 0644 $PIDDIR/xrdp-sesman.pid - [ -e $PIDDIR/$NAME.pid ] && chmod 0644 $PIDDIR/$NAME.pid - # Note: Unfortunately, xrdp currently takes too long to create - # the pidffile unless properly patched - log_end_msg $exitval + echo -n " sesman" + } + echo "." ;; stop) - check_root [ -n "$XRDP_UPGRADE" -a "$RESTART_ON_UPGRADE" = "no" ] && { echo "Upgrade in progress, no restart of xrdp." exit 0 } - exitval=0 - log_daemon_msg "Stopping RDP Session manager " - log_progress_msg "sesman" - if pidofproc -p $PIDDIR/xrdp-sesman.pid /usr/sbin/xrdp-sesman > /dev/null; then - start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/xrdp-sesman.pid \ - --chuid $USERID:$USERID --exec /usr/sbin/xrdp-sesman - exitval=$? - else - log_progress_msg "apparently not running" - fi - log_progress_msg $NAME - if pidofproc -p $PIDDIR/$NAME.pid $DAEMON > /dev/null; then - start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/$NAME.pid \ + echo -n "Stopping $DESC: " + start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/xrdp-sesman.pid \ + --chuid $USERID:$USERID --exec /usr/sbin/xrdp-sesman + echo -n "sesman " + start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/$NAME.pid \ --exec $DAEMON - value=$? - [ $value -gt 0 ] && exitval=$value - else - log_progress_msg "apparently not running" - fi - log_end_msg $exitval + sleep 1 + echo "$NAME." ;; - restart|force-reload) - check_root + restart) $0 stop - # Wait for things to settle down - sleep 1 $0 start ;; - reload) - log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon" - log_warning_msg "cannot re-read the config file (use restart)." - ;; - status) - exitval=0 - log_daemon_msg "Checking status of $DESC" "$NAME" - if pidofproc -p $PIDDIR/$NAME.pid $DAEMON > /dev/null; then - log_progress_msg "running" - log_end_msg 0 - else - log_progress_msg "apparently not running" - log_end_msg 1 || true - exitval=1 - fi - if [ "$SESMAN_START" = "yes" ] ; then - log_daemon_msg "Checking status of RDP Session Manager" "sesman" - if pidofproc -p $PIDDIR/xrdp-sesman.pid /usr/sbin/xrdp-sesman > /dev/null; then - log_progress_msg "running" - log_end_msg 0 - else - log_progress_msg "apparently not running" - log_end_msg 1 || true - exitval=1 - fi - fi - exit $exitval - ;; *) N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 + # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac From a05987334ac96efb19a0e807358e8839b09d7438 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 16:39:22 +0000 Subject: [PATCH 08/23] debian packaging related files (initial commit) --- debian/changelog | 11 +++++++++++ debian/copyright | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ debian/postinst | 21 ++++++++++++++++++++ debian/rules | 18 +++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/copyright create mode 100644 debian/postinst create mode 100644 debian/rules diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..ccfdc5e5 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,11 @@ +xrdp (0.7.0-1) unstable; urgency=low + + * Initial release + + -- Angulo Solido Wed, 20 Mar 2013 19:46:06 +0100 + +xrdp (0.6.0-1) unstable; urgency=low + + * Initial release (Closes: #nnnn) + + -- Angulo Solido Mon, 22 Aug 2011 19:46:06 +0100 diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..723d3452 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,50 @@ +This work was packaged for Debian by: + + Angulo Solido on Mon, 22 Aug 2011 19:46:06 +0100 + +It was downloaded from: + + + +Upstream Author(s): + + + + +Copyright: + + + + +License: + + 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 3 of the License, or + (at your option) any later version. + + This package 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, see . + +On Debian systems, the complete text of the GNU General +Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'. + +The Debian packaging is: + + Copyright (C) 2011 Angulo Solido + +# Please chose a license for your packaging work. If the program you package +# uses a mainstream license, using the same license is the safest choice. +# Please avoid to pick license terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. +# If you just want it to be GPL version 3, leave the following line in. + +and is licensed under the GPL version 3, see above. + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 00000000..c27cd65e --- /dev/null +++ b/debian/postinst @@ -0,0 +1,21 @@ +#!/bin/sh -e + +if ! ([ "$1" = "configure" ] || [ "$1" = "reconfigure" ]); then + exit 0 +fi + + +XRDP="xrdp" +CHOWN="/bin/chown" +ADDUSER="/usr/sbin/adduser" + +[ -d /var/run/xrdp ] || mkdir -p /var/run/xrdp +$ADDUSER --system --disabled-password --disabled-login --home /var/run/xrdp \ + --no-create-home --quiet --group $XRDP + +$CHOWN -R $XRDP:$XRDP /etc/xrdp +touch /var/log/sesman.log +$CHOWN -R $XRDP:$XRDP /var/log/sesman.log + + +#DEBHELPER# diff --git a/debian/rules b/debian/rules new file mode 100644 index 00000000..2c29bebf --- /dev/null +++ b/debian/rules @@ -0,0 +1,18 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +%: + dh $@ + +LDFLAGS = -lpthread + +override_dh_auto_configure: + ./bootstrap + ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var + find -name Makefile | while read i; do sed -e 's#\(XRDP_PID_PATH.*/run\)#\1/xrdp#g' -i "$$i"; done + + +override_dh_installdeb: + # Move rsakeys to documentation + mv debian/xrdp/etc/xrdp/rsakeys.ini debian/xrdp/usr/share/doc/xrdp + dh_installdeb -a From 4d9cd08cfc764655ded8b79c4edd760fd5add6c1 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 16:49:12 +0000 Subject: [PATCH 09/23] fine tune postinstall --- debian/postinst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/postinst b/debian/postinst index c27cd65e..37e4931d 100644 --- a/debian/postinst +++ b/debian/postinst @@ -8,14 +8,14 @@ fi XRDP="xrdp" CHOWN="/bin/chown" ADDUSER="/usr/sbin/adduser" +SESMANLOG="/var/log/xrdp-sesman.log" [ -d /var/run/xrdp ] || mkdir -p /var/run/xrdp $ADDUSER --system --disabled-password --disabled-login --home /var/run/xrdp \ --no-create-home --quiet --group $XRDP -$CHOWN -R $XRDP:$XRDP /etc/xrdp -touch /var/log/sesman.log -$CHOWN -R $XRDP:$XRDP /var/log/sesman.log +touch $SESMANLOG +$CHOWN $XRDP:$XRDP $SESMANLOG #DEBHELPER# From 49301fac005acab080ccc2d5d884d1d5f87b3c94 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 17:19:40 +0000 Subject: [PATCH 10/23] further integration fixes --- debian/postinst | 11 +++++++---- instfiles/init.d/xrdp | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/debian/postinst b/debian/postinst index 37e4931d..de913aed 100644 --- a/debian/postinst +++ b/debian/postinst @@ -6,16 +6,19 @@ fi XRDP="xrdp" -CHOWN="/bin/chown" ADDUSER="/usr/sbin/adduser" +XRDPLOG="/var/log/xrdp-sesman.log" SESMANLOG="/var/log/xrdp-sesman.log" +RSAKEYS="/etc/xrdp/rsakeys.ini" [ -d /var/run/xrdp ] || mkdir -p /var/run/xrdp $ADDUSER --system --disabled-password --disabled-login --home /var/run/xrdp \ --no-create-home --quiet --group $XRDP -touch $SESMANLOG -$CHOWN $XRDP:$XRDP $SESMANLOG - +touch $SESMANLOG $XRDPLOG +chown $XRDP:$XRDP $SESMANLOG +chown $XRDP:$XRDP $XRDPLOG +chgrp $XRDP $RSAKEYS +chmod g+r $RSAKEYS #DEBHELPER# diff --git a/instfiles/init.d/xrdp b/instfiles/init.d/xrdp index 33eeb861..0c71f35f 100755 --- a/instfiles/init.d/xrdp +++ b/instfiles/init.d/xrdp @@ -14,7 +14,9 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/xrdp PIDDIR=/var/run/xrdp -USERID=xrdp +#USERID=xrdp +# for now X11rdp sessions require root - should be fixed in the future +USERID=root RSAKEYS=/etc/xrdp/rsakeys.ini NAME=xrdp DESC=xrdp From 68f38adaa383ad6bdde104e7355251238fef2781 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 18:22:53 +0000 Subject: [PATCH 11/23] more robust version, including force-stop option --- instfiles/init.d/xrdp | 166 +++++++++++++++++++++++++++++++++--------- 1 file changed, 133 insertions(+), 33 deletions(-) mode change 100755 => 100644 instfiles/init.d/xrdp diff --git a/instfiles/init.d/xrdp b/instfiles/init.d/xrdp old mode 100755 new mode 100644 index 0c71f35f..8ed8cc23 --- a/instfiles/init.d/xrdp +++ b/instfiles/init.d/xrdp @@ -1,83 +1,183 @@ -#! /bin/sh +#!/bin/sh -e # # start/stop xrdp and sesman daemons - +# ### BEGIN INIT INFO # Provides: xrdp # Required-Start: $network $remote_fs # Required-Stop: $network $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: start xrdp daemon +# Short-Description: Start xrdp and sesman daemons +# Description: XRDP uses the Remote Desktop Protocol to present a +# graphical login to a remote client allowing connection +# to a VNC server or another RDP server. ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/xrdp -PIDDIR=/var/run/xrdp +PIDDIR=/var/run/xrdp/ +SESMAN_START=yes #USERID=xrdp -# for now X11rdp sessions require root - should be fixed in the future +# the X11rdp backend only works as root at the moment - GH 20/03/2013 USERID=root RSAKEYS=/etc/xrdp/rsakeys.ini NAME=xrdp -DESC=xrdp +DESC="Remote Desktop Protocol server" test -x $DAEMON || exit 0 +. /lib/lsb/init-functions + +check_root() { + if [ "$(id -u)" != "0" ]; then + log_failure_msg "You must be root to start, stop or restart $NAME." + exit 4 + fi +} + +force_stop() { + +DELAY=1 +PROCLIST="xrdp-sesman xrdp-sessvc xrdp-chansrv X11rdp Xvnc" + + for p in $PROCLIST; do + pgrep -x $p >/dev/null && pkill -x $p + sleep $DELAY + pgrep -x $p >/dev/null && pkill -9 -x $p + done + # let's not kill ourselves - the init script is called xrdp as well + pgrep -fx $DAEMON >/dev/null && pkill -fx $DAEMON + sleep $DELAY + pgrep -fx $DAEMON >/dev/null && pkill -9 -fx $DAEMON + + rm -f $PIDDIR/xrdp*.pid +} + if [ -r /etc/default/$NAME ]; then . /etc/default/$NAME fi -# Check for pid dir -if [ ! -d $PIDDIR ] ; then +# Tasks that can only be run as root +if [ "$(id -u)" = "0" ]; then + # Check for pid dir + if [ ! -d $PIDDIR ] ; then mkdir $PIDDIR -fi -chown $USERID:$USERID $PIDDIR + fi + chown $USERID:$USERID $PIDDIR -# Check for rsa key -if [ ! -f $RSAKEYS ] || cmp $RSAKEYS /usr/share/doc/xrdp/rsakeys.ini > /dev/null; then - echo "Generating xrdp RSA keys..." + # Check for rsa key + if [ ! -f $RSAKEYS ] || cmp $RSAKEYS /usr/share/doc/xrdp/rsakeys.ini > /dev/null; then + log_action_begin_msg "Generating xrdp RSA keys..." (umask 077 ; xrdp-keygen xrdp $RSAKEYS) chown $USERID:$USERID $RSAKEYS + if [ ! -f $RSAKEYS ] ; then + log_action_end_msg 1 "could not create $RSAKEYS" + exit 1 + fi + log_action_end_msg 0 "done" + fi fi -set -e - case "$1" in start) - echo -n "Starting $DESC: " + check_root + exitval=0 + log_daemon_msg "Starting $DESC " + if pidofproc -p $PIDDIR/$NAME.pid $DAEMON > /dev/null; then + log_progress_msg "$NAME apparently already running" + log_end_msg 0 + exit 0 + fi + log_progress_msg $NAME start-stop-daemon --start --quiet --oknodo --pidfile $PIDDIR/$NAME.pid \ - --chuid $USERID:$USERID --exec $DAEMON - echo -n "$NAME" - [ "$SESMAN_START" = "yes" ] && { \ + --chuid $USERID:$USERID --exec $DAEMON >/dev/null + exitval=$? + if [ "$SESMAN_START" = "yes" ] ; then + log_progress_msg "sesman" start-stop-daemon --start --quiet --oknodo --pidfile $PIDDIR/xrdp-sesman.pid \ - --exec /usr/sbin/xrdp-sesman - echo -n " sesman" - } - echo "." + --exec /usr/sbin/xrdp-sesman >/dev/null + value=$? + [ $value -gt 0 ] && exitval=$value + fi + # Make pidfile readables for all users (for status to work) + [ -e $PIDDIR/xrdp-sesman.pid ] && chmod 0644 $PIDDIR/xrdp-sesman.pid + [ -e $PIDDIR/$NAME.pid ] && chmod 0644 $PIDDIR/$NAME.pid + # Note: Unfortunately, xrdp currently takes too long to create + # the pidffile unless properly patched + log_end_msg $exitval ;; stop) + check_root [ -n "$XRDP_UPGRADE" -a "$RESTART_ON_UPGRADE" = "no" ] && { echo "Upgrade in progress, no restart of xrdp." exit 0 } - echo -n "Stopping $DESC: " - start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/xrdp-sesman.pid \ - --chuid $USERID:$USERID --exec /usr/sbin/xrdp-sesman - echo -n "sesman " - start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/$NAME.pid \ + exitval=0 + log_daemon_msg "Stopping RDP Session manager " + log_progress_msg "sesman" + if pidofproc -p $PIDDIR/xrdp-sesman.pid /usr/sbin/xrdp-sesman > /dev/null; then + start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/xrdp-sesman.pid \ + --chuid $USERID:$USERID --exec /usr/sbin/xrdp-sesman + exitval=$? + else + log_progress_msg "apparently not running" + fi + log_progress_msg $NAME + if pidofproc -p $PIDDIR/$NAME.pid $DAEMON > /dev/null; then + start-stop-daemon --stop --quiet --oknodo --pidfile $PIDDIR/$NAME.pid \ --exec $DAEMON - sleep 1 - echo "$NAME." + value=$? + [ $value -gt 0 ] && exitval=$value + else + log_progress_msg "apparently not running" + fi + log_end_msg $exitval ;; - restart) + force-stop) $0 stop + # because it doesn't allways die the right way + force_stop + ;; + restart|force-reload) + check_root + $0 stop + # Wait for things to settle down + sleep 1 $0 start ;; + reload) + log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon" + log_warning_msg "cannot re-read the config file (use restart)." + ;; + status) + exitval=0 + log_daemon_msg "Checking status of $DESC" "$NAME" + if pidofproc -p $PIDDIR/$NAME.pid $DAEMON > /dev/null; then + log_progress_msg "running" + log_end_msg 0 + else + log_progress_msg "apparently not running" + log_end_msg 1 || true + exitval=1 + fi + if [ "$SESMAN_START" = "yes" ] ; then + log_daemon_msg "Checking status of RDP Session Manager" "sesman" + if pidofproc -p $PIDDIR/xrdp-sesman.pid /usr/sbin/xrdp-sesman > /dev/null; then + log_progress_msg "running" + log_end_msg 0 + else + log_progress_msg "apparently not running" + log_end_msg 1 || true + exitval=1 + fi + fi + exit $exitval + ;; *) N=/etc/init.d/$NAME - # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $N {start|stop|restart|force-reload}" >&2 + echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 exit 1 ;; esac From 3543206ad76bfe4c27960cd33354de2d1c0fa3f3 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 18:28:17 +0000 Subject: [PATCH 12/23] correct usage --- instfiles/init.d/xrdp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instfiles/init.d/xrdp b/instfiles/init.d/xrdp index 8ed8cc23..f9804381 100644 --- a/instfiles/init.d/xrdp +++ b/instfiles/init.d/xrdp @@ -177,7 +177,7 @@ case "$1" in ;; *) N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|force-reload|status}" >&2 + echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2 exit 1 ;; esac From 08f5a2e7c40e78e8df4bb735c5963e04ed866ebc Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 19:09:08 +0000 Subject: [PATCH 13/23] helper file for checkinstall --- description-pak | 1 + 1 file changed, 1 insertion(+) create mode 100644 description-pak diff --git a/description-pak b/description-pak new file mode 100644 index 00000000..9be64541 --- /dev/null +++ b/description-pak @@ -0,0 +1 @@ +RDP server for Linux From fbe1e2ab74189ad0bbf94ec715b36270f7c37b20 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 19:48:29 +0000 Subject: [PATCH 14/23] Post install script --- postinstall-pak | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 postinstall-pak diff --git a/postinstall-pak b/postinstall-pak new file mode 100644 index 00000000..de913aed --- /dev/null +++ b/postinstall-pak @@ -0,0 +1,24 @@ +#!/bin/sh -e + +if ! ([ "$1" = "configure" ] || [ "$1" = "reconfigure" ]); then + exit 0 +fi + + +XRDP="xrdp" +ADDUSER="/usr/sbin/adduser" +XRDPLOG="/var/log/xrdp-sesman.log" +SESMANLOG="/var/log/xrdp-sesman.log" +RSAKEYS="/etc/xrdp/rsakeys.ini" + +[ -d /var/run/xrdp ] || mkdir -p /var/run/xrdp +$ADDUSER --system --disabled-password --disabled-login --home /var/run/xrdp \ + --no-create-home --quiet --group $XRDP + +touch $SESMANLOG $XRDPLOG +chown $XRDP:$XRDP $SESMANLOG +chown $XRDP:$XRDP $XRDPLOG +chgrp $XRDP $RSAKEYS +chmod g+r $RSAKEYS + +#DEBHELPER# From 9239b6e87ded6af7aafa4c82e270ba130f830620 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 21:13:44 +0000 Subject: [PATCH 15/23] prepare to package X11rdp on a single .deb --- xorg/debuild/debX11rdp.sh | 24 +++++++++++++++++++++++ xorg/debuild/x11rdp-files/DEBIAN/control | 7 +++++++ xorg/debuild/x11rdp-files/DEBIAN/postinst | 18 +++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100755 xorg/debuild/debX11rdp.sh create mode 100644 xorg/debuild/x11rdp-files/DEBIAN/control create mode 100755 xorg/debuild/x11rdp-files/DEBIAN/postinst diff --git a/xorg/debuild/debX11rdp.sh b/xorg/debuild/debX11rdp.sh new file mode 100755 index 00000000..3e713926 --- /dev/null +++ b/xorg/debuild/debX11rdp.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# receives version, release number and source directory as arguments + +VERSION=$1 +RELEASE=$2 +SRCDIR=$3 +PKGDEST=$4 + +PACKDIR=x11rdp-files +DESTDIR=$PACKDIR/opt +NAME=x11rdp + +sed -i -e "s/DUMMYVERINFO/$VERSION-$RELEASE/" $PACKDIR/DEBIAN/control +sed -i -e "s/DUMMYDIRINFO/$SRCDIR/" $PACKDIR/DEBIAN/postinst + +mkdir -p $DESTDIR +cp -Rf $SRCDIR $DESTDIR +dpkg-deb --build $PACKDIR $PKGDEST/${NAME}_$VERSION-$RELEASE.deb + +# revert to initial state +rm -rf $DESTDIR +sed -i -e "s/$VERSION-$RELEASE/DUMMYVERINFO/" $PACKDIR/DEBIAN/control +sed -i -e "s/$SRCDIR/DUMMYDIRINFO/" $PACKDIR/DEBIAN/postinst diff --git a/xorg/debuild/x11rdp-files/DEBIAN/control b/xorg/debuild/x11rdp-files/DEBIAN/control new file mode 100644 index 00000000..59a3f94d --- /dev/null +++ b/xorg/debuild/x11rdp-files/DEBIAN/control @@ -0,0 +1,7 @@ +Package: x11rdp +Version: DUMMYVERINFO +Section: unknown +Priority: optional +Architecture: all +Maintainer: Angulo Solido +Description: X11rdp backend for the xrdp remote access server diff --git a/xorg/debuild/x11rdp-files/DEBIAN/postinst b/xorg/debuild/x11rdp-files/DEBIAN/postinst new file mode 100755 index 00000000..b44dc212 --- /dev/null +++ b/xorg/debuild/x11rdp-files/DEBIAN/postinst @@ -0,0 +1,18 @@ +#!/bin/bash + +X11DIR=/opt/X11rdp + +# make the /usr/bin/X11rdp symbolic link if it doesn't exist... +if [ ! -e /usr/bin/X11rdp ] +then + if [ -e $X11DIR/bin/X11rdp ] + then + ln -s $X11DIR/bin/X11rdp /usr/bin/X11rdp + else + clear + echo "There was a problem... the $X11DIR/bin/X11rdp binary could not be found. Did the compilation complete?" + echo "Stopped. Please investigate what went wrong." + exit + fi +fi + From ec7d8680084c794357d0786767eda903d9c19e26 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Wed, 20 Mar 2013 21:41:56 +0000 Subject: [PATCH 16/23] improve packaging for X11RDP --- xorg/debuild/debX11rdp.sh | 5 +++-- xorg/debuild/x11rdp-files/DEBIAN/postinst | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/xorg/debuild/debX11rdp.sh b/xorg/debuild/debX11rdp.sh index 3e713926..dd80cbe9 100755 --- a/xorg/debuild/debX11rdp.sh +++ b/xorg/debuild/debX11rdp.sh @@ -12,7 +12,8 @@ DESTDIR=$PACKDIR/opt NAME=x11rdp sed -i -e "s/DUMMYVERINFO/$VERSION-$RELEASE/" $PACKDIR/DEBIAN/control -sed -i -e "s/DUMMYDIRINFO/$SRCDIR/" $PACKDIR/DEBIAN/postinst +# need a different delimiter, since it has a path +sed -i -e "s,DUMMYDIRINFO,$SRCDIR," $PACKDIR/DEBIAN/postinst mkdir -p $DESTDIR cp -Rf $SRCDIR $DESTDIR @@ -21,4 +22,4 @@ dpkg-deb --build $PACKDIR $PKGDEST/${NAME}_$VERSION-$RELEASE.deb # revert to initial state rm -rf $DESTDIR sed -i -e "s/$VERSION-$RELEASE/DUMMYVERINFO/" $PACKDIR/DEBIAN/control -sed -i -e "s/$SRCDIR/DUMMYDIRINFO/" $PACKDIR/DEBIAN/postinst +sed -i -e "s,$SRCDIR,DUMMYDIRINFO," $PACKDIR/DEBIAN/postinst diff --git a/xorg/debuild/x11rdp-files/DEBIAN/postinst b/xorg/debuild/x11rdp-files/DEBIAN/postinst index b44dc212..241103af 100755 --- a/xorg/debuild/x11rdp-files/DEBIAN/postinst +++ b/xorg/debuild/x11rdp-files/DEBIAN/postinst @@ -1,6 +1,6 @@ #!/bin/bash -X11DIR=/opt/X11rdp +X11DIR=DUMMYDIRINFO # make the /usr/bin/X11rdp symbolic link if it doesn't exist... if [ ! -e /usr/bin/X11rdp ] From bd8df09b6d46288dde5f163ba3823f7ec5d81b8e Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Thu, 21 Mar 2013 00:28:47 +0000 Subject: [PATCH 17/23] remove unused files, include arch info --- debian/changelog | 11 ------ debian/copyright | 50 ------------------------ debian/postinst | 24 ------------ debian/rules | 18 --------- xorg/debuild/debX11rdp.sh | 7 +++- xorg/debuild/x11rdp-files/DEBIAN/control | 2 +- 6 files changed, 7 insertions(+), 105 deletions(-) delete mode 100644 debian/changelog delete mode 100644 debian/copyright delete mode 100644 debian/postinst delete mode 100644 debian/rules diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index ccfdc5e5..00000000 --- a/debian/changelog +++ /dev/null @@ -1,11 +0,0 @@ -xrdp (0.7.0-1) unstable; urgency=low - - * Initial release - - -- Angulo Solido Wed, 20 Mar 2013 19:46:06 +0100 - -xrdp (0.6.0-1) unstable; urgency=low - - * Initial release (Closes: #nnnn) - - -- Angulo Solido Mon, 22 Aug 2011 19:46:06 +0100 diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 723d3452..00000000 --- a/debian/copyright +++ /dev/null @@ -1,50 +0,0 @@ -This work was packaged for Debian by: - - Angulo Solido on Mon, 22 Aug 2011 19:46:06 +0100 - -It was downloaded from: - - - -Upstream Author(s): - - - - -Copyright: - - - - -License: - - 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 3 of the License, or - (at your option) any later version. - - This package 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, see . - -On Debian systems, the complete text of the GNU General -Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'. - -The Debian packaging is: - - Copyright (C) 2011 Angulo Solido - -# Please chose a license for your packaging work. If the program you package -# uses a mainstream license, using the same license is the safest choice. -# Please avoid to pick license terms that are more restrictive than the -# packaged work, as it may make Debian's contributions unacceptable upstream. -# If you just want it to be GPL version 3, leave the following line in. - -and is licensed under the GPL version 3, see above. - -# Please also look if there are files or directories which have a -# different copyright/license attached and list them here. diff --git a/debian/postinst b/debian/postinst deleted file mode 100644 index de913aed..00000000 --- a/debian/postinst +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -e - -if ! ([ "$1" = "configure" ] || [ "$1" = "reconfigure" ]); then - exit 0 -fi - - -XRDP="xrdp" -ADDUSER="/usr/sbin/adduser" -XRDPLOG="/var/log/xrdp-sesman.log" -SESMANLOG="/var/log/xrdp-sesman.log" -RSAKEYS="/etc/xrdp/rsakeys.ini" - -[ -d /var/run/xrdp ] || mkdir -p /var/run/xrdp -$ADDUSER --system --disabled-password --disabled-login --home /var/run/xrdp \ - --no-create-home --quiet --group $XRDP - -touch $SESMANLOG $XRDPLOG -chown $XRDP:$XRDP $SESMANLOG -chown $XRDP:$XRDP $XRDPLOG -chgrp $XRDP $RSAKEYS -chmod g+r $RSAKEYS - -#DEBHELPER# diff --git a/debian/rules b/debian/rules deleted file mode 100644 index 2c29bebf..00000000 --- a/debian/rules +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- - -%: - dh $@ - -LDFLAGS = -lpthread - -override_dh_auto_configure: - ./bootstrap - ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var - find -name Makefile | while read i; do sed -e 's#\(XRDP_PID_PATH.*/run\)#\1/xrdp#g' -i "$$i"; done - - -override_dh_installdeb: - # Move rsakeys to documentation - mv debian/xrdp/etc/xrdp/rsakeys.ini debian/xrdp/usr/share/doc/xrdp - dh_installdeb -a diff --git a/xorg/debuild/debX11rdp.sh b/xorg/debuild/debX11rdp.sh index dd80cbe9..23b1428e 100755 --- a/xorg/debuild/debX11rdp.sh +++ b/xorg/debuild/debX11rdp.sh @@ -10,16 +10,21 @@ PKGDEST=$4 PACKDIR=x11rdp-files DESTDIR=$PACKDIR/opt NAME=x11rdp +ARCH=$( dpkg --print-architecture ) + sed -i -e "s/DUMMYVERINFO/$VERSION-$RELEASE/" $PACKDIR/DEBIAN/control +sed -i -e "s/DUMMYARCHINFO/$ARCH/" $PACKDIR/DEBIAN/control # need a different delimiter, since it has a path sed -i -e "s,DUMMYDIRINFO,$SRCDIR," $PACKDIR/DEBIAN/postinst mkdir -p $DESTDIR cp -Rf $SRCDIR $DESTDIR -dpkg-deb --build $PACKDIR $PKGDEST/${NAME}_$VERSION-$RELEASE.deb +dpkg-deb --build $PACKDIR $PKGDEST/${NAME}_$VERSION-${RELEASE}_${ARCH}.deb # revert to initial state rm -rf $DESTDIR sed -i -e "s/$VERSION-$RELEASE/DUMMYVERINFO/" $PACKDIR/DEBIAN/control +sed -i -e "s/$ARCH/DUMMYARCHINFO/" $PACKDIR/DEBIAN/control +# need a different delimiter, since it has a path sed -i -e "s,$SRCDIR,DUMMYDIRINFO," $PACKDIR/DEBIAN/postinst diff --git a/xorg/debuild/x11rdp-files/DEBIAN/control b/xorg/debuild/x11rdp-files/DEBIAN/control index 59a3f94d..149e9a83 100644 --- a/xorg/debuild/x11rdp-files/DEBIAN/control +++ b/xorg/debuild/x11rdp-files/DEBIAN/control @@ -2,6 +2,6 @@ Package: x11rdp Version: DUMMYVERINFO Section: unknown Priority: optional -Architecture: all +Architecture: DUMMYARCHINFO Maintainer: Angulo Solido Description: X11rdp backend for the xrdp remote access server From 5db47b08c6655a12b3931568a3ef3f58850b63a3 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Thu, 21 Mar 2013 18:20:16 +0000 Subject: [PATCH 18/23] clear things that are handled by the init script --- postinstall-pak | 3 --- 1 file changed, 3 deletions(-) diff --git a/postinstall-pak b/postinstall-pak index de913aed..011857ad 100644 --- a/postinstall-pak +++ b/postinstall-pak @@ -9,7 +9,6 @@ XRDP="xrdp" ADDUSER="/usr/sbin/adduser" XRDPLOG="/var/log/xrdp-sesman.log" SESMANLOG="/var/log/xrdp-sesman.log" -RSAKEYS="/etc/xrdp/rsakeys.ini" [ -d /var/run/xrdp ] || mkdir -p /var/run/xrdp $ADDUSER --system --disabled-password --disabled-login --home /var/run/xrdp \ @@ -18,7 +17,5 @@ $ADDUSER --system --disabled-password --disabled-login --home /var/run/xrdp \ touch $SESMANLOG $XRDPLOG chown $XRDP:$XRDP $SESMANLOG chown $XRDP:$XRDP $XRDPLOG -chgrp $XRDP $RSAKEYS -chmod g+r $RSAKEYS #DEBHELPER# From e702ac79d4700f73a4e9fc3d45c0d68e6e0ce846 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Thu, 21 Mar 2013 18:20:38 +0000 Subject: [PATCH 19/23] don't copy stock rsakeys.init --- xrdp/Makefile.am | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xrdp/Makefile.am b/xrdp/Makefile.am index 25ab3eed..6600c621 100644 --- a/xrdp/Makefile.am +++ b/xrdp/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = xrdp.ini rsakeys.ini ad24b.bmp ad256.bmp xrdp24b.bmp xrdp256.bmp sans-10.fv1 cursor0.cur cursor1.cur xrdp.h xrdp_types.h +EXTRA_DIST = xrdp.ini ad24b.bmp ad256.bmp xrdp24b.bmp xrdp256.bmp sans-10.fv1 cursor0.cur cursor1.cur xrdp.h xrdp_types.h if XRDP_DEBUG EXTRA_DEFINES = -DXRDP_DEBUG @@ -43,8 +43,7 @@ xrdp_LDADD = \ xrdpsysconfdir=$(sysconfdir)/xrdp xrdpsysconf_DATA = \ - xrdp.ini \ - rsakeys.ini + xrdp.ini xrdppkgdatadir=$(datadir)/xrdp From 4abac0a05d7b752e90f64fe30a01cee9ced725e4 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Thu, 21 Mar 2013 18:22:21 +0000 Subject: [PATCH 20/23] remove awkward rsakeys.init comparison --- instfiles/init.d/xrdp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instfiles/init.d/xrdp b/instfiles/init.d/xrdp index f9804381..2cf20999 100644 --- a/instfiles/init.d/xrdp +++ b/instfiles/init.d/xrdp @@ -67,7 +67,7 @@ if [ "$(id -u)" = "0" ]; then chown $USERID:$USERID $PIDDIR # Check for rsa key - if [ ! -f $RSAKEYS ] || cmp $RSAKEYS /usr/share/doc/xrdp/rsakeys.ini > /dev/null; then + if [ ! -f $RSAKEYS ] ; then log_action_begin_msg "Generating xrdp RSA keys..." (umask 077 ; xrdp-keygen xrdp $RSAKEYS) chown $USERID:$USERID $RSAKEYS From 23584f7e5fff06e2782f19d8f1adfd6100161cf7 Mon Sep 17 00:00:00 2001 From: Gustavo Homem Date: Thu, 21 Mar 2013 18:39:39 +0000 Subject: [PATCH 21/23] remove legacy operation on rsakeys.ini --- xrdp/Makefile.am | 3 --- 1 file changed, 3 deletions(-) diff --git a/xrdp/Makefile.am b/xrdp/Makefile.am index 6600c621..3fe0138a 100644 --- a/xrdp/Makefile.am +++ b/xrdp/Makefile.am @@ -56,6 +56,3 @@ xrdppkgdata_DATA = \ cursor0.cur \ cursor1.cur -# must be tab below -install-data-hook: - chmod 600 $(DESTDIR)$(sysconfdir)/xrdp/rsakeys.ini From 97c483c8b3d76a943fc315e58db798256ee1e488 Mon Sep 17 00:00:00 2001 From: Laxmikant Rashinkar Date: Sat, 20 Apr 2013 16:42:49 -0700 Subject: [PATCH 22/23] swapped cb_lookup and cb_readdir --- sesman/chansrv/chansrv_fuse.c | 674 +++++++++++++++++++++++++++++++--- sesman/chansrv/devredir.c | 71 +++- sesman/chansrv/devredir.h | 3 + xrdp/xrdp.ini | 3 +- 4 files changed, 684 insertions(+), 67 deletions(-) diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c index 79bf8714..76608be0 100644 --- a/sesman/chansrv/chansrv_fuse.c +++ b/sesman/chansrv/chansrv_fuse.c @@ -41,7 +41,7 @@ * */ -// LK_TODO #define USE_SYNC_FLAG +//#define USE_SYNC_FLAG /* FUSE mount point */ char g_fuse_root_path[256] = ""; @@ -139,7 +139,7 @@ void xfuse_devredir_cb_file_close(void *vp) {} #define log_debug(_params...) \ { \ - if (LOG_DEBUG <= LOG_LEVEL) \ + if (LOG_DEBUG <= LOG_LEVEL) \ { \ g_write("[%10.10u]: FUSE %s: %d : ", \ g_time3(), __func__, __LINE__); \ @@ -164,6 +164,13 @@ struct dirbuf size_t size; }; +struct dirbuf1 +{ + char buf[4096]; + int bytes_in_buf; + int first_time; +}; + /* FUSE reply types */ #define RT_FUSE_REPLY_OPEN 1 #define RT_FUSE_REPLY_CREATE 2 @@ -181,6 +188,9 @@ struct xfuse_info int reply_type; int mode; int type; + size_t size; + off_t off; + struct dirbuf1 dirbuf1; }; typedef struct xfuse_info XFUSE_INFO; @@ -227,10 +237,13 @@ static struct xrdp_inode * xfuse_create_file_in_xrdp_fs(tui32 device_id, int pinode, char *name, int type); -static int xfuse_does_file_exist(int parent, char *name); -static int xfuse_delete_file(int parent, char *name); -static int xfuse_delete_file_with_xinode(XRDP_INODE *xinode); -static int xfuse_delete_dir_with_xinode(XRDP_INODE *xinode); +static int xfuse_does_file_exist(int parent, char *name); +static int xfuse_delete_file(int parent, char *name); +static int xfuse_delete_file_with_xinode(XRDP_INODE *xinode); +static int xfuse_delete_dir_with_xinode(XRDP_INODE *xinode); +static void xfuse_update_xrdpfs_size(); +static void xfuse_enum_dir(fuse_req_t req, fuse_ino_t ino, size_t size, + off_t off, struct fuse_file_info *fi); /* forward declarations for calls we make into devredir */ int dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path); @@ -255,6 +268,9 @@ static void xfuse_cb_getattr(fuse_req_t req, fuse_ino_t ino, static void xfuse_dirbuf_add(fuse_req_t req, struct dirbuf *b, const char *name, fuse_ino_t ino); +static int xfuse_dirbuf_add1(fuse_req_t req, struct dirbuf1 *b, + const char *name, fuse_ino_t ino); + static void xfuse_cb_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, struct fuse_file_info *fi); @@ -410,6 +426,10 @@ int xfuse_init() #if 0 sprintf(opt, "-o uid=%d,gid=%d", g_getuid(), g_getgid()); fuse_opt_add_arg(&args, opt); +#else + /* disable multi threading */ + sprintf(opt, "-s"); + fuse_opt_add_arg(&args, opt); #endif if (xfuse_init_lib(&args)) @@ -548,12 +568,6 @@ int xfuse_create_share(tui32 device_id, char *dirname) return -1; } - if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL) - { - log_error("system out of memory"); - return -1; - } - /* create directory entry */ xinode->parent_inode = 1; xinode->inode = g_xrdp_fs.next_node++; @@ -582,6 +596,13 @@ int xfuse_create_share(tui32 device_id, char *dirname) return -1; xinode->nentries++; +#if 0 + if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL) + { + log_error("system out of memory"); + return -1; + } + /* enumerate root dir, do not call FUSE when done */ fip->req = NULL; fip->inode = 1; // LK_TODO saved_inode; @@ -590,6 +611,7 @@ int xfuse_create_share(tui32 device_id, char *dirname) fip->device_id = device_id; dev_redir_get_dir_listing((void *) fip, device_id, "\\"); +#endif return 0; } @@ -652,14 +674,6 @@ int xfuse_file_contents_size(int stream_id, int file_size) static int xfuse_init_lib(struct fuse_args *args) { - // LK_TODO - { - int i; - - for (i = 0; i < args->argc; i++) - log_debug("+++++++++++++ argc=%d argv=%s", i, args->argv[i]); - } - if (fuse_parse_cmdline(args, &g_mount_point, 0, 0) < 0) { log_error("fuse_parse_cmdline() failed"); @@ -785,7 +799,7 @@ static int xfuse_init_xrdp_fs() xino->ctime = time(0); strcpy(xino->name, ".clipboard"); - g_xrdp_fs.max_entries = 1024; + g_xrdp_fs.max_entries = 4096; g_xrdp_fs.num_entries = 3; g_xrdp_fs.next_node = 3; @@ -865,6 +879,7 @@ static void xfuse_create_file(fuse_req_t req, fuse_ino_t parent, /* insert it in xrdp fs */ g_xrdp_fs.inode_table[xinode->inode] = xinode; + xfuse_update_xrdpfs_size(); log_debug("inserted new dir at inode_table[%d]", (int) xinode->inode); xfuse_dump_fs(); @@ -1064,7 +1079,7 @@ static struct xrdp_inode * xfuse_create_file_in_xrdp_fs(tui32 device_id, log_debug("S_IFDIR=0x%x S_IFREG=0x%x type=0x%x", S_IFDIR, S_IFREG, type); xinode->parent_inode = pinode; - xinode->inode = g_xrdp_fs.next_node++; /* TODO should be thread safe */ + xinode->inode = g_xrdp_fs.next_node++; xinode->nlink = 1; xinode->uid = getuid(); xinode->gid = getgid(); @@ -1087,13 +1102,14 @@ static struct xrdp_inode * xfuse_create_file_in_xrdp_fs(tui32 device_id, } g_xrdp_fs.inode_table[xinode->inode] = xinode; - g_xrdp_fs.num_entries++; /* TODO should be thread safe */ + g_xrdp_fs.num_entries++; /* bump up lookup count in parent dir */ xinodep = g_xrdp_fs.inode_table[pinode]; xinodep->nentries++; + xfuse_update_xrdpfs_size(); - log_debug("LK_TODO: incremented nentries; parent=%d nentries=%d", + log_debug("incremented nentries; parent=%d nentries=%d", pinode, xinodep->nentries); /* LK_TODO */ @@ -1181,6 +1197,85 @@ static int xfuse_delete_dir_with_xinode(XRDP_INODE *xinode) return 0; } +static void xfuse_update_xrdpfs_size() +{ + void *vp; + int diff; + + diff = g_xrdp_fs.max_entries - g_xrdp_fs.num_entries; + if (diff > 100) + return; + + /* extend memory */ + vp = realloc(g_xrdp_fs.inode_table, + (g_xrdp_fs.max_entries + 100) * sizeof(struct xrdp_inode *)); + + if (vp == NULL) + { + log_error("system out of memory"); + return; + } + + /* zero newly added memory */ + memset(vp + g_xrdp_fs.max_entries * sizeof(struct xrdp_inode *), + 0, + 100 * sizeof(struct xrdp_inode *)); + + g_xrdp_fs.max_entries += 100; + g_xrdp_fs.inode_table = vp; +} + +static void xfuse_enum_dir(fuse_req_t req, fuse_ino_t ino, size_t size, + off_t off, struct fuse_file_info *fi) +{ + XRDP_INODE *xinode; + XRDP_INODE *xinode1; + struct dirbuf b; + int first_time = 1; + int i; + + memset(&b, 0, sizeof(struct dirbuf)); + + for (i = FIRST_INODE; i < g_xrdp_fs.num_entries; i++) + { + if ((xinode = g_xrdp_fs.inode_table[i]) == NULL) + continue; + + /* match parent inode */ + if (xinode->parent_inode != ino) + continue; + + if (first_time) + { + first_time = 0; + if (ino == 1) + { + xfuse_dirbuf_add(req, &b, ".", 1); + xfuse_dirbuf_add(req, &b, "..", 1); + } + else + { + xinode1 = g_xrdp_fs.inode_table[ino]; + xfuse_dirbuf_add(req, &b, ".", ino); + xfuse_dirbuf_add(req, &b, "..", xinode1->parent_inode); + } + } + + xfuse_dirbuf_add(req, &b, xinode->name, xinode->inode); + } + + if (!first_time) + { + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, size)); + else + fuse_reply_buf(req, NULL, 0); + } + + if (b.p) + free(b.p); +} + /****************************************************************************** ** ** ** callbacks for devredir ** @@ -1191,10 +1286,138 @@ static int xfuse_delete_dir_with_xinode(XRDP_INODE *xinode) * Add a file or directory to xrdp file system *****************************************************************************/ +/* LK_TODO delete this after testing */ +#if 0 +void ___xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) +{ + XFUSE_INFO *fip = (XFUSE_INFO *) vp; + XRDP_INODE *xip = NULL; + + log_debug("<<<<<< entered"); + + if ((fip == NULL) || (xinode == NULL)) + { + log_error("fip or xinode are NULL"); + printf("RASH_TODO: fip or xinode are NULL - leaving\n"); + return; + } + + log_debug("req=%p", fip->req); + + /* do we have a valid inode? */ + if (!xfuse_is_inode_valid(fip->inode)) + { + log_error("inode %d is not valid", fip->inode); + printf("RASH_TODO: inode %d is not valid - leaving\n", (tui32) fip->inode); + return; + } + + /* if filename is . or .. don't add it */ + if ((strcmp(xinode->name, ".") == 0) || (strcmp(xinode->name, "..") == 0)) + { + free(xinode); + printf("RASH_TODO: not adding ./.. - leaving\n"); + return; + } + +// LK_TODO +#if 0 + /* we have a parent inode and a dir name; what we need is the xinode */ + /* that matches the parent inode and the dir name */ + target_inode = xfuse_get_inode_from_pinode_name(fip->inode, fip->name); + if (target_inode == 0) + { + log_debug("did not find entry with inode=%d name=%s", + fip->inode, fip->name); + return; + } +#endif + + if ((xip = xfuse_get_inode_from_pinode_name(fip->inode, xinode->name)) != NULL) + { + log_debug("inode=%d name=%s already exists in xrdp_fs; not adding it", + fip->inode, xinode->name); + free(xinode); + xinode = xip; + goto update_fuse; + } + + xinode->parent_inode = fip->inode; + xinode->inode = g_xrdp_fs.next_node++; + xinode->uid = getuid(); + xinode->gid = getgid(); + xinode->device_id = fip->device_id; + + g_xrdp_fs.num_entries++; + + /* insert it in xrdp fs and update lookup count */ + g_xrdp_fs.inode_table[xinode->inode] = xinode; + g_xrdp_fs.inode_table[fip->inode]->nentries; + xfuse_update_xrdpfs_size(); + +update_fuse: + +#if 1 + /* let FUSE know about this entry */ + if (fip->invoke_fuse) + { + struct dirbuf b; + + memset(&b, 0, sizeof(struct dirbuf)); + + /* RASH_TODO if we are not using dirbuf, change this code */ + if (fip->dirbuf == NULL) + { + fip->dirbuf = calloc(1, sizeof(struct dirbuf)); + xfuse_dirbuf_add(fip->req, &b, ".", xinode->inode); + xfuse_dirbuf_add(fip->req, &b, "..", xinode->parent_inode); + } + + xfuse_dirbuf_add(fip->req, &b, xinode->name, xinode->inode); + + if (fip->off < b.size) + { + printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): req=%p off=%d\n", + fip->req, (tui32) fip->off); + + printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): dumping req b4\n\n"); + g_hexdump((char *) fip->req, 128); + + printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): dumping buf b4\n\n"); + g_hexdump(b.p, b.size); + + printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): calling fuse\n"); + + fuse_reply_buf(fip->req, b.p, b.size); + + printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): calling fuse...done\n"); + + printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): dumping req aft\n\n"); + g_hexdump((char *) fip->req, 128); + + printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): dumping buf aft\n\n"); + g_hexdump(b.p, b.size); + } + else + { + printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): calling fuse with NULL\n"); + fuse_reply_buf(fip->req, NULL, 0); + printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): calling fuse with NULL...done\n"); + } + + log_debug("added inode=%d name=%s to FUSE", (tui32) xinode->inode, xinode->name); + } +#endif + + log_debug("leaving"); + printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): leaving\n"); +} +#endif + void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) { - XFUSE_INFO *fip = (XFUSE_INFO *) vp; - XRDP_INODE *target_inode; + XFUSE_INFO *fip = (XFUSE_INFO *) vp; + XRDP_INODE *xip = NULL; if ((fip == NULL) || (xinode == NULL)) { @@ -1202,15 +1425,12 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) return; } -/* LK_TODO */ -#if 0 - /* do we have a valid inode? */ + if (!xfuse_is_inode_valid(fip->inode)) { log_error("inode %d is not valid", fip->inode); return; } -#endif /* if filename is . or .. don't add it */ if ((strcmp(xinode->name, ".") == 0) || (strcmp(xinode->name, "..") == 0)) @@ -1219,19 +1439,16 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) return; } - /* we have a parent inode and a dir name; what we need is the xinode */ - /* that matches the parent inode and the dir name */ - target_inode = xfuse_get_inode_from_pinode_name(fip->inode, fip->name); - if (target_inode == 0) - return; - - if (xfuse_does_file_exist(target_inode->inode, xinode->name)) + if ((xip = xfuse_get_inode_from_pinode_name(fip->inode, xinode->name)) != NULL) { + log_debug("inode=%d name=%s already exists in xrdp_fs; not adding it", + fip->inode, xinode->name); free(xinode); + xinode = xip; return; } - xinode->parent_inode = target_inode->inode; + xinode->parent_inode = fip->inode; xinode->inode = g_xrdp_fs.next_node++; xinode->uid = getuid(); xinode->gid = getgid(); @@ -1239,21 +1456,124 @@ void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) g_xrdp_fs.num_entries++; - /* insert it in xrdp fs */ + /* insert it in xrdp fs and update lookup count */ g_xrdp_fs.inode_table[xinode->inode] = xinode; - - /* bump up lookup count */ - xinode = g_xrdp_fs.inode_table[target_inode->inode]; - xinode->nentries++; - - log_debug("added %s to pinode=%d, nentries=%d target_inode->inode=%d", - fip->name, fip->inode, xinode->nentries, target_inode->inode); + g_xrdp_fs.inode_table[fip->inode]->nentries; + xfuse_update_xrdpfs_size(); } /** *****************************************************************************/ void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus) +{ + log_debug(">>>>>> vp=%p IoStatus=0x%x", vp, IoStatus); + + if (vp == NULL) + return; + + XRDP_INODE *xinode; + XRDP_INODE *ti; + struct dirbuf1 b; + int i; + int first_time = 1; + + XFUSE_INFO *fip = (XFUSE_INFO *) vp; + + if (fip == NULL) + { + log_debug("fip is NULL"); + goto done; + } + + if (IoStatus != 0) + { + /* command failed */ + if (fip->invoke_fuse) + fuse_reply_err(fip->req, ENOENT); + goto done; + } + + /* do we have a valid inode? */ + if (!xfuse_is_inode_valid(fip->inode)) + { + log_error("inode %d is not valid", fip->inode); + if (fip->invoke_fuse) + fuse_reply_err(fip->req, EBADF); + goto done; + } +#if 0 + memset(&b, 0, sizeof(struct dirbuf)); +#else + b.bytes_in_buf = 0; +#endif + for (i = FIRST_INODE; i < g_xrdp_fs.num_entries; i++) + { + if ((xinode = g_xrdp_fs.inode_table[i]) == NULL) + continue; + + /* match parent inode */ + if (xinode->parent_inode != fip->inode) + continue; + + xinode->is_synced = 1; + + if (first_time) + { + first_time = 0; + ti = g_xrdp_fs.inode_table[fip->inode]; +#if 0 + xfuse_dirbuf_add(fip->req, &b, ".", fip->inode); + xfuse_dirbuf_add(fip->req, &b, "..", ti->parent_inode); +#else + xfuse_dirbuf_add1(fip->req, &b, ".", fip->inode); + xfuse_dirbuf_add1(fip->req, &b, "..", ti->parent_inode); +#endif + } +#if 0 + xfuse_dirbuf_add(fip->req, &b, xinode->name, xinode->inode); +#else + xfuse_dirbuf_add1(fip->req, &b, xinode->name, xinode->inode); +#endif + } + + if ((first_time == 0) && (fip->invoke_fuse)) + { + if (fip->off < b.bytes_in_buf) + { +#if 0 + fuse_reply_buf(fip->req, b.p + fip->off, + min(b.size - fip->off, fip->size)); +#else + fuse_reply_buf(fip->req, b.buf, b.bytes_in_buf); +#endif + fuse_reply_buf(fip->req, NULL, 0); + } + else + { + fuse_reply_buf(fip->req, NULL, 0); + } + } + else + { + fuse_reply_err(fip->req, ENOENT); + } + +done: + +#if 0 + if (b.p) + free(b.p); +#endif + + if (!fip) + printf("###### %s : %s : %d: fip is NULL\n", __FILE__, __func__, __LINE__); + + if (fip) + free(fip); +} + +void xfuse_devredir_cb_enum_dir_done_TODO(void *vp, tui32 IoStatus) { struct xrdp_inode *xinode; struct fuse_entry_param e; @@ -1261,6 +1581,8 @@ void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus) XFUSE_INFO *fip = (XFUSE_INFO *) vp; + printf("--------- xfuse_devredir_cb_enum_dir_done() entered\n"); + xfuse_dump_fs(); if (fip == NULL) @@ -1598,6 +1920,49 @@ void xfuse_devredir_cb_file_close(void *vp) *****************************************************************************/ static void xfuse_cb_lookup(fuse_req_t req, fuse_ino_t parent, const char *name) +{ + XRDP_INODE *xinode; + struct fuse_entry_param e; + + log_debug("looking for parent=%d name=%s", (int) parent, name); + xfuse_dump_fs(); + + if (!xfuse_is_inode_valid(parent)) + { + log_error("inode %d is not valid", parent); + fuse_reply_err(req, EBADF); + return; + } + + xinode = xfuse_get_inode_from_pinode_name(parent, name); + if (xinode == NULL) + { + log_debug("did not find entry for parent=%d name=%s", parent, name); + fuse_reply_err(req, ENOENT); + return; + } + + memset(&e, 0, sizeof(e)); + e.ino = xinode->inode; + e.attr_timeout = XFUSE_ATTR_TIMEOUT; + e.entry_timeout = XFUSE_ENTRY_TIMEOUT; + e.attr.st_ino = xinode->inode; + e.attr.st_mode = xinode->mode; + e.attr.st_nlink = xinode->nlink; + e.attr.st_uid = xinode->uid; + e.attr.st_gid = xinode->gid; + e.attr.st_size = xinode->size; + e.attr.st_atime = xinode->atime; + e.attr.st_mtime = xinode->mtime; + e.attr.st_ctime = xinode->ctime; + e.generation = 1; + + fuse_reply_entry(req, &e); + log_debug("found entry for parent=%d name=%s", parent, name); + return; +} + +static void xfuse_cb_lookup_TODO(fuse_req_t req, fuse_ino_t parent, const char *name) { XFUSE_INFO *fip; XRDP_INODE *xinode; @@ -1606,6 +1971,9 @@ static void xfuse_cb_lookup(fuse_req_t req, fuse_ino_t parent, const char *name) char full_path[4096]; char *cptr; + /* SPEEDUP_TODO */ + printf("###### cb_lookup: looking for parent=%d name=%s\n", (int) parent, name); + log_debug("ENTERED: looking for parent=%d name=%s", (int) parent, name); xfuse_dump_fs(); @@ -1619,7 +1987,7 @@ static void xfuse_cb_lookup(fuse_req_t req, fuse_ino_t parent, const char *name) if ((xinode = xfuse_get_inode_from_pinode_name(parent, name)) != NULL) { - log_debug("LK_TODO: got match: device_id=%d", xinode->device_id); + log_debug("got match: device_id=%d", xinode->device_id); /* got a full match; if this dir is located on a remote device */ /* and is not synced, do a remote look up */ @@ -1659,13 +2027,15 @@ do_remote_lookup: /* if ino belongs to a redirected share, pass the call to devredir; */ /* when done, devredir will invoke xfuse_devredir_cb_enum_dir_done(...) */ strcpy(full_path, name); - log_debug("LK_TODO: full_path=%s name=%s", full_path, name); + log_debug("full_path=%s name=%s", full_path, name); device_id = xfuse_get_device_id_for_inode((tui32) parent, full_path); log_debug("device_id=%d", device_id); if (device_id != 0) { log_debug("did not find entry; redirecting call to dev_redir"); + printf("????????? xfuse_cb_lookup() doing remote lookup for %s\n", name); + if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL) { log_error("system out of memory"); @@ -1729,7 +2099,7 @@ static void xfuse_cb_getattr(fuse_req_t req, fuse_ino_t ino, (void) fi; - log_debug("ino=%d", (int) ino); + log_debug("req=%p ino=%d", req, (int) ino); /* if ino is not valid, just return */ if (!xfuse_is_inode_valid(ino)) @@ -1740,7 +2110,6 @@ static void xfuse_cb_getattr(fuse_req_t req, fuse_ino_t ino, } xino = g_xrdp_fs.inode_table[ino]; - xfuse_dump_xrdp_inode(xino); memset(&stbuf, 0, sizeof(stbuf)); stbuf.st_ino = ino; @@ -1749,6 +2118,7 @@ static void xfuse_cb_getattr(fuse_req_t req, fuse_ino_t ino, stbuf.st_size = xino->size; fuse_reply_attr(req, &stbuf, 1.0); + log_debug("exiting"); } /** @@ -1772,12 +2142,209 @@ static void xfuse_dirbuf_add(fuse_req_t req, struct dirbuf *b, b->size); } +static int xfuse_dirbuf_add1(fuse_req_t req, struct dirbuf1 *b, + const char *name, fuse_ino_t ino) +{ + struct stat stbuf; + int len; + + len = fuse_add_direntry(req, NULL, 0, name, NULL, 0); + if (b->bytes_in_buf + len > 4096) + { + log_debug("not adding entry because dirbuf overflow would occur"); + return -1; + } + + memset(&stbuf, 0, sizeof(stbuf)); + stbuf.st_ino = ino; + + fuse_add_direntry(req, + &b->buf[b->bytes_in_buf], /* index where new entry will be added to buf */ + 4096 - len, /* remaining size of buf */ + name, /* name of entry */ + &stbuf, /* file attributes */ + b->bytes_in_buf + len /* offset of next entry */ + ); + + b->bytes_in_buf += len; + return 0; +} + /** * *****************************************************************************/ static void xfuse_cb_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, struct fuse_file_info *fi) +{ + XRDP_INODE *xinode; + XFUSE_INFO *fip; + tui32 device_id; + char full_path[4096]; + char *cptr; + + log_debug("req=%p inode=%d size=%d offset=%d", req, ino, size, off); + + if (!xfuse_is_inode_valid(ino)) + { + log_error("inode %d is not valid", ino); + fuse_reply_err(req, EBADF); + return; + } + + xinode = g_xrdp_fs.inode_table[ino]; + if (xinode->device_id == 0) + { + /* enumerate local resources */ + xfuse_enum_dir(req, ino, size, off, fi); + return; + } + + /* enumerate resources on a remote device */ + +// lK_TODO +#if 0 +{ + struct dirbuf b; + + memset(&b, 0, sizeof(struct dirbuf)); + xfuse_dirbuf_add(req, &b, ".", 1); + xfuse_dirbuf_add(req, &b, "..", 1); + xfuse_dirbuf_add(req, &b, "f2", 2); + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, b.size)); + else + fuse_reply_buf(req, NULL, 0); + + xfuse_dirbuf_add(req, &b, "f3", 3); + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, b.size)); + else + fuse_reply_buf(req, NULL, 0); + + xfuse_dirbuf_add(req, &b, "f4", 4); + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, b.size)); + else + fuse_reply_buf(req, NULL, 0); + + xfuse_dirbuf_add(req, &b, "f5", 5); + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, b.size)); + else + fuse_reply_buf(req, NULL, 0); + + xfuse_dirbuf_add(req, &b, "f6", 6); + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, b.size)); + else + fuse_reply_buf(req, NULL, 0); + + xfuse_dirbuf_add(req, &b, "f7", 7); + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, b.size)); + else + fuse_reply_buf(req, NULL, 0); + + xfuse_dirbuf_add(req, &b, "f8", 8); + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, b.size)); + else + fuse_reply_buf(req, NULL, 0); + + xfuse_dirbuf_add(req, &b, "f9", 9); + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, b.size)); + else + fuse_reply_buf(req, NULL, 0); + + xfuse_dirbuf_add(req, &b, "f10", 10); + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, b.size)); + else + fuse_reply_buf(req, NULL, 0); + + xfuse_dirbuf_add(req, &b, "f11", 11); + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, b.size)); + else + fuse_reply_buf(req, NULL, 0); + + xfuse_dirbuf_add(req, &b, "f12", 12); + if (off < b.size) + fuse_reply_buf(req, b.p + off, min(b.size - off, b.size)); + else + fuse_reply_buf(req, NULL, 0); + + fuse_reply_buf(req, NULL, 0); + return; +} +#endif + +#ifdef USE_SYNC_FLAG + if (xinode->is_synced) + { + xfuse_enum_dir(req, ino, size, off, fi); + return; + } + else + { + goto do_remote_lookup; + } +#endif + +do_remote_lookup: + + log_debug("did not find entry; redirecting call to dev_redir"); + device_id = xfuse_get_device_id_for_inode((tui32) ino, full_path); + log_debug("dev_id=%d ino=%d full_path=%s", device_id, ino, full_path); + + if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL) + { + log_error("system out of memory"); + fuse_reply_err(req, ENOMEM); + return; + } + + fip->req = req; + fip->inode = ino; + fip->size = size; + fip->off = off; + fip->fi = fi; + fip->dirbuf1.first_time = 1; + fip->dirbuf1.bytes_in_buf = 0; + + fip->invoke_fuse = 1; + fip->device_id = device_id; + + /* we want path minus 'root node of the share' */ + if ((cptr = strchr(full_path, '/')) == NULL) + { + /* enumerate root dir */ + if (dev_redir_get_dir_listing((void *) fip, device_id, "\\")) + { + log_error("failed to send dev_redir_get_dir_listing() cmd"); + fuse_reply_buf(req, NULL, 0); + } + } + else + { + if (dev_redir_get_dir_listing((void *) fip, device_id, cptr)) + { + log_error("failed to send dev_redir_get_dir_listing() cmd"); + fuse_reply_buf(req, NULL, 0); + } + } +} + + + + + + + +static void xfuse_cb_readdir_TODO(fuse_req_t req, fuse_ino_t ino, size_t size, + off_t off, struct fuse_file_info *fi) { struct xrdp_inode *xinode; struct dirbuf b; @@ -1785,6 +2352,9 @@ static void xfuse_cb_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, (void) fi; + /* SPEEDUP_TODO */ + printf("++++++ cb_readdir: looking for inode=%d\n", (int) ino); + log_debug("looking for dir with inode=%d", ino); if (!xfuse_is_inode_valid(ino)) @@ -1823,6 +2393,8 @@ static void xfuse_cb_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, fuse_reply_buf(req, NULL, 0); free(b.p); + + printf("++++++ cb_readdir: leaving\n"); } /** @@ -2132,7 +2704,7 @@ static void xfuse_create_dir_or_file(fuse_req_t req, fuse_ino_t parent, const char *name, mode_t mode, struct fuse_file_info *fi, int type) { - XFUSE_INFO *fip; // LK_TODO use only XFUSE_INFO instead of struct + XFUSE_INFO *fip; char *cptr; char full_path[1024]; tui32 device_id; diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index 37afad26..f09d7f07 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -381,7 +381,7 @@ int dev_redir_send_drive_create_request(tui32 device_id, char *path, int bytes; int len; - log_debug("LK_TODO: DesiredAccess=0x%x CreateDisposition=0x%x CreateOptions=0x%x", + log_debug("DesiredAccess=0x%x CreateDisposition=0x%x CreateOptions=0x%x", DesiredAccess, CreateDisposition, CreateOptions); /* to store path as unicode */ @@ -482,7 +482,11 @@ void dev_redir_send_drive_dir_request(IRP *irp, tui32 device_id, IRP_MJ_DIRECTORY_CONTROL, IRP_MN_QUERY_DIRECTORY); +#ifdef USE_SHORT_NAMES_IN_DIR_LISTING + stream_wr_u32_le(s, FileBothDirectoryInformation); /* FsInformationClass */ +#else stream_wr_u32_le(s, FileDirectoryInformation); /* FsInformationClass */ +#endif stream_wr_u8(s, InitialQuery); /* InitialQuery */ if (!InitialQuery) @@ -651,8 +655,7 @@ void dev_redir_proc_device_iocompletion(struct stream *s) /* LK_TODO need to check for IoStatus */ - log_debug("entered: IoStatus=0x%x CompletionId=%d", - IoStatus, CompletionId); + log_debug("entered: IoStatus=0x%x CompletionId=%d", IoStatus, CompletionId); if ((irp = dev_redir_irp_find(CompletionId)) == NULL) { @@ -682,6 +685,7 @@ void dev_redir_proc_device_iocompletion(struct stream *s) stream_rd_u32_le(s, irp->FileId); log_debug("got CID_CREATE_DIR_REQ IoStatus=0x%x FileId=%d", IoStatus, irp->FileId); + dev_redir_send_drive_dir_request(irp, DeviceId, 1, irp->pathname); break; @@ -788,6 +792,12 @@ void dev_redir_proc_query_dir_response(IRP *irp, tui32 FileNameLength; tui32 status; +#ifdef USE_SHORT_NAMES_IN_DIR_LISTING + tui32 EaSize; + tui8 ShortNameLength; + tui8 Reserved; +#endif + char filename[256]; int i = 0; @@ -828,18 +838,30 @@ void dev_redir_proc_query_dir_response(IRP *irp, stream_rd_u32_le(s_in, FileAttributes); stream_rd_u32_le(s_in, FileNameLength); +#ifdef USE_SHORT_NAMES_IN_DIR_LISTING + stream_rd_u32_le(s_in, EaSize); + stream_rd_u8(s_in, ShortNameLength); + stream_rd_u8(s_in, Reserved); + stream_seek(s_in, 23); /* ShortName in Unicode */ +#endif devredir_cvt_from_unicode_len(filename, s_in->p, FileNameLength); +#ifdef USE_SHORT_NAMES_IN_DIR_LISTING + i += 70 + 23 + FileNameLength; +#else i += 64 + FileNameLength; - - log_debug("NextEntryOffset: 0x%x", NextEntryOffset); - log_debug("CreationTime: 0x%llx", CreationTime); - log_debug("LastAccessTime: 0x%llx", LastAccessTime); - log_debug("LastWriteTime: 0x%llx", LastWriteTime); - log_debug("ChangeTime: 0x%llx", ChangeTime); - log_debug("EndOfFile: %lld", EndOfFile); - log_debug("FileAttributes: 0x%x", FileAttributes); - log_debug("FileNameLength: 0x%x", FileNameLength); +#endif + //log_debug("NextEntryOffset: 0x%x", NextEntryOffset); + //log_debug("CreationTime: 0x%llx", CreationTime); + //log_debug("LastAccessTime: 0x%llx", LastAccessTime); + //log_debug("LastWriteTime: 0x%llx", LastWriteTime); + //log_debug("ChangeTime: 0x%llx", ChangeTime); + //log_debug("EndOfFile: %lld", EndOfFile); + //log_debug("FileAttributes: 0x%x", FileAttributes); +#ifdef USE_SHORT_NAMES_IN_DIR_LISTING + //log_debug("ShortNameLength: %d", ShortNameLength); +#endif + //log_debug("FileNameLength: %d", FileNameLength); log_debug("FileName: %s", filename); if ((xinode = calloc(1, sizeof(struct xrdp_inode))) == NULL) @@ -886,6 +908,9 @@ int dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path) if ((irp = dev_redir_irp_new()) == NULL) return -1; + /* cvt / to windows compatible \ */ + devredir_cvt_slash(path); + irp->completion_id = g_completion_id++; irp->completion_type = CID_CREATE_DIR_REQ; irp->device_id = device_id; @@ -895,6 +920,7 @@ int dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path) DesiredAccess = DA_FILE_READ_DATA | DA_SYNCHRONIZE; CreateOptions = CO_FILE_DIRECTORY_FILE | CO_FILE_SYNCHRONOUS_IO_NONALERT; CreateDisposition = CD_FILE_OPEN; + rval = dev_redir_send_drive_create_request(device_id, path, DesiredAccess, CreateOptions, CreateDisposition, @@ -905,7 +931,6 @@ int dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path) /* when we get a respone to dev_redir_send_drive_create_request(), we */ /* call dev_redir_send_drive_dir_request(), which needs the following */ /* at the end of the path argument */ - if (dev_redir_string_ends_with(irp->pathname, '\\')) strcat(irp->pathname, "*"); else @@ -964,7 +989,7 @@ int dev_redir_file_open(void *fusep, tui32 device_id, char *path, } else //if (mode & O_RDWR) { - log_debug("LK_TODO: open file in O_RDWR"); + log_debug("open file in O_RDWR"); DesiredAccess = DA_FILE_READ_DATA | DA_FILE_WRITE_DATA | DA_SYNCHRONIZE; CreateOptions = CO_FILE_SYNCHRONOUS_IO_NONALERT; CreateDisposition = CD_FILE_OPEN; // WAS 1 @@ -972,7 +997,7 @@ int dev_redir_file_open(void *fusep, tui32 device_id, char *path, #if 0 else { - log_debug("LK_TODO: open file in O_RDONLY"); + log_debug("open file in O_RDONLY"); DesiredAccess = DA_FILE_READ_DATA | DA_SYNCHRONIZE; CreateOptions = CO_FILE_SYNCHRONOUS_IO_NONALERT; CreateDisposition = CD_FILE_OPEN; @@ -1408,6 +1433,22 @@ void dev_redir_insert_dev_io_req_header(struct stream *s, stream_wr_u32_le(s, MinorFunction); } +/** + * Convert / to windows compatible \ + *****************************************************************************/ + +void devredir_cvt_slash(char *path) +{ + char *cptr = path; + + while (*cptr != 0) + { + if (*cptr == '/') + *cptr = '\\'; + cptr++; + } +} + void devredir_cvt_to_unicode(char *unicode, char *path) { int len = strlen(path); diff --git a/sesman/chansrv/devredir.h b/sesman/chansrv/devredir.h index 231c2626..5bc85ede 100644 --- a/sesman/chansrv/devredir.h +++ b/sesman/chansrv/devredir.h @@ -37,6 +37,8 @@ #include "log.h" #include "chansrv_fuse.h" +#define USE_SHORT_NAMES_IN_DIR_LISTING + typedef struct fuse_data FUSE_DATA; struct fuse_data { @@ -123,6 +125,7 @@ void dev_redir_insert_dev_io_req_header(struct stream *s, tui32 MajorFunction, tui32 MinorFunction); +void devredir_cvt_slash(char *path); void devredir_cvt_to_unicode(char *unicode, char *path); void devredir_cvt_from_unicode_len(char *path, char *unicode, int len); int dev_redir_string_ends_with(char *string, char c); diff --git a/xrdp/xrdp.ini b/xrdp/xrdp.ini index f4c44666..fdf68bf6 100644 --- a/xrdp/xrdp.ini +++ b/xrdp/xrdp.ini @@ -61,7 +61,8 @@ lib=libxup.so username=ask password=ask ip=127.0.0.1 -port=-1 +port=/tmp/.xrdp/xrdp_display_10 +chansrvport=/tmp/.xrdp/xrdp_chansrv_socket_7210 xserverbpp=24 [xrdp2] From c5ebc9ae51b7a0c9a805ecd93055557d64341baf Mon Sep 17 00:00:00 2001 From: Laxmikant Rashinkar Date: Sat, 20 Apr 2013 18:44:11 -0700 Subject: [PATCH 23/23] a debug version of xrdp/xrdp.ini was previously commited --- xrdp/xrdp.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xrdp/xrdp.ini b/xrdp/xrdp.ini index fdf68bf6..f4c44666 100644 --- a/xrdp/xrdp.ini +++ b/xrdp/xrdp.ini @@ -61,8 +61,7 @@ lib=libxup.so username=ask password=ask ip=127.0.0.1 -port=/tmp/.xrdp/xrdp_display_10 -chansrvport=/tmp/.xrdp/xrdp_chansrv_socket_7210 +port=-1 xserverbpp=24 [xrdp2]