bug fix: mail scanner

This commit is contained in:
Usman Nasir
2020-05-28 21:29:48 +05:00
parent e8b541ccea
commit 28568b8829
4 changed files with 10 additions and 263 deletions

View File

@@ -1297,7 +1297,6 @@ app.controller('MailScanner', function ($scope, $http, $timeout, $window) {
$scope.SpamAssassinSuccessfullyInstalled = true;
$scope.installationFailed = true;
$scope.installSpamAssassin = function () {
$scope.SpamAssassinNotifyBox = true;
@@ -1441,130 +1440,4 @@ app.controller('MailScanner', function ($scope, $http, $timeout, $window) {
}
}
///// SpamAssassin configs
var report_safe = false;
$('#report_safe').change(function () {
report_safe = $(this).prop('checked');
});
fetchSpamAssassinSettings();
function fetchSpamAssassinSettings() {
$scope.SpamAssassinLoading = false;
$('#report_safe').bootstrapToggle('off');
url = "/emailPremium/fetchSpamAssassinSettings";
var data = {};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.SpamAssassinLoading = true;
if (response.data.fetchStatus === 1) {
if (response.data.installed === 1) {
if (response.data.report_safe === 1) {
$('#report_safe').bootstrapToggle('on');
}
$scope.required_hits = response.data.required_hits;
$scope.rewrite_header = response.data.rewrite_header;
$scope.required_score = response.data.required_score;
}
}
}
function cantLoadInitialDatas(response) {
$scope.SpamAssassinLoading = true;
}
}
/////
/// Save SpamAssassin Changes
$scope.failedToSave = true;
$scope.successfullySaved = true;
$scope.saveSpamAssassinConfigurations = function () {
$scope.failedToSave = true;
$scope.successfullySaved = true;
$scope.SpamAssassinLoading = false;
$scope.couldNotConnect = true;
url = "/emailPremium/saveSpamAssassinConfigurations";
var data = {
report_safe: report_safe,
required_hits: $scope.required_hits,
rewrite_header: $scope.rewrite_header,
required_score: $scope.required_score
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.saveStatus === 1) {
$scope.failedToSave = true;
$scope.successfullySaved = false;
$scope.SpamAssassinLoading = true;
$scope.couldNotConnect = true;
} else {
$scope.errorMessage = response.data.error_message;
$scope.failedToSave = false;
$scope.successfullySaved = true;
$scope.SpamAssassinLoading = true;
$scope.couldNotConnect = true;
}
}
function cantLoadInitialDatas(response) {
$scope.failedToSave = true;
$scope.successfullySaved = false;
$scope.SpamAssassinLoading = true;
$scope.couldNotConnect = true;
}
};
});

View File

@@ -1190,7 +1190,7 @@ def MailScanner(request):
if mailUtilities.checkIfMailScannerInstalled() == 1:
checkIfMailScannerInstalled = 1
return render(request, 'emailPremium/MailScanner.html',{'checkIfMailScannerInstalled': checkIfMailScannerInstalled, 'ipAddress': ipAddress})
return render(request, 'emailPremium/MailScanner.html',{'checkIfMailScannerInstalled': 0, 'ipAddress': ipAddress})
except KeyError:
return redirect(loadLoginPage)
@@ -1234,7 +1234,7 @@ def installStatusMailScanner(request):
try:
if request.method == 'POST':
command = "sudo cat " + mailUtilities.spamassassinInstallLogPath
command = "sudo cat " + mailUtilities.mailScannerInstallLogPath
installStatus = ProcessUtilities.outputExecutioner(command)
if installStatus.find("[200]")>-1:

View File

