From c80c295bcd3971b634aaba1d0e8b4574dc216928 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Sat, 3 Feb 2024 21:42:58 +0200 Subject: [PATCH] Fix to check if plugin has a function before calling it --- add.cgi | 16 +++++++++------- delete.cgi | 12 +++++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/add.cgi b/add.cgi index 44c2757..8e07d73 100755 --- a/add.cgi +++ b/add.cgi @@ -56,13 +56,15 @@ foreach my $clash ("AuthUserFile", "AuthType", "AuthName") { # Add protected directory in other webserver plugins foreach my $p (&virtual_server::list_feature_plugins()) { - my $err = &virtual_server::plugin_call($p, - "feature_add_protected_dir", $d, - { 'protected_dir' => $dir, - 'protected_user_file_path' => $usersfile, - 'protected_user_file' => $htusers, - 'protected_name' => $in{'desc'} }); - &error($err) if ($err); + if (&virtual_server::plugin_defined($p, "feature_add_protected_dir")) { + my $err = &virtual_server::plugin_call($p, + "feature_add_protected_dir", $d, + { 'protected_dir' => $dir, + 'protected_user_file_path' => $usersfile, + 'protected_user_file' => $htusers, + 'protected_name' => $in{'desc'} }); + &error($err) if ($err); + } } # Create .htaccess (as domain owner) diff --git a/delete.cgi b/delete.cgi index 0f926ec..1569f94 100755 --- a/delete.cgi +++ b/delete.cgi @@ -25,11 +25,13 @@ foreach my $path (@d) { if ($dir) { # Delete protected directory in other webserver plugins foreach my $p (&virtual_server::list_feature_plugins()) { - my $err = &virtual_server::plugin_call($p, - "feature_delete_protected_dir", $d, - { 'protected_dir' => $dir->[0], - 'protected_user_file_path' => $dir->[1] }); - &error($err) if ($err); + if (&virtual_server::plugin_defined($p, "feature_delete_protected_dir")) { + my $err = &virtual_server::plugin_call($p, + "feature_delete_protected_dir", $d, + { 'protected_dir' => $dir->[0], + 'protected_user_file_path' => $dir->[1] }); + &error($err) if ($err); + } } # Remove protection directives no warnings "once";