Skip to content

Commit

Permalink
e2guardian5 - update changes to config_set_path function
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcello Coutinho committed Jul 24, 2023
1 parent 2eec0bf commit 7f7209a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
28 changes: 17 additions & 11 deletions pkg-e2guardian5/files/usr/local/pkg/e2guardian_antivirus.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* squid_antivirus.inc
*
* part of pfSense (https://www.pfsense.org)
* Copyright (c) 2015-2017 Rubicon Communications, LLC (Netgate)
* Copyright (c) 2015-2023 Rubicon Communications, LLC (Netgate)
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -156,10 +156,10 @@ function e2guardian_antivirus_upgrade_config() {
global $config;
/* unset broken antivirus settings */
if (is_array($config['installedpackages']['squidantivirus'])) {
unset($config['installedpackages']['squidantivirus']['config'][0]['squidclamav']);
unset($config['installedpackages']['squidantivirus']['config'][0]['c-icap_conf']);
unset($config['installedpackages']['squidantivirus']['config'][0]['c-icap_magic']);
unset($config['installedpackages']['squidantivirus']['config'][0]['freshclam_conf']);
config_del_path("installedpackages/squidantivirus/config/0/squidclamav");
config_del_path("installedpackages/squidantivirus/config/0/c-icap_conf");
config_del_path("installedpackages/squidantivirus/config/0/c-icap_magic");
config_del_path("installedpackages/squidantivirus/config/0/freshclam_conf");
}
}

Expand Down Expand Up @@ -557,15 +557,17 @@ function e2guardian_antivirus_get_raw_config() {
$conffile = SQUID_LOCALBASE . "/etc" . "{$confdir}" . "/{$rawfile}.pfsense";
if (file_exists($conffile)) {
if ($config['installedpackages']['squidantivirus']['config'][0][$confopt] == "") {
$config['installedpackages']['squidantivirus']['config'][0][$confopt] = base64_encode(str_replace("\r", "", file_get_contents("{$conffile}")));
//$config['installedpackages']['squidantivirus']['config'][0][$confopt] = base64_encode(str_replace("\r", "", file_get_contents("{$conffile}")));
config_set_path("installedpackages/squidantivirus/config/0/$confopt",base64_encode(str_replace("\r", "", file_get_contents($conffile))));
log_error("[squid] Successfully loaded '{$conffile}' configuration file");
$loaded = true;
}
// Just a fallback attempt if people do things in weird order on a completely fresh install perhaps; should not be ever needed
} else {
squid_antivirus_install_config_files();
if (file_exists($conffile)) {
$config['installedpackages']['squidantivirus']['config'][0][$confopt] = base64_encode(str_replace("\r", "", file_get_contents("{$conffile}")));
//$config['installedpackages']['squidantivirus']['config'][0][$confopt] = base64_encode(str_replace("\r", "", file_get_contents("{$conffile}")));
config_set_path("installedpackages/squidantivirus/config/0/$confopt",base64_encode(str_replace("\r", "", file_get_contents($conffile))));
log_error("[squid] Successfully loaded '{$conffile}' configuration file");
$loaded = true;
} else {
Expand All @@ -588,7 +590,8 @@ function e2guardian_antivirus_toggle_raw_config($state) {
$opts = array("clamav_url", "clamav_safebrowsing", "clamav_dbregion", "clamav_dbservers");
foreach ($opts as $opt) {
if (isset($config['installedpackages']['squidantivirus']['config'][0][$opt])) {
unset($config['installedpackages']['squidantivirus']['config'][0][$opt]);
config_del_path("installedpackages/squidantivirus/config/0/$opt");
//unset($config['installedpackages']['squidantivirus']['config'][0][$opt]);
log_error("[squid] Loaded '{$opt}' raw configuration file...");
}
}
Expand All @@ -599,11 +602,13 @@ function e2guardian_antivirus_toggle_raw_config($state) {
$opts = array("raw_squidclamav_conf", "raw_cicap_conf", "raw_cicap_magic", "raw_freshclam_conf", "raw_clamd_conf");
foreach ($opts as $opt) {
if (isset($config['installedpackages']['squidantivirus']['config'][0][$opt])) {
unset($config['installedpackages']['squidantivirus']['config'][0][$opt]);
//unset($config['installedpackages']['squidantivirus']['config'][0][$opt]);
config_del_path("installedpackages/squidantivirus/config/0/$opt");
log_error("[squid] Unloaded '{$opt}' raw configuration.");
}
}
$config['installedpackages']['squidantivirus']['config'][0]['enable_advanced'] = "disabled";
//$config['installedpackages']['squidantivirus']['config'][0]['enable_advanced'] = "disabled";
config_set_path("installedpackages/squidantivirus/config/0/enable_advanced","disabled");
}
}

Expand Down Expand Up @@ -851,7 +856,8 @@ function e2guardian_validate_antivirus($post, &$input_errors) {

/* Load the raw config files if manual configuration is enabled */
if ($post['load_advanced'] == 'Load Advanced') {
$config['installedpackages']['squidantivirus']['config'][0]['enable_advanced'] = "enabled";
//$config['installedpackages']['squidantivirus']['config'][0]['enable_advanced'] = "enabled";
config_set_path("installedpackages/squidantivirus/config/0/enable_advanced", "enabled");
squid_antivirus_toggle_raw_config(true);
return;
}
Expand Down
8 changes: 5 additions & 3 deletions pkg-e2guardian5/files/usr/local/www/e2guardian_ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* ========================================================================== */
/*
e2guardian_ldap.php
Copyright (C) 2015-2020 Marcello Coutinho
Copyright (C) 2015-2023 Marcello Coutinho
part of pfSense (http://www.pfSense.com)
All rights reserved.
*/
Expand Down Expand Up @@ -151,15 +151,17 @@ function get_ldap_members($group, $user, $password) {
}
if (empty($members)) {
if (!is_null($config['installedpackages']['e2guardianusers']['config'][0][strtolower($group['name'])])) {
$config['installedpackages']['e2guardianusers']['config'][0][strtolower($group['name'])] = NULL;
//$config['installedpackages']['e2guardianusers']['config'][0][strtolower($group['name'])] = NULL;
config_set_path("installedpackages/e2guardianusers/config/0/" . strtolower($group['name']),NULL);
$apply_config++;
}
} else {
$import_users = explode("\n", $members);
asort($import_users);
$members = base64_encode(implode("\n", $import_users));
if ($config['installedpackages']['e2guardianusers']['config'][0][strtolower($group['name'])] != $members) {
$config['installedpackages']['e2guardianusers']['config'][0][strtolower($group['name'])] = $members;
//$config['installedpackages']['e2guardianusers']['config'][0][strtolower($group['name'])] = $members;
config_set_path("installedpackages/e2guardianusers/config/0/" . strtolower($group['name']),$members);
$apply_config++;
}
}
Expand Down

0 comments on commit 7f7209a

Please sign in to comment.