index 57f26167185cc5de16e051bec86d3a27d3c87161..5ce0d368fc429a0d9661857f1952bbafb510f8e3 100755 (executable)
our $server_key;
our $opts_dnslookup;
+our $FIFO_FD = undef;
+
# default variables
our $REGISTERED = 0;
our $REGISTRATION_IN_PROGRESS = 0;
@logged_in_user_list = split(/\s/, $result);
}
- system("echo 'CURRENTLY_LOGGED_IN ".join(" ", @logged_in_user_list)."' > /var/run/gosa-si-client.socket");
+ $FIFO_FD = undef
+ if (! defined $FIFO_FD && ! defined open($FIFO_FD, '>', $gosa_si_client_fifo));
+ if (! defined $FIFO_FD) {
+ daemon_log("ERROR: unable to open fifo for writing: $!", 1);
+ $kernel->delay_set('trigger_logged_in_users_report', 30);
+ }
+ else {
+ print($FIFO_FD 'CURRENTLY_LOGGED_IN ' . join(" ", @logged_in_user_list));
$kernel->delay_set('trigger_logged_in_users_report', $trigger_logged_in_users_report_delay);
+ }
} else {
# try it in 10 sec again
$kernel->delay_set('trigger_logged_in_users_report', 10);
my $send_error = &send_msg_to_target($confirm_msg, $server_address, $server_key);
# Delete file
- if (not $send_error) {
- system("rm $goto_dir/$goto_file");
- }
+ unlink("$goto_dir/$goto_file")
+ if (! $send_error);
}
}
$kernel->alias_remove($heap->{alias});
$kernel->alarm_remove_all();
$kernel->post($heap->{child_session}, '_stop');
+ close( $FIFO_FD ) if( defined $FIFO_FD );
}
&read_configfile($cfg_file, %cfg_defaults);
&check_pid;
-# forward error messages to logfile
-if ( ! $foreground ) {
- open( STDIN, '+>/dev/null' );
- open( STDOUT, '+>&STDIN' );
- open( STDERR, '+>&STDIN' );
-}
-
-# Just fork, if we are not in foreground mode
-if( ! $foreground ) {
- chdir '/' or die "Can't chdir to /: $!";
- $pid = fork;
- setsid or die "Can't start a new session: $!";
- umask 0;
-} else {
- $pid = $$;
-}
-
-# Do something useful - put our PID into the pid_file
-if( 0 != $pid ) {
- open( LOCK_FILE, ">$pid_file" );
- print LOCK_FILE "$pid\n";
- close( LOCK_FILE );
- if( !$foreground ) {
- exit( 0 )
- };
-}
-
# parse head url and revision from svn
my $client_status_hash = { 'developmental'=>'revision', 'stable'=>'release'};
$client_version =~ /^\$HeadURL: (\S+) \$:\$Rev: (\d+) \$$/;
@@ -1290,6 +1273,52 @@ daemon_log("INFO: ".$client_status_hash->{$client_status}.": $client_revision",
# delete old DBsqlite lock files
system('rm -f /tmp/gosa_si_lock*gosa-si-client*');
+# (re-)create FIFO
+if (-e $gosa_si_client_fifo) {
+ daemon_log("INFO: $gosa_si_client_fifo exists - deleting", 5);
+ if (1 != unlink($gosa_si_client_fifo)) {
+ daemon_log("ERROR: unable to delete '$gosa_si_client_fifo': $!", 1);
+ exit( 1 );
+ }
+}
+if (! defined POSIX::mkfifo($gosa_si_client_fifo, "0600")) {
+ daemon_log("ERROR: failed creating fifo: $!", 1);
+ exit( 1 );
+}
+
+# Just fork, if we are not in foreground mode
+if( ! $foreground ) {
+ if (! chdir('/')) {
+ daemon_log("ERROR: Can't chdir to /: $!");
+ exit( 1 );
+ }
+ umask( 0 );
+ $pid = fork;
+} else {
+ $pid = $$;
+}
+
+if( 0 != $pid ) {
+ # Parent: put our PID into the $pid_file
+ open( LOCK_FILE, ">$pid_file" );
+ print LOCK_FILE "$pid\n";
+ close( LOCK_FILE );
+ if( !$foreground ) {
+ exit( 0 );
+ }
+}
+else {
+ # Child
+ open( STDIN, '+>/dev/null' );
+ open( STDOUT, '+>&STDIN' );
+ open( STDERR, '+>&STDIN' );
+ if (! POSIX::setsid()) {
+ deamon_log("ERROR: Can't start a new session: $!", 1);
+ exit( 1 );
+ }
+ $poe_kernel->has_forked() if ($poe_kernel->can('has_forked'));
+}
+
# detect ip and mac address and complete host address
$client_address = $client_ip.":".$client_port;
my $network_interface= &get_interface_for_ip($client_ip);
# Find servers from config and DNS
&find_servers;
-# open fifo for non-gosa-si-client-msgs to gosa-si-server
-POSIX::mkfifo("$gosa_si_client_fifo", "0600");
-
-
POE::Session->create(
inline_states => {
_start => \&_start,