/usr/share/perl5/X2Go/Server/DB.pm is in libx2go-server-db-perl 4.1.0.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | # Copyright (C) 2007-2015 X2Go Project - http://wiki.x2go.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Copyright (C) 2007-2015 Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de>
# Copyright (C) 2007-2015 Heinz-Markus Graesing <heinz-m.graesing@obviously-nice.de>
package X2Go::Server::DB;
=head1 NAME
X2Go::Server::DB - X2Go Session Database package for Perl
=head1 DESCRIPTION
X2Go::Server::DB Perl package for X2Go::Server.
=cut
use strict;
use DBI;
use POSIX;
use Sys::Syslog qw( :standard :macros );
use X2Go::Config qw( get_sqlconfig );
use X2Go::Log qw( loglevel );
use X2Go::Server::DB::PostgreSQL;
use X2Go::Utils qw( system_capture_merged_output system_capture_stdout_output );
setlogmask( LOG_UPTO(loglevel()) );
my ($uname, $pass, $uid, $pgid, $quota, $comment, $gcos, $homedir, $shell, $expire) = getpwuid(getuid());
my $Config = get_sqlconfig();
my $x2go_lib_path=system_capture_stdout_output("x2gopath", "libexec");
my $backend=$Config->param("backend");
my $host;
my $port;
my $db="x2go_sessions";
my $dbpass;
my $dbuser;
my $sslmode;
if ($backend ne 'postgres' && $backend ne 'sqlite')
{
die "unknown backend $backend";
}
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_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');
sub dbsys_rmsessionsroot
{
my $sid=shift or die "argument \"session_id\" missed";
dbsys_deletemounts($sid);
if($backend eq 'postgres')
{
X2Go::Server::DB::PostgreSQL::dbsys_rmsessionsroot($sid);
}
if($backend eq 'sqlite')
{
system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "rmsessionsroot", "$sid");
}
}
sub dbsys_deletemounts
{
my $sid=shift or die "argument \"session_id\" missed";
if ($backend eq 'postgres')
{
X2Go::Server::DB::PostgreSQL::dbsys_deletemounts($sid);
}
if ($backend eq 'sqlite')
{
system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "deletemounts", "$sid");
}
syslog('debug', "dbsys_deletemounts called, session ID: $sid");
}
sub dbsys_listsessionsroot
{
my $server=shift or die "argument \"server\" missed";
if ($backend eq 'postgres')
{
return X2Go::Server::DB::PostgreSQL::dbsys_listsessionsroot($server);
}
if($backend eq 'sqlite')
{
return split("\n",system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "listsessionsroot", "$server"));
}
}
sub dbsys_listsessionsroot_all
{
if ($backend eq 'postgres')
{
return X2Go::Server::DB::PostgreSQL::dbsys_listsessionsroot_all();
}
if ($backend eq 'sqlite')
{
return split("\n",system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "listsessionsroot_all"));
}
}
sub dbsys_getmounts
{
my @mounts;
my $sid=shift or die "argument \"session_id\" missed";
if ($backend eq 'postgres')
{
@mounts = X2Go::Server::DB::PostgreSQL::dbsys_getmounts($sid);
}
if ($backend eq 'sqlite')
{
@mounts = split("\n",system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "getmounts", "$sid"));
}
my $log_retval = join(" ", @mounts);
syslog('debug', "dbsys_getmounts called, session ID: $sid; return value: $log_retval");
return @mounts;
}
sub db_getmounts
{
my @mounts;
my $sid=shift or die "argument \"session_id\" missed";
if($backend eq 'postgres')
{
@mounts = X2Go::Server::DB::PostgreSQL::db_getmounts($sid);
}
if ($backend eq 'sqlite')
{
@mounts = split("\n",system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "getmounts", "$sid"));
}
my $log_retval = join(" ", @mounts);
syslog('debug', "db_getmounts called, session ID: $sid; return value: $log_retval");
return @mounts;
}
sub db_deletemount
{
my $sid=shift or die "argument \"session_id\" missed";
my $path=shift or die "argument \"path\" missed";
if ($backend eq 'postgres')
{
X2Go::Server::DB::PostgreSQL::db_deletemount($sid, $path);
}
if ($backend eq 'sqlite')
{
system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "deletemount", "$sid", "$path");
}
syslog('debug', "db_deletemount called, session ID: $sid, path: $path");
}
sub db_insertmount
{
my $sid=shift or die "argument \"session_id\" missed";
my $path=shift or die "argument \"path\" missed";
my $client=shift or die "argument \"client\" missed";
my $res_ok=0;
if ($backend eq 'postgres')
{
$res_ok = X2Go::Server::DB::PostgreSQL::db_insertmount($sid, $path, $client);
}
if ($backend eq 'sqlite')
{
if( system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "insertmount", "$sid", "$path", "$client") eq "ok")
{
$res_ok=1;
}
}
syslog('debug', "db_insertmount called, session ID: $sid, path: $path, client: $client; return value: $res_ok");
return $res_ok;
}
sub db_insertsession
{
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";
if ($backend eq 'postgres')
{
X2Go::Server::DB::PostgreSQL::db_insertsession($display, $server, $sid);
}
if ($backend eq 'sqlite')
{
my $err=system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "insertsession", "$display", "$server", "$sid");
if ($err ne "ok")
{
die "$err: $x2go_lib_path/libx2go-server-db-sqlite3-wrapper insertsession $display $server $sid";
}
}
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=system_capture_merged_output("$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 $sid=shift or die "argument \"session_id\" missed";
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 $tekictrl_port=shift or die"argument \"tekictrl_port\" missed";
my $tekidata_port=shift or die"argument \"tekidata_port\" missed";
if ($backend eq 'postgres')
{
X2Go::Server::DB::PostgreSQL::db_createsession($sid, $cookie, $pid, $client, $gr_port, $snd_port, $fs_port, $tekictrl_port, $tekidata_port);
}
if ($backend eq 'sqlite')
{
my $err= system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "createsession", "$sid", "$cookie", "$pid", "$client", "$gr_port", "$snd_port", "$fs_port", "$tekictrl_port", "$tekidata_port");
if ($err ne "ok")
{
die $err;
}
}
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. telekinesis ctrl port: $tekictrl_port, telekinesis data port: $tekidata_port");
}
sub db_createshadowsession
{
my $sid=shift or die "argument \"session_id\" missed";
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 $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($sid, $cookie, $pid, $client, $gr_port, $snd_port, $fs_port, -1, -1);
}
if ($backend eq 'sqlite')
{
my $err=system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "createshadowsession", "$sid", "$cookie", "$pid", "$client", "$gr_port", "$snd_port", "$fs_port", "$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";
my $sid=shift or die "argument \"session_id\" missed";
my $sshport=shift or die "argument \"port\" missed";
if ($backend eq 'postgres')
{
X2Go::Server::DB::PostgreSQL::db_insertport($server, $sid, $sshport);
}
if ($backend eq 'sqlite')
{
my $err=system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "insertport", "$server", "$sid", "$sshport");
if ($err ne "ok")
{
die $err;
}
}
syslog('debug', "db_insertport called, session ID: $sid, server: $server, SSH port: $sshport");
}
sub db_rmport
{
my $server=shift or die "argument \"server\" missed";
my $sid=shift or die "argument \"session_id\" missed";
my $sshport=shift or die "argument \"port\" missed";
if ($backend eq 'postgres')
{
X2Go::Server::DB::PostgreSQL::db_rmport($server, $sid, $sshport);
}
if ($backend eq 'sqlite')
{
system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "rmport", "$server", "$sid", "$sshport");
}
syslog('debug', "db_rmport called, session ID: $sid, server: $server, SSH port: $sshport");
}
sub db_resume
{
my $client=shift or die "argument \"client\" missed";
my $sid=shift or die "argument \"session_id\" 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 $tekictrl_port=shift or die"argument \"tekictrl_port\" missed";
my $tekidata_port=shift or die"argument \"tekidata_port\" missed";
if ($backend eq 'postgres')
{
X2Go::Server::DB::PostgreSQL::db_resume($client, $sid, $gr_port, $snd_port, $fs_port, $tekictrl_port, $tekidata_port);
}
if ($backend eq 'sqlite')
{
system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "resume", "$client", "$sid", "$gr_port", "$snd_port", "$fs_port", "$tekictrl_port", "$tekidata_port");
}
syslog('debug', "db_resume called, session ID: $sid, client: $client, gr_port: $gr_port, sound_port: $snd_port, fs_port: $fs_port, telekinesis ctrl port: $tekictrl_port, telekinesis data port: $tekidata_port");
}
sub db_changestatus
{
my $status=shift or die "argument \"status\" missed";
my $sid=shift or die "argument \"session_id\" missed";
if ($backend eq 'postgres')
{
X2Go::Server::DB::PostgreSQL::db_changestatus($status, $sid);
}
if ($backend eq 'sqlite')
{
system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "changestatus", "$status", "$sid");
}
syslog('debug', "db_changestatus called, session ID: $sid, new status: $status");
}
sub db_getstatus
{
my $sid=shift or die "argument \"session_id\" missed";
my $status='';
if ($backend eq 'postgres')
{
$status = X2Go::Server::DB::PostgreSQL::db_getstatus($sid);
}
if ($backend eq 'sqlite')
{
$status=system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "getstatus", "$sid");
}
syslog('debug', "db_getstatus called, session ID: $sid, return value: $status");
return $status;
}
sub db_getdisplays
{
my @displays;
#ignore $server
my $server=shift or die "argument \"server\" missed";
if ($backend eq 'postgres')
{
@displays = X2Go::Server::DB::PostgreSQL::db_getdisplays($server);
}
if ($backend eq 'sqlite')
{
@displays = split("\n",system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "getdisplays", "$server"));
}
my $log_retval = join(" ", @displays);
syslog('debug', "db_getdisplays called, server: $server; return value: $log_retval");
return @displays;
}
sub db_getports
{
my @ports;
#ignore $server
my $server=shift or die "argument \"server\" missed";
if ($backend eq 'postgres')
{
@ports = X2Go::Server::DB::PostgreSQL::db_getports($server);
}
if ($backend eq 'sqlite')
{
@ports = split("\n",system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "getports", "$server"));
}
my $log_retval = join(" ", @ports);
syslog('debug', "db_getports called, server: $server; return value: $log_retval");
return @ports;
}
sub db_getservers
{
my @servers;
if ($backend eq 'postgres')
{
@servers = X2Go::Server::DB::PostgreSQL::db_getservers();
}
if ($backend eq 'sqlite')
{
@servers = split("\n",system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "getservers"));
}
my $log_retval = join(" ", @servers);
syslog('debug', "db_getservers called, return value: $log_retval");
return @servers;
}
sub db_getagent
{
my $agent;
my $sid=shift or die "argument \"session_id\" missed";
if ($backend eq 'postgres')
{
$agent = X2Go::Server::DB::PostgreSQL::db_getagent($sid);
}
if($backend eq 'sqlite')
{
$agent=system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "getagent", "$sid");
}
syslog('debug', "db_getagent called, session ID: $sid; return value: $agent");
return $agent;
}
sub db_getdisplay
{
my $display;
my $sid=shift or die "argument \"session_id\" missed";
if ($backend eq 'postgres')
{
$display = X2Go::Server::DB::PostgreSQL::db_getdisplay($sid);
}
if ($backend eq 'sqlite')
{
$display=system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "getdisplay", "$sid");
}
syslog('debug', "db_getdisplay called, session ID: $sid; return value: $display");
return $display;
}
sub db_listsessions
{
my $server=shift or die "argument \"server\" missed";
if ($backend eq 'postgres')
{
return X2Go::Server::DB::PostgreSQL::db_listsessions($server);
}
if ($backend eq 'sqlite')
{
return split("\n",system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "listsessions", "$server"));
}
}
sub db_listsessions_all
{
if($backend eq 'postgres')
{
return X2Go::Server::DB::PostgreSQL::db_listsessions_all();
}
if ($backend eq 'sqlite')
{
return split("\n",system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "listsessions_all"));
}
}
sub db_listshadowsessions
{
my $server=shift or die "argument \"server\" missed";
if ($backend eq 'postgres')
{
return X2Go::Server::DB::PostgreSQL::db_listshadowsessions($server);
}
if ($backend eq 'sqlite')
{
return split("\n",system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "listshadowsessions", "$server"));
}
}
sub db_listshadowsessions_all
{
if($backend eq 'postgres')
{
return X2Go::Server::DB::PostgreSQL::db_listshadowsessions_all();
}
if ($backend eq 'sqlite')
{
return split("\n",system_capture_merged_output("$x2go_lib_path/libx2go-server-db-sqlite3-wrapper", "listshadowsessions_all"));
}
}
|