mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
bug fix: fix opendkim on config rest
This commit is contained in:
@@ -5,6 +5,7 @@ import json
|
||||
import re
|
||||
from loginSystem.models import Administrator
|
||||
|
||||
|
||||
class secMiddleware:
|
||||
HIGH = 0
|
||||
LOW = 1
|
||||
@@ -52,7 +53,7 @@ class secMiddleware:
|
||||
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
#logging.writeToFile(request.body)
|
||||
# logging.writeToFile(request.body)
|
||||
data = json.loads(request.body)
|
||||
for key, value in data.items():
|
||||
if request.path.find('gitNotify') > -1:
|
||||
@@ -78,7 +79,8 @@ class secMiddleware:
|
||||
continue
|
||||
|
||||
if key == 'backupDestinations':
|
||||
if re.match('^[a-z|0-9]+:[a-z|0-9|\.]+\/?[A-Z|a-z|0-9|\.]*$', value) == None and value != 'local':
|
||||
if re.match('^[a-z|0-9]+:[a-z|0-9|\.]+\/?[A-Z|a-z|0-9|\.]*$',
|
||||
value) == None and value != 'local':
|
||||
logging.writeToFile(request.body)
|
||||
final_dic = {'error_message': "Data supplied is not accepted.",
|
||||
"errorMessage": "Data supplied is not accepted."}
|
||||
@@ -94,7 +96,7 @@ class secMiddleware:
|
||||
'cloudAPI') > -1 or request.build_absolute_uri().find(
|
||||
'verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1:
|
||||
continue
|
||||
if key == 'CLAMAV_VIRUS' or key == "Rspamdserver" or key == 'smtpd_milters' or key == 'non_smtpd_milters' or key == 'key' or key == 'cert' or key == 'recordContentAAAA' or key == 'backupDestinations' or key == 'ports' \
|
||||
if key == 'scriptUrl' or key == 'CLAMAV_VIRUS' or key == "Rspamdserver" or key == 'smtpd_milters' or key == 'non_smtpd_milters' or key == 'key' or key == 'cert' or key == 'recordContentAAAA' or key == 'backupDestinations' or key == 'ports' \
|
||||
or key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' \
|
||||
or key == 'emailMessage' or key == 'configData' or key == 'rewriteRules' \
|
||||
or key == 'modSecRules' or key == 'recordContentTXT' or key == 'SecAuditLogRelevantStatus' \
|
||||
@@ -106,7 +108,7 @@ class secMiddleware:
|
||||
")") > -1 \
|
||||
or value.find("'") > -1 or value.find("[") > -1 or value.find("]") > -1 or value.find(
|
||||
"{") > -1 or value.find("}") > -1 \
|
||||
or value.find(":") > -1 or value.find("<") >-1 or value.find(">") > -1:
|
||||
or value.find(":") > -1 or value.find("<") > -1 or value.find(">") > -1:
|
||||
logging.writeToFile(request.body)
|
||||
final_dic = {
|
||||
'error_message': "Data supplied is not accepted, following characters are not allowed in the input ` $ & ( ) [ ] { } ; : ‘ < >.",
|
||||
@@ -143,9 +145,11 @@ class secMiddleware:
|
||||
response['X-Frame-Options'] = "sameorigin"
|
||||
response['Content-Security-Policy'] = "script-src 'self' https://www.jsdelivr.com"
|
||||
response['Content-Security-Policy'] = "connect-src *;"
|
||||
response['Content-Security-Policy'] = "font-src 'self' 'unsafe-inline' https://www.jsdelivr.com https://fonts.googleapis.com"
|
||||
response['Content-Security-Policy'] = "style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://www.jsdelivr.com https://cdnjs.cloudflare.com https://maxcdn.bootstrapcdn.com https://cdn.jsdelivr.net"
|
||||
#response['Content-Security-Policy'] = "default-src 'self' cyberpanel.cloud *.cyberpanel.cloud"
|
||||
response[
|
||||
'Content-Security-Policy'] = "font-src 'self' 'unsafe-inline' https://www.jsdelivr.com https://fonts.googleapis.com"
|
||||
response[
|
||||
'Content-Security-Policy'] = "style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://www.jsdelivr.com https://cdnjs.cloudflare.com https://maxcdn.bootstrapcdn.com https://cdn.jsdelivr.net"
|
||||
# response['Content-Security-Policy'] = "default-src 'self' cyberpanel.cloud *.cyberpanel.cloud"
|
||||
response['X-Content-Type-Options'] = "nosniff"
|
||||
response['Referrer-Policy'] = "same-origin"
|
||||
|
||||
|
||||
@@ -595,9 +595,6 @@
|
||||
title="{% trans 'DKIM Manager' %}"><span>{% trans "DKIM Manager" %}</span></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li><a href="{% url 'EmailDebugger' %}"
|
||||
title="{% trans 'Email Debugger' %}"><span>{% trans "Email Debugger" %}</span></a>
|
||||
</li>
|
||||
|
||||
{% if admin or createEmail %}
|
||||
<li><a href="/snappymail/index.php" title="{% trans 'Access Webmail' %}"
|
||||
@@ -1039,6 +1036,9 @@
|
||||
<div class="sidebar-submenu">
|
||||
|
||||
<ul>
|
||||
<li><a href="{% url 'EmailDebugger' %}"
|
||||
title="{% trans 'Email Debugger' %}"><span>{% trans "Email Debugger" %}</span></a>
|
||||
</li>
|
||||
<li><a href="{% url 'mailQueue' %}"
|
||||
title="{% trans 'Mail Queue' %}"><span>{% trans "Mail Queue" %}</span></a>
|
||||
</li>
|
||||
|
||||
@@ -10,7 +10,7 @@ urlpatterns = [
|
||||
url(r'^design', views.design, name='design'),
|
||||
url(r'^getthemedata', views.getthemedata, name='getthemedata'),
|
||||
|
||||
#url(r'^upgrade',views.upgrade, name='upgrade'),
|
||||
url(r'^upgrade',views.upgrade, name='upgrade'),
|
||||
|
||||
url(r'^UpgradeStatus',views.upgradeStatus, name='UpgradeStatus'),
|
||||
url(r'^upgradeVersion',views.upgradeVersion, name='upgradeVersion'),
|
||||
|
||||
@@ -206,7 +206,7 @@ def upgrade(request):
|
||||
|
||||
vers = version.objects.get(pk=1)
|
||||
|
||||
from upgrade import Upgrade
|
||||
from plogical.upgrade import Upgrade
|
||||
|
||||
Upgrade.initiateUpgrade(vers.currentVersion, vers.build)
|
||||
|
||||
|
||||
@@ -1380,6 +1380,39 @@ class MailServerManager(multi.Thread):
|
||||
|
||||
return 1
|
||||
|
||||
def installOpenDKIMNew(self):
|
||||
try:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Installing opendkim..,40')
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
command = 'yum -y install opendkim'
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'dnf install opendkim -y'
|
||||
else:
|
||||
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install opendkim'
|
||||
|
||||
os.system(command)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'dnf install opendkim-tools -y'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'apt install opendkim-tools -y'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'mkdir -p /etc/opendkim/keys/'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'%s [installOpenDKIM][404]' % (str(msg)), 10)
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
def configureOpenDKIM(self):
|
||||
try:
|
||||
|
||||
@@ -1440,6 +1473,7 @@ milter_default_action = accept
|
||||
return 1
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(f'Error in configureOpenDKIM {str(msg)}')
|
||||
return 0
|
||||
|
||||
def fixCyberPanelPermissions(self):
|
||||
@@ -1652,6 +1686,11 @@ milter_default_action = accept
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Restoreing OpenDKIM configurations..,70')
|
||||
|
||||
if self.installOpenDKIMNew() == 0:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Install OpenDKIM failed. [404].')
|
||||
return 0
|
||||
|
||||
if self.configureOpenDKIM() == 0:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'configureOpenDKIM failed. [404].')
|
||||
return 0
|
||||
|
||||
@@ -2059,6 +2059,51 @@ class MailServerManagerUtils(multi.Thread):
|
||||
|
||||
###
|
||||
|
||||
def installOpenDKIMNew(self):
|
||||
try:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Installing opendkim..,40')
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
|
||||
|
||||
command = 'yum -y erase opendkim*'
|
||||
os.system(command)
|
||||
|
||||
command = 'yum -y install opendkim'
|
||||
elif ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
|
||||
command = 'yum -y erase opendkim*'
|
||||
os.system(command)
|
||||
|
||||
command = 'dnf install opendkim -y'
|
||||
else:
|
||||
|
||||
command = 'apt-get -y purge opendkim'
|
||||
os.system(command)
|
||||
|
||||
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install opendkim'
|
||||
|
||||
os.system(command)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
|
||||
command = 'dnf install opendkim-tools -y'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
command = 'apt install opendkim-tools -y'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
command = 'mkdir -p /etc/opendkim/keys/'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
|
||||
except BaseException as msg:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'%s [installOpenDKIM][404]' % (str(msg)), 10)
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
def ResetEmailConfigurations(self):
|
||||
try:
|
||||
### Check if remote or local mysql
|
||||
@@ -2121,6 +2166,11 @@ class MailServerManagerUtils(multi.Thread):
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Restoring OpenDKIM configurations..,70')
|
||||
|
||||
if self.installOpenDKIMNew() == 0:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'Install OpenDKIM failed. [404].')
|
||||
return 0
|
||||
|
||||
if self.configureOpenDKIM() == 0:
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
|
||||
'configureOpenDKIM failed. [404].')
|
||||
@@ -2159,6 +2209,9 @@ class MailServerManagerUtils(multi.Thread):
|
||||
|
||||
self.fixCyberPanelPermissions()
|
||||
|
||||
command = 'touch /home/cyberpanel/postfix'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Completed [200].')
|
||||
|
||||
except BaseException as msg:
|
||||
@@ -2203,11 +2256,11 @@ milter_default_action = accept
|
||||
writeToFile.write(configData)
|
||||
writeToFile.close()
|
||||
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
|
||||
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
|
||||
data = open(openDKIMConfigurePath, 'r').readlines()
|
||||
writeToFile = open(openDKIMConfigurePath, 'w')
|
||||
for items in data:
|
||||
if items.find('Socket') > -1 and items.find('local:') and items[0] != '#':
|
||||
if items.find('Socket') > -1 and items.find('local:') > -1:
|
||||
writeToFile.writelines('Socket inet:8891@localhost\n')
|
||||
else:
|
||||
writeToFile.writelines(items)
|
||||
|
||||
@@ -2907,6 +2907,8 @@ vmail
|
||||
# Upgrade.stdOut("Upgrades are currently disabled")
|
||||
# return 0
|
||||
|
||||
if branch.find('SoftUpgrade') == -1:
|
||||
|
||||
if os.path.exists(Upgrade.CentOSPath) or os.path.exists(Upgrade.openEulerPath):
|
||||
command = 'yum list installed'
|
||||
Upgrade.installedOutput = subprocess.check_output(shlex.split(command)).decode()
|
||||
@@ -3064,6 +3066,9 @@ vmail
|
||||
Upgrade.executioner(command, command, 1)
|
||||
|
||||
Upgrade.stdOut("Upgrade Completed.")
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user