diff --git a/lib/Qpsmtpd/DB/File/DBM.pm b/lib/Qpsmtpd/DB/File/DBM.pm index c038618..6126a1d 100644 --- a/lib/Qpsmtpd/DB/File/DBM.pm +++ b/lib/Qpsmtpd/DB/File/DBM.pm @@ -201,6 +201,7 @@ sub validate_dir { my ( $self, $d ) = @_; return 0 if ! $d; return 0 if ! -d $d; + return 0 if ! -w $d; return 1; } diff --git a/t/qpsmtpd-db-file-dbm.t b/t/qpsmtpd-db-file-dbm.t index 58a94a7..c9e471d 100644 --- a/t/qpsmtpd-db-file-dbm.t +++ b/t/qpsmtpd-db-file-dbm.t @@ -125,6 +125,13 @@ sub __validate_dir { 'validate_dir(): false for non-existent directory' ); is( $db->validate_dir('t/tmp'), 1, 'validate_dir(): true for real directory' ); + mkdir 't/tmp/wtest', 0555; + is( $db->validate_dir('t/tmp/wtest'), 0, + 'validate_dir(): false for non-writeable directory' ); + chmod 0777, 't/tmp/wtest'; + is( $db->validate_dir('t/tmp/wtest'), 1, + 'validate_dir(): true for writeable directory' ); + rmdir 't/tmp/wtest'; } sub __dir {