Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 117124 | Differences between
and this patch

Collapse All | Expand All

(-)ddclient.bak (-17 / +38 lines)
Lines 22-27 Link Here
22
my $now       = time;
22
my $now       = time;
23
my $hostname  = hostname();
23
my $hostname  = hostname();
24
my $etc       = ($program =~ /test/i) ? './'   : '/etc/ddclient/';
24
my $etc       = ($program =~ /test/i) ? './'   : '/etc/ddclient/';
25
my $run       = ($program =~ /test/i) ? './'   : '/var/run/ddclient/';
25
my $savedir   = ($program =~ /test/i) ? 'URL/' : '/tmp/';
26
my $savedir   = ($program =~ /test/i) ? 'URL/' : '/tmp/';
26
my $msgs      = '';
27
my $msgs      = '';
27
my $last_msgs = '';
28
my $last_msgs = '';
Lines 221-227 Link Here
221
    'global-defaults'    => {
222
    'global-defaults'    => {
222
	'daemon'              => setv(T_DELAY, 0, 0, 1, 0,                    interval('60s')),
223
	'daemon'              => setv(T_DELAY, 0, 0, 1, 0,                    interval('60s')),
223
	'file'                => setv(T_FILE,  0, 0, 1, "$etc$program.conf",  undef),
224
	'file'                => setv(T_FILE,  0, 0, 1, "$etc$program.conf",  undef),
224
	'cache'               => setv(T_FILE,  0, 0, 1, "$etc$program.cache", undef),
225
	'cache'               => setv(T_FILE,  0, 0, 1, "$run$program.cache", undef),
225
	'pid'                 => setv(T_FILE,  0, 0, 1, "",                   undef),
226
	'pid'                 => setv(T_FILE,  0, 0, 1, "",                   undef),
226
	'proxy'               => setv(T_FQDNP, 0, 0, 1, '',                   undef),
227
	'proxy'               => setv(T_FQDNP, 0, 0, 1, '',                   undef),
227
	'protocol'            => setv(T_PROTO, 0, 0, 1, 'dyndns2',            undef),
228
	'protocol'            => setv(T_PROTO, 0, 0, 1, 'dyndns2',            undef),
Lines 474-481 Link Here
474
}
475
}
475
my $caught_hup  = 0;
476
my $caught_hup  = 0;
476
my $caught_term = 0;
477
my $caught_term = 0;
478
my $killing_me_softly = 0;
477
$SIG{'HUP'}    = sub { $caught_hup  = 1; };
479
$SIG{'HUP'}    = sub { $caught_hup  = 1; };
478
$SIG{'TERM'}   = sub { $caught_term = 1; };
480
$SIG{'TERM'}   = sub { $caught_term = 1; };
481
$SIG{'USR1'}   = sub { $killing_me_softly = 1;};
479
if (opt('daemon') && !opt('force')) {
482
if (opt('daemon') && !opt('force')) {
480
    $SIG{'CHLD'}   = 'IGNORE';
483
    $SIG{'CHLD'}   = 'IGNORE';
481
    my $pid = fork;
484
    my $pid = fork;
Lines 537-543 Link Here
537
	sendmail();
540
	sendmail();
538
541
539
	my $left = $daemon;
542
	my $left = $daemon;
540
	while (($left > 0) && !$caught_hup && !$caught_term) {
543
	while (($left > 0) && !$caught_hup && !$caught_term && !$killing_me_softly) {
541
		my $delay = $left > 10 ? 10 : $left;
544
		my $delay = $left > 10 ? 10 : $left;
542
545
543
		$0 = sprintf("%s - sleeping for %s seconds", $program, $left);
546
		$0 = sprintf("%s - sleeping for %s seconds", $program, $left);
Lines 553-560 Link Here
553
    } else {
556
    } else {
554
	$result = $result eq 'OK' ? 0 : 1;
557
	$result = $result eq 'OK' ? 0 : 1;
555
    }
558
    }
556
} while ($daemon && !$result && !$caught_term);
559
} while ($daemon && !$result && !$caught_term && !$killing_me_softly);
557
560
561
info("Shutting down ddclient.") if $killing_me_softly;
558
warning("caught SIGTERM; exiting") if $caught_term;
562
warning("caught SIGTERM; exiting") if $caught_term;
559
unlink_pid();
563
unlink_pid();
560
sendmail();
564
sendmail();
Lines 772-791 Link Here
772
    my $content = '';
