From 32d20fe18ca045590459f10dea7c05bb3cee0b9e Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 10 Oct 2026 15:51:39 -0700 Subject: [PATCH] If the DBM belongs to a user, open it with that user's permissions --- spam/spam-lib.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/spam/spam-lib.pl b/spam/spam-lib.pl index fd17aa447..f20d58c4a 100755 --- a/spam/spam-lib.pl +++ b/spam/spam-lib.pl @@ -1034,15 +1034,23 @@ return $awp; # 0 if it could not be opened, or -1 if empty. sub open_auto_whitelist_dbm { -local ($user) = @_; -local $awp = &get_auto_whitelist_file($user); +my ($user) = @_; +my $awp = &get_auto_whitelist_file($user); return 0 if (!$awp); local $anyok; foreach my $cls ('DB_File', 'GDBM_File', 'SDBM_File') { $@ = undef; eval "use $cls"; next if ($@); - tie(%awl, $cls, $awp, O_RDWR, 0755) || next; + my $ok; + if ($user && $user ne "root") { + $ok = &eval_as_unix_user($user, + sub { return tie(%awl, $cls, $awp, O_RDWR, 0755) }); + } + else { + $ok = tie(%awl, $cls, $awp, O_RDWR, 0755); + } + next if (!$ok); if (scalar(keys %awl)) { return 1; }