exim-exigrey.pl
changeset 18 8e9577bcbe71
parent 16 b47059897e9b
child 23 bce276394054
--- a/exim-exigrey.pl	Tue Jan 02 21:36:31 2007 +0000
+++ b/exim-exigrey.pl	Tue Jan 02 21:46:52 2007 +0000
@@ -104,9 +104,13 @@
     # this file
     if (!-f $db) {
 	(my $dir = $db) =~ s/^(.*)\/.*?$/$1/;
-	local ($>, $)) = (stat $dir)[4,5] or die "Can't stat $dir: $!";
+	# copy mode, uid, gid from the directory
+	my ($mode, $user, $group) = (stat $dir)[2,4,5] or die "Can't stat $dir: $!";
+	my $umask = umask(($mode & 0777) ^ 0777);
+	local ($>, $)) = ($user, $group);
 	open(X, ">>$db") or die "Can't create $db: $!";
 	close(X);
+	umask $umask;
     }
 
     # now test which of the DB-Modules has been loaded