--- ddclient.bak 2006-01-18 18:02:53.000000000 -0500 +++ ddclient 2006-01-18 18:56:34.000000000 -0500 @@ -776,20 +776,31 @@ my $content = ''; local *FD; - if (! open(FD, "< $file")) { - # fatal("Cannot open file '%s'. ($!)", $file); - warning("Cannot open file '%s'. ($!)", $file); - } + if (! open(FD, "< $file")) { fatal("Cannot open file '%s'. ($!)", $file); } # Check for only owner has any access to config file - my ($dev, $ino, $mode, @statrest) = stat(FD); - if ($mode & 077) { - if (-f FD && (chmod 0600, $file)) { - warning("file $file must be accessible only by its owner (fixed)."); - } else { - # fatal("file $file must be accessible only by its owner."); - warning("file $file must be accessible only by its owner."); - } - } + my $badperm = 0; + my @stats = stat(FD); + my $perms = $stats[2] & 07777; + my $oct_perms = sprintf "%lo", $perms; + my $uid = $stats[4]; + my $uname = getpwuid($uid); + my $gid = $stats[5]; + my $grnam = getgrgid($gid); + if ($uid != getpwnam("root")) { + $badperm = 1; + warning("Root should own $file, but $uname owns it!"); + } + if ($gid != getgrnam("ddclient")) { + $badperm = 1; + warning("Group ddclient should own $file, but group $grnam owns it!"); + } + if ($perms != 0640) { + $badperm = 1; + warning("$file has permissions $oct_perms, but should have permissions 0640."); + } +# if ($badperm) { +# fatal("Please correct the permissions on $file and restart ddclient. Exiting.") +# } local $lineno = 0; my $continuation = '';