From 71b1ad6d49dedba5748afb07ff91ddc75e8dfed3 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 31 Dec 2008 00:09:57 +0000 Subject: [PATCH] Don't try root-only stuff if we aren't root --- filter/filter-lib.pl | 45 +++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/filter/filter-lib.pl b/filter/filter-lib.pl index 6ab7a5082..c70122ab6 100644 --- a/filter/filter-lib.pl +++ b/filter/filter-lib.pl @@ -10,28 +10,35 @@ do 'autoreply-file-lib.pl'; if (&get_product_name() eq 'usermin') { # If configured, check if this user has virtualmin spam filtering # enabled before switching away from root - if ($config{'virtualmin_spam'} && -x $config{'virtualmin_spam'} && - $< == 0) { - local $out = `$config{'virtualmin_spam'} $remote_user /dev/null`; - $out =~ s/\r|\n//g; - if ($out =~ /\d/) { - # Yes - we can show the user this - $global_spamassassin = 2; - $virtualmin_domain_id = $out; - } - } - - # Copy autoreply.pl to /etc/usermin/forward, while we are still root - local $autoreply_src = "$root_directory/forward/autoreply.pl"; $autoreply_cmd = "$config_directory/forward/autoreply.pl"; - local @rst = stat($autoreply_src); - local @cst = stat($autoreply_cmd); - if (!@cst || $cst[7] != $rst[7]) { - ©_source_dest($autoreply_src, $autoreply_cmd); - &set_ownership_permissions(undef, undef, 0755, $autoreply_cmd); + if ($< == 0) { + if ($config{'virtualmin_spam'} && + -x $config{'virtualmin_spam'}) { + local $out = &backquote_command( + "$config{'virtualmin_spam'} $remote_user ". + "/dev/null"); + $out =~ s/\r|\n//g; + if ($out =~ /\d/) { + # Yes - we can show the user this + $global_spamassassin = 2; + $virtualmin_domain_id = $out; + } + } + + # Copy autoreply.pl to /etc/usermin/forward, while we + # are still root + local $autoreply_src = "$root_directory/forward/autoreply.pl"; + local @rst = stat($autoreply_src); + local @cst = stat($autoreply_cmd); + if (!@cst || $cst[7] != $rst[7]) { + ©_source_dest($autoreply_src, $autoreply_cmd); + &set_ownership_permissions( + undef, undef, 0755, $autoreply_cmd); + } + + &switch_to_remote_user(); } - &switch_to_remote_user(); &create_user_config_dirs(); &foreign_require("procmail", "procmail-lib.pl"); &foreign_require("mailbox", "mailbox-lib.pl");