umask for file creation
authorheiko
Tue, 02 Jan 2007 21:46:52 +0000
changeset 18 8e9577bcbe71
parent 17 43cfd824c314
child 19 f741b1822a02
umask for file creation
debian/changelog
exim-exigrey.pl
--- a/debian/changelog	Tue Jan 02 21:36:31 2007 +0000
+++ b/debian/changelog	Tue Jan 02 21:46:52 2007 +0000
@@ -1,3 +1,9 @@
+exigrey (0.6-1) stable; urgency=low
+
+  * bug with umask fixed
+
+ -- Heiko Schlittermann <hs@schlittermann.de>  Tue, 02 Jan 2007 22:46:22 +0100
+
 exigrey (0.5-1) stable; urgency=low
 
   * new upstream: 
--- 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