index c79bfdd1c9297b919b8121f3477987557619fb61..b3c88c1d8f32cf13cfe9164aab04b9a9d12fe0f0 100755 (executable)
my $sources_list;
my $max_clients;
my %repo_files=();
-my $repo_path;
my %repo_dirs=();
# Variables declared in config file are always set to 'our'
-our (%cfg_defaults, $log_file, $pid_file,
+our (%cfg_defaults, $log_file, $pid_file, $repo_basepath,
$server_ip, $server_port, $ClientPackages_key, $dns_lookup,
$arp_activ, $gosa_unit_tag,
$GosaPackages_key, $gosa_timeout,
%cfg_defaults = (
"general" => {
- "log-file" => [\$log_file, "/var/run/".$prg.".log"],
- "pid-file" => [\$pid_file, "/var/run/".$prg.".pid"],
+ "log-file" => [\$log_file, "/var/run/".$prg.".log"],
+ "pid-file" => [\$pid_file, "/var/run/".$prg.".pid"],
+ "repo-basepath" => [\$repo_basepath, "/srv/www"],
},
"server" => {
"ip" => [\$server_ip, "0.0.0.0"],
"messaging" => [\$messaging_file_name, '/var/lib/gosa-si/messaging.db'],
"foreign-clients" => [\$foreign_clients_file_name, '/var/lib/gosa-si/foreign_clients.db'],
"source-list" => [\$sources_list, '/etc/apt/sources.list'],
- "repo-path" => [\$repo_path, '/srv/www/repository'],
"ldap-uri" => [\$ldap_uri, ""],
"ldap-base" => [\$ldap_base, ""],
"ldap-admin-dn" => [\$ldap_admin_dn, ""],
return 1;
}
-sub sig_die_handler
-{
- my @loc = caller(0);
- daemon_log( "SIGDIE line " . $loc[2] . ": " . $_[0], 1 );
- clean_shutdown();
- return 1;
-}
-
$SIG{'INT'} = \&sig_int_or_term_handler;
$SIG{'TERM'} = \&sig_int_or_term_handler;
$SIG{'__WARN__'} = \&sig_warn_handler;
-$SIG{'__DIE__'} = \&sig_die_handler;
$SIG{'USR1'} = 'IGNORE';
sub check_key_and_xml_validity {
sub create_packages_list_db {
my ($ldap_handle, $sources_file, $session_id) = @_;
-
+
+ # Cleanup repo basepath
+ $repo_basepath = File::Spec->canonpath($repo_basepath);
+
# it should not be possible to trigger a recreation of packages_list_db
# while packages_list_db is under construction, so set flag packages_list_under_construction
# which is tested befor recreation can be started
my ($baseurl, $dist, $section, $session_id)= @_;
my ($package);
if (not defined $session_id) { $session_id = 0; }
- my ($path) = ($baseurl =~ m%://[^/]*(.*)$%);
+ my ($path) = ($baseurl =~ m%://[^/]*/(.*)$%);
+
+ my $repo_path = File::Spec->join($repo_basepath, $path);
+
$repo_dirs{ "${repo_path}/pool" } = 1;
foreach $package ("Packages.gz"){
# Trigger for filename
if ($line =~ /^Filename:\s/){
my ($filename) = ($line =~ /^Filename: (.*)$/);
+ # Construct real path
+ my $repo_path = File::Spec->join($repo_basepath, $srv_path);
store_fileinfo( $package, $filename, $dist, $srv_path, $version, $repo_path );
next;
}
$SIG{CHLD} = 'IGNORE';
-# 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 /: $!";
+ if (! chdir('/')) {
+ daemon_log("Can't chdir to /: $!", 1);
+ exit( 1 );
+ }
+ umask( 0 );
$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 ) {
+ # Parent: put PID into the $pid_file
open( LOCK_FILE, ">$pid_file" );
print LOCK_FILE "$pid\n";
close( LOCK_FILE );
if( !$foreground ) {
- exit( 0 )
- };
+ exit( 0 );
}
+}
+else {
+ # Child
+ open( STDIN, '+>/dev/null' );
+ open( STDOUT, '+>&STDIN' );
+ open( STDERR, '+>&STDIN' );
+ if (! POSIX::setsid()) {
+ daemon_log("Can't start a new session: $!");
+ exit( 1 );
+ }
+ $poe_kernel->has_forked() if ($poe_kernel->can('has_forked'));
+}
+
# parse head url and revision from svn
my $server_status_hash = { 'developmental'=>'revision', 'stable'=>'release'};