-
-# sub REAPER { my $pid = wait; $SIG{CHLD} = \&REAPER; $kids--; }
-# #sub REAPER { my $pid = wait; $kids--; $SIG{CHLD} = \&REAPER; }
-# $SIG{CHLD} = \&REAPER;
-
- $shutdown = 0;
- $SIG{HUP} = sub { warn "SIGHUP received; shutting down\n"; $shutdown++; };
- $SIG{INT} = sub { warn "SIGINT received; shutting down\n"; $shutdown++; };
- $SIG{TERM} = sub { warn "SIGTERM received; shutting down\n"; $shutdown++; };
- $SIG{QUIT} = sub { warn "SIGQUIT received; shutting down\n"; $shutdown++; };
- $SIG{PIPE} = sub { warn "SIGPIPE received; shutting down\n"; $shutdown++; };
-
- #false laziness w/freeside-queued
- my $freeside_gid = scalar(getgrnam('freeside'))
- or die "can't setgid to freeside group\n";
- $) = $freeside_gid;
- $( = $freeside_gid;
- #if freebsd can't setuid(), presumably it can't setgid() either. grr fleabsd
- ($(,$)) = ($),$();
- $) = $freeside_gid;
-
- $> = $FS::UID::freeside_uid;
- $< = $FS::UID::freeside_uid;
- #freebsd is sofa king broken, won't setuid()
- ($<,$>) = ($>,$<);
- $> = $FS::UID::freeside_uid;
- #eslaf
-
- $ENV{HOME} = (getpwuid($>))[7]; #for ssh
- adminsuidsetup $user;
-
- #$log_file = "/usr/local/etc/freeside/selfservice.". $FS::UID::datasrc; #MACHINE NAME
- $log_file = "/usr/local/etc/freeside/selfservice.$machine.log";
-
- open STDOUT, '>/dev/null'
- or die "Can't write to /dev/null: $!";
- setsid or die "Can't start a new session: $!";
- open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
-
- $SIG{__DIE__} = \&_die;
- $SIG{__WARN__} = \&_logmsg;
-
- warn "freeside-selfservice-server starting\n";
-