776
    my $content = '';
773
777
774
    local *FD;
778
    local *FD;
775
    if (! open(FD, "< $file")) {
779
    if (! open(FD, "< $file")) { fatal("Cannot open file '%s'. ($!)", $file); }
776
	# fatal("Cannot open file '%s'. ($!)", $file);
777
	warning("Cannot open file '%s'. ($!)", $file);
778
    }
779
    # Check for only owner has any access to config file
780
    # Check for only owner has any access to config file
780
    my ($dev, $ino, $mode, @statrest) = stat(FD);
781
    my $badperm   = 0;
781
    if ($mode & 077) {                          
782
    my @stats     = stat(FD);
782
	if (-f FD && (chmod 0600, $file)) {
783
    my $perms     = $stats[2] & 07777; 
783
	    warning("file $file must be accessible only by its owner (fixed).");
784
    my $oct_perms = sprintf "%lo", $perms;
784
	} else {
785
    my $uid       = $stats[4];         
785
	    # fatal("file $file must be accessible only by its owner.");
786
    my $uname     = getpwuid($uid);
786
	    warning("file $file must be accessible only by its owner.");
787
    my $gid       = $stats[5];         
787
	}
788
    my $grnam     = getgrgid($gid);
788
    }
789
    if ($uid != getpwnam("root")) {
790
    	$badperm = 1;
791
    	warning("Root should own $file, but $uname owns it!"); 
792
    }
793
    if ($gid != getgrnam("ddclient")) {
794
     	$badperm = 1;
795
    	warning("Group ddclient should own $file, but group $grnam owns it!");
796
    }
797
    if ($perms != 0640) {
798
     	$badperm = 1;
799
    	warning("$file has permissions $oct_perms, but should have permissions 0640.");
800
    }
801
#    if ($badperm) {
802
#    	fatal("Please correct the permissions on $file and restart ddclient. Exiting.")
803
#    }
789
804
790
    local $lineno       = 0;
805
    local $lineno       = 0;
791
    my    $continuation = '';
806
    my    $continuation = '';
Lines 969-974 Link Here
969
	my $def    = $variables{'merged'}{$k};
984
	my $def    = $variables{'merged'}{$k};
970
	my $ovalue = define($globals{$k}, $def->{'default'});
985
	my $ovalue = define($globals{$k}, $def->{'default'});
971
	my $value  = check_value($ovalue, $def);
986
	my $value  = check_value($ovalue, $def);
987
988
	# we should really be allowed to set daemon to 0 in the config file
989
	if ($k eq 'daemon' && $ovalue == 0) {
990
		$value = $ovalue;
991
	}
992
972
	if ($def->{'required'} && !defined $value) {
993
	if ($def->{'required'} && !defined $value) {
973
	    $value = default($k);
994
	    $value = default($k);
974
	    warning("'%s=%s' is an invalid %s. (using default of %s)", $k, $ovalue, $def->{'type'}, $value);
995
	    warning("'%s=%s' is an invalid %s. (using default of %s)", $k, $ovalue, $def->{'type'}, $value);
Lines 2810-2816 Link Here
2810
		my $h = pop @hosts;
2831
		my $h = pop @hosts;
2811
	    
2832
	    
2812
		$config{$h}{'status'} = $status;
2833
		$config{$h}{'status'} = $status;
2813
		if ($status eq 'ok') {
2834
		if ($status eq 'ok' || $status eq 'nochange') {
2814
		    $config{$h}{'ip'}     = $ip;
2835
		    $config{$h}{'ip'}     = $ip;
2815
		    $config{$h}{'mtime'}  = $now;
2836
		    $config{$h}{'mtime'}  = $now;
2816
		    success("updating %s: %s: IP address set to %s", $h, $status, $ip);
2837
		    success("updating %s: %s: IP address set to %s", $h, $status, $ip);

Return to bug 117124