]>
git.proxmox.com Git - pve-manager-legacy.git/blob - bin/spiceproxy
3 # Note: In theory, all this can be done by 'pveproxy' daemon. But som API call
4 # still have blocking code, so we use a separate daemon to avoid that the console
7 $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
9 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
17 my $pidfile = "/var/run/pveproxy/spiceproxy.pid";
18 my $lockfile = "/var/lock/spiceproxy.lck";
22 initlog
('spiceproxy');
24 if (!GetOptions
('debug' => \
$opt_debug)) {
25 die "usage: $0 [--debug]\n";
28 $SIG{'__WARN__'} = sub {
32 syslog
('warning', "WARNING: %s", $t);
38 my $gid = getgrnam('www-data') || die "getgrnam failed - $!\n";
39 POSIX
::setgid
($gid) || die "setgid $gid failed - $!\n";
40 $EGID = "$gid $gid"; # this calls setgroups
41 my $uid = getpwnam('www-data') || die "getpwnam failed - $!\n";
42 POSIX
::setuid
($uid) || die "setuid $uid failed - $!\n";
45 die "detected strange uid/gid\n" if !($UID == $uid && $EUID == $uid && $GID eq "$gid $gid" && $EGID eq "$gid $gid");
50 $daemon = PVE
::APIDaemon-
>new(
53 max_workers
=> 1, # do we need more?
55 lockfile
=> $lockfile,
58 logfile
=> '/var/log/pveproxy/access.log',
65 syslog
('err' , "unable to start server: $err");
70 if ($opt_debug || !($cpid = fork ())) {
72 $SIG{PIPE
} = 'IGNORE';
73 $SIG{INT
} = 'IGNORE' if !$opt_debug;
75 $SIG{TERM
} = $SIG{QUIT
} = sub {
76 syslog
('info' , "server closing");
78 $SIG{INT
} = 'DEFAULT';
85 syslog
('info' , "starting server");
88 # redirect STDIN/STDOUT/SDTERR to /dev/null
89 open STDIN
, '</dev/null' || die "can't read /dev/null [$!]";
90 open STDOUT
, '>/dev/null' || die "can't write /dev/null [$!]";
91 open STDERR
, '>&STDOUT' || die "can't open STDERR to STDOUT [$!]";
97 $daemon->start_server();
102 syslog
('err' , "unexpected server error: $err");
103 print STDERR
$err if $opt_debug;
109 open (PIDFILE
, ">$pidfile") ||
110 die "cant write '$pidfile' - $! :ERROR";
111 print PIDFILE
"$cpid\n";
113 die "cant write '$pidfile' - $! :ERROR";
122 spiceproxy - SPICE proxy server for Proxmox VE
130 SPICE proxy server for Proxmox VE. Listens on port 3128.
132 =head1 COPYRIGHT AND DISCLAIMER
134 Copyright (C) 2007-2013 Proxmox Server Solutions GmbH
136 This program is free software: you can redistribute it and/or modify it
137 under the terms of the GNU Affero General Public License as published
138 by the Free Software Foundation, either version 3 of the License, or
139 (at your option) any later version.
141 This program is distributed in the hope that it will be useful, but
142 WITHOUT ANY WARRANTY; without even the implied warranty of
143 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
144 Affero General Public License for more details.
146 You should have received a copy of the GNU Affero General Public
147 License along with this program. If not, see
148 <http://www.gnu.org/licenses/>.