Permalink
Browse files

Allow configuration of spool_dir permissions

Author: Jared Johnson <jaredj@nmgi.com>


git-svn-id: http://svn.perl.org/qpsmtpd/trunk@964 958fd67b-6ff1-0310-b445-bb7760255be9
  • Loading branch information...
1 parent 2781ef8 commit c9e628e9fe06a741a59c31874dd0f2acde6d07d7 robert committed Dec 31, 2008
Showing with 14 additions and 12 deletions.
  1. +3 −0 Changes
  2. +2 −1 README
  3. +9 −11 lib/Qpsmtpd.pm
View
@@ -59,6 +59,9 @@
(Jared Johnson)
http://groups.google.com/group/perl.qpsmtpd/browse_thread/thread/35e3a187d8e75cbe
+ New config option "spool_perms" to set permissions of spool_dir
+ (Jared Johnson)
+
0.43 - February 5, 2008
(This release was mostly done by Matt Sergeant and Hanno Hecker)
View
3 README
@@ -77,7 +77,8 @@ some other way.
The smtpd user needs write access to ~smtpd/qpsmtpd/tmp/ but should
not need to write anywhere else. This directory can be configured
-with the "spool_dir" configuration.
+with the "spool_dir" configuration and permissions can be set with
+"spool_perms".
As per version 0.25 the distributed ./run script runs tcpserver with
the -R flag to disable identd lookups. Remove the -R flag if that's
View
@@ -529,18 +529,16 @@ sub spool_dir {
$Spool_dir =~ /^(.+)$/ or die "spool_dir not configured properly";
$Spool_dir = $1; # cleanse the taint
-
- # Make sure the spool dir has appropriate rights
- if (-e $Spool_dir) {
- my $mode = (stat($Spool_dir))[2];
- $self->log(LOGWARN,
- "Permissions on spool_dir $Spool_dir are not 0700")
- if $mode & 07077;
+ my $Spool_perms = $self->config('spool_perms') || '0700';
+
+ if (-d $Spool_dir) { # Make sure the spool dir has appropriate rights
+ $self->log(LOGWARN,
+ "Permissions on spool_dir $Spool_dir are not $Spool_perms")
+ unless ((stat $Spool_dir)[2] & 07777) == oct($Spool_perms);
+ } else { # Or create it if it doesn't already exist
+ mkdir($Spool_dir,oct($Spool_perms))
+ or die "Could not create spool_dir $Spool_dir: $!";
}
-
- # And finally, create it if it doesn't already exist
- -d $Spool_dir or mkdir($Spool_dir, 0700)
- or die "Could not create spool_dir $Spool_dir: $!";
}
return $Spool_dir;

0 comments on commit c9e628e

Please sign in to comment.