From 6b13e24221cc5a21754e63fff19370116b5bfdb1 Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Tue, 24 Feb 2015 11:51:18 -0600 Subject: [PATCH] Add perms test to Qpsmtpd::DB::File::DBM::dir() --- lib/Qpsmtpd/DB/File/DBM.pm | 1 + t/qpsmtpd-db-file-dbm.t | 7 +++++++ 2 files changed, 8 insertions(+) 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 {