@@ -30,6 +30,7 @@ class mailUtilities:
installLogPath = "/home/cyberpanel/openDKIMInstallLog"
spamassassinInstallLogPath = "/home/cyberpanel/spamassassinInstallLogPath"
cyberPanelHome = "/home/cyberpanel"
mailScannerInstallLogPath = "/home/cyberpanel/mailScannerInstallLogPath"
@staticmethod
def SendEmail(sender, receivers, message):
@@ -484,8 +485,8 @@ milter_default_action = accept
def installMailScanner(install, SpamAssassin):
try:
if os.path.exists(mailUtilities.spamassassinInstallLogPath):
os.remove(mailUtilities.spamassassinInstallLogPath)
if os.path.exists(mailUtilities.mailScannerInstallLogPath):
os.remove(mailUtilities.mailScannerInstallLogPath)
if mailUtilities.checkIfSpamAssassinInstalled():
@@ -497,30 +498,30 @@ milter_default_action = accept
cmd = shlex.split(command)
with open(mailUtilities.spamassassinInstallLogPath, 'w') as f:
with open(mailUtilities.mailScannerInstallLogPath, 'w') as f:
res = subprocess.call(cmd, stdout=f)
if res == 1:
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
writeToFile = open(mailUtilities.mailScannerInstallLogPath, 'a')
writeToFile.writelines("Can not be installed.[404]\n")
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile("[Could not Install MailScanner.]")
return 0
else:
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
writeToFile = open(mailUtilities.mailScannerInstallLogPath, 'a')
writeToFile.writelines("MailScanner Installed.[200]\n")
writeToFile.close()
return 1
else:
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
writeToFile = open(mailUtilities.mailScannerInstallLogPath, 'a')
writeToFile.writelines("Please install SpamAssassin from CyberPanel before installing MailScanner.[404]\n")
writeToFile.close()
except BaseException as msg:
writeToFile = open(mailUtilities.spamassassinInstallLogPath, 'a')
writeToFile = open(mailUtilities.mailScannerInstallLogPath, 'a')
writeToFile.writelines("Can not be installed.[404]\n")
writeToFile.close()
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[installSpamAssassin]")

View File

@@ -1297,7 +1297,6 @@ app.controller('MailScanner', function ($scope, $http, $timeout, $window) {
$scope.SpamAssassinSuccessfullyInstalled = true;
$scope.installationFailed = true;
$scope.installSpamAssassin = function () {
$scope.SpamAssassinNotifyBox = true;
@@ -1441,130 +1440,4 @@ app.controller('MailScanner', function ($scope, $http, $timeout, $window) {
}
}
///// SpamAssassin configs
var report_safe = false;
$('#report_safe').change(function () {
report_safe = $(this).prop('checked');
});
fetchSpamAssassinSettings();
function fetchSpamAssassinSettings() {
$scope.SpamAssassinLoading = false;
$('#report_safe').bootstrapToggle('off');
url = "/emailPremium/fetchSpamAssassinSettings";
var data = {};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.SpamAssassinLoading = true;
if (response.data.fetchStatus === 1) {
if (response.data.installed === 1) {
if (response.data.report_safe === 1) {
$('#report_safe').bootstrapToggle('on');
}
$scope.required_hits = response.data.required_hits;
$scope.rewrite_header = response.data.rewrite_header;
$scope.required_score = response.data.required_score;
}
}
}
function cantLoadInitialDatas(response) {
$scope.SpamAssassinLoading = true;
}
}
/////
/// Save SpamAssassin Changes
$scope.failedToSave = true;
$scope.successfullySaved = true;
$scope.saveSpamAssassinConfigurations = function () {
$scope.failedToSave = true;
$scope.successfullySaved = true;
$scope.SpamAssassinLoading = false;
$scope.couldNotConnect = true;
url = "/emailPremium/saveSpamAssassinConfigurations";
var data = {
report_safe: report_safe,
required_hits: $scope.required_hits,
rewrite_header: $scope.rewrite_header,
required_score: $scope.required_score
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
if (response.data.saveStatus === 1) {
$scope.failedToSave = true;
$scope.successfullySaved = false;
$scope.SpamAssassinLoading = true;
$scope.couldNotConnect = true;
} else {
$scope.errorMessage = response.data.error_message;
$scope.failedToSave = false;
$scope.successfullySaved = true;
$scope.SpamAssassinLoading = true;
$scope.couldNotConnect = true;
}
}
function cantLoadInitialDatas(response) {
$scope.failedToSave = true;
$scope.successfullySaved = false;
$scope.SpamAssassinLoading = true;
$scope.couldNotConnect = true;
}
};
});