The branch, build-baikal has been updated via 1204142af2c8e7f6430136d50ff8f6b40fbc99f2 (commit) from 2042ae237c3f6ad906104eaee208fc98d75afd03 (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: debian/changelog | 6 ++++++ sql | 7 ++++++- x2godbadmin | 13 +++++++++---- x2godbwrapper.pm | 51 +++++++++++++++++++++++++++------------------------ 4 files changed, 48 insertions(+), 29 deletions(-) The diff of changes is: diff --git a/debian/changelog b/debian/changelog index bf3f606..6424e87 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +x2goserver (3.0.99-4) unstable; urgency=low + + * support for ssl connect (postgresql) + + -- Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de> Wed, 16 Mar 2011 11:16:21 +0100 + x2goserver (3.0.99-3) unstable; urgency=low * fixed wrong path to dbfile, thanks Moritz Struebe <Moritz.Struebe@informatik.uni-erlangen.de> diff --git a/sql b/sql index f3052d7..66a7f7d 100644 --- a/sql +++ b/sql @@ -6,4 +6,9 @@ host=localhost port=5432 #database admin (must have permissions to create databases and users) dbadmin=postgres - +#disable: SSL connections are never used +#allow: try non-SSL, then SSL +#prefer: try SSL, then non-SSL +#require: connect only with SSL +#default - prefer +ssl=prefer diff --git a/x2godbadmin b/x2godbadmin index 6a93e05..ccb1bdf 100755 --- a/x2godbadmin +++ b/x2godbadmin @@ -138,6 +138,11 @@ if($Config->param("backend") eq 'sqlite') my $host=$Config->param("postgres.host"); my $port=$Config->param("postgres.port"); + my $sslmode=$Config->param("postgres.ssl"); + if(!$sslmode) + { + $sslmode="prefer"; + } my $dbadmin=$Config->param("postgres.dbadmin"); my $x2goadmin="x2godbuser"; my $x2goadminpass=`makepasswd`; @@ -165,10 +170,10 @@ if($Config->param("backend") eq 'sqlite') my $dbh; if($createdb) { - $dbh=DBI->connect("dbi:Pg:;host=$host;port=$port;", "$dbadmin", "$dbadminpass",{AutoCommit => 1}) or die $_; + $dbh=DBI->connect("dbi:Pg:dbname=postgres;host=$host;port=$port;sslmode=$sslmode", "$dbadmin", "$dbadminpass",{AutoCommit => 1}) or die $_; create_database(); $dbh->disconnect(); - $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbadmin", "$dbadminpass",{AutoCommit => 1}) or die $_; + $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbadmin", "$dbadminpass",{AutoCommit => 1}) or die $_; create_tables(); $dbh->disconnect(); exit(0); @@ -176,13 +181,13 @@ if($Config->param("backend") eq 'sqlite') if($listusers) { - $dbh=DBI->connect("dbi:Pg:;host=$host;port=$port;", "$dbadmin", "$dbadminpass",{AutoCommit => 1}) or die $_; + $dbh=DBI->connect("dbi:Pg:dbname=postgres;host=$host;port=$port;sslmode=$sslmode", "$dbadmin", "$dbadminpass",{AutoCommit => 1}) or die $_; list_users(); $dbh->disconnect(); exit(0); } - $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbadmin", "$dbadminpass",{AutoCommit => 1}) or die $_; + $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbadmin", "$dbadminpass",{AutoCommit => 1}) or die $_; if($adduser) { add_user($adduser); diff --git a/x2godbwrapper.pm b/x2godbwrapper.pm index ebadcff..d433cad 100644 --- a/x2godbwrapper.pm +++ b/x2godbwrapper.pm @@ -6,9 +6,6 @@ use DBI; use POSIX; -use lib "/usr/lib/x2go"; -use x2godbwrapper; - my ($uname, $pass, $uid, $pgid, $quota, $comment, $gcos, $homedir, $shell, $expire) = getpwuid(getuid()); my $Config = new Config::Simple(syntax=>'ini'); @@ -20,7 +17,7 @@ my $port; my $db="x2go_sessions"; my $dbpass; my $dbuser; - +my $sslmode; if($backend ne 'postgres' && $backend ne 'sqlite') { @@ -50,7 +47,11 @@ if($backend eq 'postgres') $dbuser="x2gouser_$uname"; $passfile="$homedir/.x2go/sqlpass"; } - + $sslmode=$Config->param("postgres.ssl"); + if(!$sslmode) + { + $sslmode="prefer"; + } open (FL,"< $passfile") or die "Can't read password file $passfile<br><b>Use x2godbadmin on server to configure database access for user $uname</b><br>"; $dbpass=<FL>; close(FL); @@ -73,7 +74,8 @@ sub dbsys_rmsessionsroot my $sid=shift or die "argument \"session_id\" missed"; if($backend eq 'postgres') { - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", + "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("delete from sessions where session_id='$sid'"); $sth->execute()or die; @@ -90,7 +92,8 @@ sub dbsys_listsessionsroot if($backend eq 'postgres') { my @strings; - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", + "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("select agent_pid, session_id, display, server, status, to_char(init_time,'DD.MM.YY*HH24:MI:SS'),cookie,client,gr_port, @@ -119,7 +122,7 @@ sub dbsys_listsessionsroot_all if($backend eq 'postgres') { my @strings; - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("select agent_pid, session_id, display, server, status, to_char(init_time,'DD.MM.YY*HH24:MI:SS'),cookie,client,gr_port, @@ -150,7 +153,7 @@ sub dbsys_getmounts if($backend eq 'postgres') { my @strings; - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("select client, path from mounts where session_id='$sid'"); $sth->execute()or die; my @data; @@ -176,7 +179,7 @@ sub db_getmounts if($backend eq 'postgres') { my @strings; - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("select client, path from mounts_view where session_id='$sid'"); $sth->execute()or die; my @data; @@ -201,7 +204,7 @@ sub db_deletemount my $path=shift or die "argument \"path\" missed"; if($backend eq 'postgres') { - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("delete from mounts_view where session_id='$sid' and path='$path'"); $sth->execute(); $sth->finish(); @@ -222,7 +225,7 @@ sub db_insertmount my $res_ok=1; if($backend eq 'postgres') { - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + 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 mounts (session_id,path,client) values ('$sid','$path','$client')"); $sth->execute(); if(!$sth->err()) @@ -250,7 +253,7 @@ sub db_insertsession my $sid=shift or die "argument \"session_id\" missed"; if($backend eq 'postgres') { - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + 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','$uname','$sid')"); $sth->execute()or die $_; $sth->finish(); @@ -278,7 +281,7 @@ sub db_createsession my $sid=shift or die "argument \"session_id\" missed"; if($backend eq 'postgres') { - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("update sessions_view set status='R',last_time=now(), cookie='$cookie',agent_pid='$pid',client='$client',gr_port='$gr_port', sound_port='$snd_port',fs_port='$fs_port' where session_id='$sid'"); @@ -304,7 +307,7 @@ sub db_insertport my $sshport=shift or die "argument \"port\" missed"; if($backend eq 'postgres') { - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + 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 used_ports (server,session_id,port) values ('$server','$sid','$sshport')"); $sth->execute()or die; $sth->finish(); @@ -324,7 +327,7 @@ sub db_resume my $sid=shift or die "argument \"session_id\" missed"; if($backend eq 'postgres') { - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("update sessions_view set last_time=now(),status='R',client='$client' where session_id = '$sid'"); $sth->execute()or die; $sth->finish(); @@ -343,7 +346,7 @@ sub db_changestatus my $sid=shift or die "argument \"session_id\" missed"; if($backend eq 'postgres') { - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("update sessions_view set last_time=now(),status='$status' where session_id = '$sid'"); $sth->execute()or die; $sth->finish(); @@ -363,7 +366,7 @@ sub db_getdisplays if($backend eq 'postgres') { my @strings; - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("select display from servers_view"); $sth->execute()or die; my @data; @@ -390,7 +393,7 @@ sub db_getports if($backend eq 'postgres') { my @strings; - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("select port from ports_view"); $sth->execute()or die; my @data; @@ -415,7 +418,7 @@ sub db_getservers if($backend eq 'postgres') { my @strings; - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("select server,count(*) from servers_view where status != 'F' group by server"); $sth->execute()or die; @@ -442,7 +445,7 @@ sub db_getagent my $agent; if($backend eq 'postgres') { - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("select agent_pid from sessions_view where session_id ='$sid'"); @@ -469,7 +472,7 @@ sub db_getdisplay my $display; if($backend eq 'postgres') { - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("select display from sessions_view where session_id ='$sid'"); @@ -495,7 +498,7 @@ sub db_listsessions if($backend eq 'postgres') { my @strings; - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("select agent_pid, session_id, display, server, status, to_char(init_time,'DD.MM.YY*HH24:MI:SS'), cookie, client, gr_port, @@ -526,7 +529,7 @@ sub db_listsessions_all if($backend eq 'postgres') { my @strings; - my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; + my $dbh=DBI->connect("dbi:Pg:dbname=$db;host=$host;port=$port;sslmode=$sslmode", "$dbuser", "$dbpass",{AutoCommit => 1}) or die $_; my $sth=$dbh->prepare("select agent_pid, session_id, display, server, status, to_char(init_time,'DD.MM.YY*HH24:MI:SS'), cookie, client, gr_port, 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).