The branch, build-baikal has been updated via 40c674c9e82c6217c5422aae2d86974c5949b716 (commit) from da7cc13e30fb9773b0c2ab8706e5ceadb55feec8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: X2Go/Server/DB.pm | 49 +++++++++++++++++++- X2Go/Server/DB/PostgreSQL.pm | 16 ++++++- X2Go/Server/DB/SQLite3.pm | 47 ++++++++++++++++++- debian/changelog | 4 ++ x2goserver/bin/x2gostartagent | 21 +++++++-- .../{x2gocreatesession => x2gocreateshadowsession} | 5 +- .../{x2goinsertsession => x2goinsertshadowsession} | 5 +- 7 files changed, 137 insertions(+), 10 deletions(-) copy x2goserver/lib/{x2gocreatesession => x2gocreateshadowsession} (87%) copy x2goserver/lib/{x2goinsertsession => x2goinsertshadowsession} (88%) The diff of changes is: diff --git a/X2Go/Server/DB.pm b/X2Go/Server/DB.pm index 0f638a2..2ce7a02 100644 --- a/X2Go/Server/DB.pm +++ b/X2Go/Server/DB.pm @@ -63,7 +63,7 @@ if ($backend ne 'postgres' && $backend ne 'sqlite') use base 'Exporter'; our @EXPORT=('db_listsessions','db_listsessions_all', 'db_getservers', 'db_getagent', 'db_resume', 'db_changestatus', 'db_getstatus', - 'db_getdisplays', 'db_insertsession', 'db_getports', 'db_insertport', 'db_rmport', 'db_createsession', 'db_insertmount', + 'db_getdisplays', 'db_insertsession', 'db_insertshadowsession', 'db_getports', 'db_insertport', 'db_rmport', 'db_createsession', 'db_createshadowsession', 'db_insertmount', 'db_getmounts', 'db_deletemount', 'db_getdisplay', 'dbsys_getmounts', 'dbsys_listsessionsroot', 'dbsys_listsessionsroot_all', 'dbsys_rmsessionsroot', 'dbsys_deletemounts', 'db_listshadowsessions','db_listshadowsessions_all'); @@ -210,6 +210,27 @@ sub db_insertsession syslog('debug', "db_insertsession called, session ID: $sid, server: $server, session ID: $sid"); } +sub db_insertshadowsession +{ + my $display=shift or die "argument \"display\" missed"; + my $server=shift or die "argument \"server\" missed"; + my $sid=shift or die "argument \"session_id\" missed"; + my $shadreq_user=shift or die "argument \"shadreq_user\" missed"; + if ($backend eq 'postgres') + { + X2Go::Server::DB::PostgreSQL::db_insertshadowsession($display, $server, $sid, $shadreq_user); + } + if ($backend eq 'sqlite') + { + my $err=`$x2go_lib_path/libx2go-server-db-sqlite3-wrapper insertshadowsession $display $server $sid $shadreq_user`; + if ($err ne "ok") + { + die "$err: $x2go_lib_path/libx2go-server-db-sqlite3-wrapper insertshadowsession $display $server $sid $shadreq_user"; + } + } + syslog('debug', "db_insertshadowsession called, session ID: $sid, server: $server, session ID: $sid, shadowing requesting user: $shadreq_user"); +} + sub db_createsession { my $cookie=shift or die"argument \"cookie\" missed"; @@ -234,6 +255,32 @@ sub db_createsession syslog('debug', "db_createsession called, session ID: $sid, cookie: $cookie, client: $client, pid: $pid, graphics port: $gr_port, sound port: $snd_port, file sharing port: $fs_port"); } +sub db_createshadowsession +{ + my $cookie=shift or die"argument \"cookie\" missed"; + my $pid=shift or die"argument \"pid\" missed"; + my $client=shift or die"argument \"client\" missed"; + my $gr_port=shift or die"argument \"gr_port\" missed"; + my $snd_port=shift or die"argument \"snd_port\" missed"; + my $fs_port=shift or die"argument \"fs_port\" missed"; + my $sid=shift or die "argument \"session_id\" missed"; + my $shadreq_user=shift or die "argument \"shadreq_user\" missed"; + if ($backend eq 'postgres') + { + # for PostgreSQL we can use the normal db_createsession code... + X2Go::Server::DB::PostgreSQL::db_createsession($cookie, $pid, $client, $gr_port, $snd_port, $fs_port, $sid); + } + if ($backend eq 'sqlite') + { + my $err= `$x2go_lib_path/libx2go-server-db-sqlite3-wrapper createshadowsession $cookie $pid $client $gr_port $snd_port $fs_port $sid $shadreq_user`; + if ($err ne "ok") + { + die $err; + } + } + syslog('debug', "db_createshadowsession called, session ID: $sid, cookie: $cookie, client: $client, pid: $pid, graphics port: $gr_port, sound port: $snd_port, file sharing port: $fs_port, shadowing requesting user: $shadreq_user"); +} + sub db_insertport { my $server=shift or die "argument \"server\" missed"; diff --git a/X2Go/Server/DB/PostgreSQL.pm b/X2Go/Server/DB/PostgreSQL.pm index 1bad04a..f101de8 100644 --- a/X2Go/Server/DB/PostgreSQL.pm +++ b/X2Go/Server/DB/PostgreSQL.pm @@ -43,7 +43,7 @@ setlogmask( LOG_UPTO(loglevel()) ); use base 'Exporter'; our @EXPORT=('db_listsessions','db_listsessions_all', 'db_getservers', 'db_getagent', 'db_resume', 'db_changestatus', 'db_getstatus', - 'db_getdisplays', 'db_insertsession', 'db_getports', 'db_insertport', 'db_rmport', 'db_createsession', 'db_insertmount', + 'db_getdisplays', 'db_insertsession', 'db_insertshadowsession', 'db_getports', 'db_insertport', 'db_rmport', 'db_createsession', 'db_insertmount', 'db_getmounts', 'db_deletemount', 'db_getdisplay', 'dbsys_getmounts', 'dbsys_listsessionsroot', 'dbsys_listsessionsroot_all', 'dbsys_rmsessionsroot', 'dbsys_deletemounts', 'db_listshadowsessions','db_listshadowsessions_all'); @@ -256,6 +256,20 @@ sub db_insertsession $dbh->disconnect(); } +sub db_insertshadowsession +{ + init_db(); + my $display=shift or die "argument \"display\" missed"; + my $server=shift or die "argument \"server\" missed"; + my $sid=shift or die "argument \"session_id\" missed"; + my $shadreq_user=shift or die "argument \"shadreq_user\" missed"; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $sth=$dbh->prepare("insert into sessions (display,server,uname,session_id) values ('$display','$server','$shadreq_user','$sid')"); + $sth->execute()or die $_; + $sth->finish(); + $dbh->disconnect(); +} + sub db_createsession { init_db(); diff --git a/X2Go/Server/DB/SQLite3.pm b/X2Go/Server/DB/SQLite3.pm index 21741b8..9a0ce2a 100644 --- a/X2Go/Server/DB/SQLite3.pm +++ b/X2Go/Server/DB/SQLite3.pm @@ -52,7 +52,7 @@ my $realuser=$uname; use base 'Exporter'; our @EXPORT=('db_listsessions','db_listsessions_all', 'db_getservers', 'db_getagent', 'db_resume', 'db_changestatus', 'db_getstatus', - 'db_getdisplays', 'db_insertsession', 'db_getports', 'db_insertport', 'db_rmport', 'db_createsession', 'db_insertmount', + 'db_getdisplays', 'db_insertsession', 'db_insertshadowsession', 'db_getports', 'db_insertport', 'db_rmport', 'db_createsession', 'db_createshadowsession', 'db_insertmount', 'db_getmounts', 'db_deletemount', 'db_getdisplay', 'dbsys_getmounts', 'dbsys_listsessionsroot', 'dbsys_listsessionsroot_all', 'dbsys_rmsessionsroot', 'dbsys_deletemounts', 'db_listshadowsessions','db_listshadowsessions_all', ); @@ -219,6 +219,24 @@ sub db_insertsession return 1; } +sub db_insertshadowsession +{ + my $dbh = init_db(); + my $display=shift or die "argument \"display\" missed"; + my $server=shift or die "argument \"server\" missed"; + my $sid=shift or die "argument \"session_id\" missed"; + my $shadreq_user = shift or die "argument \"shadreq_user\" missed"; + my $fake_sid = $sid; + $fake_sid =~ s/$shadreq_user-/$realuser-/; + check_user($fake_sid); + my $sth=$dbh->prepare("insert into sessions (display,server,uname,session_id, init_time, last_time) values + (?, ?, ?, ?, datetime('now','localtime'), datetime('now','localtime'))"); + $sth->execute($display, $server, $shadreq_user, $sid) or die $_; + $sth->finish(); + $dbh->disconnect(); + return 1; +} + sub db_createsession { my $dbh = init_db(); @@ -243,6 +261,33 @@ sub db_createsession return 1; } +sub db_createshadowsession +{ + my $dbh = init_db(); + my $cookie=shift or die"argument \"cookie\" missed"; + my $pid=shift or die"argument \"pid\" missed"; + my $client=shift or die"argument \"client\" missed"; + my $gr_port=shift or die"argument \"gr_port\" missed"; + my $snd_port=shift or die"argument \"snd_port\" missed"; + my $fs_port=shift or die"argument \"fs_port\" missed"; + my $sid=shift or die "argument \"session_id\" missed"; + my $shadreq_user = shift or die "argument \"shadreq_user\" missed"; + my $fake_sid = $sid; + $fake_sid =~ s/^$shadreq_user-/$realuser-/; + check_user($fake_sid); + my $sth=$dbh->prepare("update sessions set status='R',last_time=datetime('now','localtime'),cookie=?,agent_pid=?, + client=?,gr_port=?,sound_port=?,fs_port=? where session_id=? and uname=?"); + $sth->execute($cookie, $pid, $client, $gr_port, $snd_port, $fs_port, $sid, $shadreq_user); + if ($sth->err()) + { + syslog('error', "createshadowsession (SQLite3 session db backend) failed with exitcode: $sth->err()"); + die(); + } + $sth->finish(); + $dbh->disconnect(); + return 1; +} + sub db_insertport { my $dbh = init_db(); diff --git a/debian/changelog b/debian/changelog index 989bb45..9cc828d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,10 @@ x2goserver (4.1.0.0-0~x2go1) UNRELEASED; urgency=low - Fix build-arch target in x2goserver/Makefile. (Fixes: #121). - Load config files from a Perl package (X2Go::Config). - Disable SupeReNicer by default. + - Fix session handling for cross-user-account desktop sharing. Now session + names of desktop sharing session start with the username of the user who + is requesting the desktop sharing, rather than the username of the person + who shares his/her desktop. * /debian/control: + Package X2Go::Log in separate package: libx2go-log-perl. + Package X2Go::Server::DB in separate package: libx2go-server-db-perl. diff --git a/x2goserver/bin/x2gostartagent b/x2goserver/bin/x2gostartagent index bc399c2..7b94862 100755 --- a/x2goserver/bin/x2gostartagent +++ b/x2goserver/bin/x2gostartagent @@ -89,6 +89,7 @@ if [ "$X2GO_STYPE" == "S" ]; then $X2GO_LIB_PATH/x2gosyslog "$0" "notice" "user ,,$USER'' requests desktop sharing from user ,,$SHADOW_USER'' for desktop ,,$SHADOW_DESKTOP''" $X2GO_LIB_PATH/x2gosyslog "$0" "debug" "executing command: x2godesktopsharing client $X2GO_CLIENT $X2GO_GEOMETRY $X2GO_LINK $X2GO_PACK $X2GO_TYPE $X2GO_KBD_LAYOUT $X2GO_KBD_TYPE $X2GO_SET_KBD $X2GO_STYPE $X2GO_CMD $USER" OUTPUT=`x2godesktopsharing client "$X2GO_CLIENT" "$X2GO_GEOMETRY" "$X2GO_LINK" "$X2GO_PACK" "$X2GO_TYPE" "$X2GO_KBD_LAYOUT" "$X2GO_KBD_TYPE" "$X2GO_SET_KBD" "$X2GO_STYPE" "$X2GO_CMD" "$USER"` + OUTPUT=`echo $OUTPUT | sed -e 's/#012/ /g'` $X2GO_LIB_PATH/x2gosyslog "$0" "debug" "command result is: $OUTPUT" if [ "$OUTPUT" == "DENY" ]; then echo "ACCESS DENIED" 1>&2 @@ -165,12 +166,22 @@ while [ "$OUTPUT" != "inserted" ]; do grep -q "|${NX_PORT}|" <<<$USED_PORTS ; then OUTPUT="XXX" else - SESSION_NAME="${USER}-${X2GO_PORT}-`date +\"%s\"`" + if [ -n "$SHADREQ_USER" ]; then + SESSION_NAME="${SHADREQ_USER}-${X2GO_PORT}-`date +\"%s\"`" + else + SESSION_NAME="${USER}-${X2GO_PORT}-`date +\"%s\"`" + fi if [ "$COLORDEPTH" != "" ]; then SESSION_NAME="${SESSION_NAME}_st${SESSION_TYPE}${X2GO_CMD}_dp${COLORDEPTH}" SESSION_NAME=`echo "$SESSION_NAME" | sed -e "s/:/PP/g"` fi - OUTPUT=`$X2GO_LIB_PATH/x2goinsertsession "$X2GO_PORT" "$HOSTNAME" "$SESSION_NAME"` + if [ -n "$SHADREQ_USER" ]; then + $X2GO_LIB_PATH/x2gosyslog "$0" "debug" "initializing new shadow session with ID $SESSION_NAME" + OUTPUT=`$X2GO_LIB_PATH/x2goinsertshadowsession "$X2GO_PORT" "$HOSTNAME" "$SESSION_NAME" "$SHADREQ_USER"` + else + $X2GO_LIB_PATH/x2gosyslog "$0" "debug" "initializing new session with ID $SESSION_NAME" + OUTPUT=`$X2GO_LIB_PATH/x2goinsertsession "$X2GO_PORT" "$HOSTNAME" "$SESSION_NAME"` + fi fi done @@ -317,7 +328,11 @@ test $X2GO_AGENT_RETVAL && { X2GO_SND_PORT=1024 -$X2GO_LIB_PATH/x2gocreatesession "$X2GO_COOKIE" "$X2GO_AGENT_PID" "$X2GO_CLIENT" "$GR_PORT" "$SOUND_PORT" "$FS_PORT" "$SESSION_NAME" > /dev/null +if [ -n "$SHADREQ_USER" ]; then + $X2GO_LIB_PATH/x2gocreateshadowsession "$X2GO_COOKIE" "$X2GO_AGENT_PID" "$X2GO_CLIENT" "$GR_PORT" "$SOUND_PORT" "$FS_PORT" "$SESSION_NAME" "$SHADREQ_USER" > /dev/null +else + $X2GO_LIB_PATH/x2gocreatesession "$X2GO_COOKIE" "$X2GO_AGENT_PID" "$X2GO_CLIENT" "$GR_PORT" "$SOUND_PORT" "$FS_PORT" "$SESSION_NAME" > /dev/null# +fi if [ "$X2GO_SET_KBD" == "0" ] || [ "$X2GO_KBD_TYPE" != "auto" ]; then $X2GO_LIB_PATH/x2gosyslog "$0" "info" "blocking creation of agent's keyboard file ${SESSION_DIR}/keyboard as requested by session startup command" diff --git a/x2goserver/lib/x2gocreatesession b/x2goserver/lib/x2gocreateshadowsession similarity index 87% copy from x2goserver/lib/x2gocreatesession copy to x2goserver/lib/x2gocreateshadowsession index 27d3d2d..7149b81 100755 --- a/x2goserver/lib/x2gocreatesession +++ b/x2goserver/lib/x2gocreateshadowsession @@ -23,7 +23,7 @@ use strict; use Sys::Syslog qw( :standard :macros ); -use X2Go::Server::DB qw(db_createsession); +use X2Go::Server::DB qw(db_createshadowsession); use X2Go::Log qw(loglevel); openlog($0,'cons,pid','user'); @@ -37,8 +37,9 @@ my $gr_port=shift or die; my $snd_port=shift or die; my $fs_port=shift or die; my $sid=shift or die; +my $shadreq_user=shift or die; -db_createsession($cookie,$pid,$client,$gr_port, $snd_port, $fs_port, $sid); +db_createshadowsession($cookie,$pid,$client,$gr_port, $snd_port, $fs_port, $sid, $shadreq_user); # closing syslog closelog; \ No newline at end of file diff --git a/x2goserver/lib/x2goinsertsession b/x2goserver/lib/x2goinsertshadowsession similarity index 88% copy from x2goserver/lib/x2goinsertsession copy to x2goserver/lib/x2goinsertshadowsession index 94deece..44cc336 100755 --- a/x2goserver/lib/x2goinsertsession +++ b/x2goserver/lib/x2goinsertshadowsession @@ -23,7 +23,7 @@ use strict; use Sys::Syslog qw( :standard :macros ); -use X2Go::Server::DB qw(db_insertsession); +use X2Go::Server::DB qw(db_insertshadowsession); use X2Go::Log qw(loglevel); openlog($0,'cons,pid','user'); @@ -33,8 +33,9 @@ setlogmask( LOG_UPTO(loglevel()) ); my $display=shift or die; my $server=shift or die; my $sid=shift or die; +my $shadreq_user=shift or die; -db_insertsession($display, $server, $sid); +db_insertshadowsession($display, $server, $sid, $shadreq_user); print "inserted"; # closing syslog hooks/post-receive -- x2goserver.git (X2Go Server) This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "x2goserver.git" (X2Go Server).