-
{% trans "List Emails Accounts. Change their passwords or delete them." %}
diff --git a/manageServices/views.py b/manageServices/views.py
index e82afe5d1..33f874004 100755
--- a/manageServices/views.py
+++ b/manageServices/views.py
@@ -18,7 +18,11 @@ def managePowerDNS(request):
data = {}
data['status'] = 1
- pdnsStatus = PDNSStatus.objects.get(pk=1)
+ try:
+ pdnsStatus = PDNSStatus.objects.get(pk=1)
+ except:
+ pdnsStatus = PDNSStatus(type='NATIVE', serverStatus=1)
+ pdnsStatus.save()
if pdnsStatus.type == 'MASTER':
counter = 1
diff --git a/plogical/filesPermsUtilities.py b/plogical/filesPermsUtilities.py
new file mode 100644
index 000000000..07261326b
--- /dev/null
+++ b/plogical/filesPermsUtilities.py
@@ -0,0 +1,190 @@
+import os
+import shutil
+import pathlib
+import stat
+
+
+def mkdir_p(path, exist_ok=True):
+ """
+ Creates the directory and paths leading up to it like unix mkdir -p .
+ Defaults to exist_ok so if it exists were not throwing fatal errors
+ https://docs.python.org/3.7/library/os.html#os.makedirs
+ """
+ if not os.path.exists(path):
+ print('creating directory: ' + path)
+ os.makedirs(path, exist_ok)
+
+
+def chmod_digit(file_path, perms):
+ """
+ Helper function to chmod like you would in unix without having to preface 0o or converting to octal yourself.
+ Credits: https://stackoverflow.com/a/60052847/1621381
+ """
+ try:
+ os.chmod(file_path, int(str(perms), base=8))
+ except:
+ print(f'Could not chmod : {file_path} to {perms}')
+ pass
+
+
+def touch(filepath: str, exist_ok=True):
+ """
+ Touches a file like unix `touch somefile` would.
+ """
+ try:
+ pathlib.Path(filepath).touch(exist_ok)
+ except FileExistsError:
+ print('Could touch : ' + filepath)
+ pass
+
+
+def symlink(src, dst):
+ """
+ Symlink a path to another if the src exists.
+ """
+ try:
+ if os.access(src, os.R_OK):
+ os.symlink(src, dst)
+ except:
+ print(f'Could not symlink Source: {src} > Destination: {dst}')
+ pass
+
+
+def chown(path, user, group=-1):
+ """
+ Chown file/path to user/group provided. Passing -1 to user or group will leave it unchanged.
+ Useful if just changing user or group vs both.
+ """
+ try:
+ shutil.chown(path, user, group)
+ except PermissionError:
+ print(f'Could not change permissions for: {path} to {user}:{group}')
+ pass
+
+
+def recursive_chown(path, owner, group=-1):
+ """
+ Recursively chown a path and contents to owner.
+ https://docs.python.org/3/library/shutil.html
+ """
+ for dirpath, dirnames, filenames in os.walk(path):
+ try:
+ shutil.chown(dirpath, owner, group)
+ except PermissionError:
+ print('Could not change permissions for: ' + dirpath + ' to: ' + owner)
+ pass
+ for filename in filenames:
+ try:
+ shutil.chown(os.path.join(dirpath, filename), owner, group)
+ except PermissionError:
+ print('Could not change permissions for: ' + os.path.join(dirpath, filename) + ' to: ' + owner)
+ pass
+
+
+def recursive_permissions(path, dir_mode=755, file_mode=644, topdir=True):
+ """
+ Recursively chmod a path and contents to mode.
+ Defaults to chmod top level directory but can be optionally
+ toggled off when you want to chmod only contents of like a user's homedir vs homedir itself
+ https://docs.python.org/3.6/library/os.html#os.walk
+ """
+
+ # Here we are converting the integers to string and then to octal.
+ # so this function doesn't need to be called with 0o prefixed for the file and dir mode
+ dir_mode = int(str(dir_mode), base=8)
+ file_mode = int(str(file_mode), base=8)
+
+ if topdir:
+ # Set chmod on top level path
+ try:
+ os.chmod(path, dir_mode)
+ except:
+ print('Could not chmod :' + path + ' to ' + str(dir_mode))
+ for root, dirs, files in os.walk(path):
+ for d in dirs:
+ try:
+ os.chmod(os.path.join(root, d), dir_mode)
+ except:
+ print('Could not chmod :' + os.path.join(root, d) + ' to ' + str(dir_mode))
+ pass
+ for f in files:
+ try:
+ os.chmod(os.path.join(root, f), file_mode)
+ except:
+ print('Could not chmod :' + path + ' to ' + str(file_mode))
+ pass
+
+
+# Left intentionally here for reference.
+# Set recursive chown for a path
+# recursive_chown(my_path, 'root', 'root')
+# for changing group recursively without affecting user
+# recursive_chown('/usr/local/lscp/cyberpanel/rainloop/data', -1, 'lscpd')
+
+# explicitly set permissions for directories/folders to 0755 and files to 0644
+# recursive_permissions(my_path, 755, 644)
+
+# Fix permissions and use default values
+# recursive_permissions(my_path)
+# =========================================================
+# Below is a helper class for getting and working with permissions
+# Original credits to : https://github.com/keysemble/perfm
+
+def perm_octal_digit(rwx):
+ digit = 0
+ if rwx[0] == 'r':
+ digit += 4
+ if rwx[1] == 'w':
+ digit += 2
+ if rwx[2] == 'x':
+ digit += 1
+ return digit
+
+
+class FilePerm:
+ def __init__(self, filepath):
+ filemode = stat.filemode(os.stat(filepath).st_mode)
+ permissions = [filemode[-9:][i:i + 3] for i in range(0, len(filemode[-9:]), 3)]
+ self.filepath = filepath
+ self.access_dict = dict(zip(['user', 'group', 'other'], [list(perm) for perm in permissions]))
+
+ def mode(self):
+ mode = 0
+ for shift, digit in enumerate(self.octal()[::-1]):
+ mode += digit << (shift * 3)
+ return mode
+
+ def digits(self):
+ """Get the octal chmod equivalent value 755 in single string"""
+ return "".join(map(str, self.octal()))
+
+ def octal(self):
+ """Get the octal value in a list [7, 5, 5]"""
+ return [perm_octal_digit(p) for p in self.access_dict.values()]
+
+ def access_bits(self, access):
+ if access in self.access_dict.keys():
+ r, w, x = self.access_dict[access]
+ return [r == 'r', w == 'w', x == 'x']
+
+ def update_bitwise(self, settings):
+ def perm_list(read=False, write=False, execute=False):
+ pl = ['-', '-', '-']
+ if read:
+ pl[0] = 'r'
+ if write:
+ pl[1] = 'w'
+ if execute:
+ pl[2] = 'x'
+ return pl
+
+ self.access_dict = dict(
+ [(access, perm_list(read=r, write=w, execute=x)) for access, [r, w, x] in settings.items()])
+ os.chmod(self.filepath, self.mode())
+
+# project_directory = os.path.abspath(os.path.dirname(sys.argv[0]))
+# home_directory = os.path.expanduser('~')
+# print(f'Path: {home_directory} Mode: {FilePerm(home_directory).mode()} Octal: {FilePerm(home_directory).octal()} '
+# f'Digits: {FilePerm(home_directory).digits()}')
+# Example: Output
+# Path: /home/cooluser Mode: 493 Octal: [7, 5, 5] Digits: 755
diff --git a/plogical/firewallUtilities.py b/plogical/firewallUtilities.py
index e58588eaa..7c3c0997a 100755
--- a/plogical/firewallUtilities.py
+++ b/plogical/firewallUtilities.py
@@ -238,6 +238,5 @@ def main():
-
if __name__ == "__main__":
main()
\ No newline at end of file
diff --git a/plogical/ftpUtilities.py b/plogical/ftpUtilities.py
index 7c72131ca..4deee0b13 100755
--- a/plogical/ftpUtilities.py
+++ b/plogical/ftpUtilities.py
@@ -121,7 +121,7 @@ class FTPUtilities:
path = path.lstrip("/")
if path != 'None':
- path = "/home/" + domainName + "/public_html/" + path
+ path = "/home/" + domainName + "/" + path
## Security Check
diff --git a/plogical/httpProc.py b/plogical/httpProc.py
index 2224101a4..20e0a4604 100755
--- a/plogical/httpProc.py
+++ b/plogical/httpProc.py
@@ -19,6 +19,7 @@ class httpProc:
from plogical.acl import ACLManager
currentACL = ACLManager.loadedACL(userID)
+ admin = Administrator.objects.get(pk=userID)
### Permissions Check
@@ -38,6 +39,7 @@ class httpProc:
ipData = f.read()
ipAddress = ipData.split('\n', 1)[0]
self.data['ipAddress'] = ipAddress
+ self.data['fullName'] = '%s %s' % (admin.firstName, admin.lastName)
self.data.update(currentACL)
diff --git a/plogical/mailUtilities.py b/plogical/mailUtilities.py
index 747a3a179..2ec0529cf 100755
--- a/plogical/mailUtilities.py
+++ b/plogical/mailUtilities.py
@@ -818,6 +818,29 @@ class MailServerManagerUtils(multi.Thread):
command = 'apt-get -y remove postfix'
ProcessUtilities.executioner(command)
+ ### On Ubuntu 18 find if old dovecot and remove
+
+ if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
+ try:
+
+ command = 'apt-get purge dovecot* -y'
+ os.system(command)
+
+ command = 'apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 18A348AEED409DA1'
+ ProcessUtilities.executioner(command)
+
+ writeToFile = open('/etc/apt/sources.list.d/dovecot.list', 'a')
+ writeToFile.writelines('deb [arch=amd64] https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n')
+ writeToFile.close()
+
+ command = 'apt update'
+ ProcessUtilities.executioner(command)
+
+ except:
+ pass
+
+ ##
+
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], 'Re-installing postfix..,10')
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
@@ -834,6 +857,8 @@ class MailServerManagerUtils(multi.Thread):
command = 'dnf install --enablerepo=gf-plus postfix3 postfix3-mysql -y'
ProcessUtilities.executioner(command)
else:
+
+
import socket
command = 'apt-get install -y debconf-utils'
ProcessUtilities.executioner(command)
@@ -856,12 +881,13 @@ class MailServerManagerUtils(multi.Thread):
if ProcessUtilities.decideDistro() == ProcessUtilities.centos:
command = 'yum --enablerepo=gf-plus -y install dovecot23 dovecot23-mysql'
+ ProcessUtilities.executioner(command)
elif ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
command = 'dnf install --enablerepo=gf-plus dovecot23 dovecot23-mysql -y'
+ ProcessUtilities.executioner(command)
else:
- command = 'apt-get -y install dovecot-mysql dovecot-imapd dovecot-pop3d'
-
- ProcessUtilities.executioner(command)
+ command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install dovecot-mysql dovecot-imapd dovecot-pop3d'
+ os.system(command)
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
'Postfix/dovecot reinstalled.,40')
@@ -1238,6 +1264,15 @@ class MailServerManagerUtils(multi.Thread):
command = "systemctl restart dovecot"
ProcessUtilities.executioner(command)
+
+ ## For ubuntu 20
+
+ if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20:
+
+ command = "sed -i 's|daemon_directory = /usr/libexec/postfix|daemon_directory = /usr/lib/postfix/sbin|g' /etc/postfix/main.cf"
+ ProcessUtilities.executioner(command)
+
+
except BaseException as msg:
logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'],
'%s [setup_postfix_dovecot_config][404]' % (
@@ -1574,7 +1609,6 @@ milter_default_action = accept
return 1, 'All checks are OK.'
-
def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
diff --git a/plogical/sslUtilities.py b/plogical/sslUtilities.py
index af96da488..d8477d601 100755
--- a/plogical/sslUtilities.py
+++ b/plogical/sslUtilities.py
@@ -298,7 +298,7 @@ class sslUtilities:
command = acmePath + " --issue -d " + virtualHostName + " -d www." + virtualHostName \
+ ' --cert-file ' + existingCertPath + '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
- + ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
+ + ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --server letsencrypt --force'
logging.CyberCPLogFileWriter.writeToFile(command, 0)
@@ -319,7 +319,7 @@ class sslUtilities:
logging.CyberCPLogFileWriter.writeToFile("Trying to obtain SSL for: " + virtualHostName, 0)
command = acmePath + " --issue -d " + virtualHostName + ' --cert-file ' + existingCertPath \
+ '/cert.pem' + ' --key-file ' + existingCertPath + '/privkey.pem' \
- + ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --force'
+ + ' --fullchain-file ' + existingCertPath + '/fullchain.pem' + ' -w ' + sslpath + ' --server letsencrypt --force'
output = subprocess.check_output(shlex.split(command)).decode("utf-8")
logging.CyberCPLogFileWriter.writeToFile("Successfully obtained SSL for: " + virtualHostName, 0)
finalText = '%s\nSuccessfully obtained SSL for: %s.' % (finalText, virtualHostName)
diff --git a/plogical/upgrade.py b/plogical/upgrade.py
index 2033d3515..e0c856986 100755
--- a/plogical/upgrade.py
+++ b/plogical/upgrade.py
@@ -455,8 +455,8 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
count = count + 1
if count == 3:
break
- else:
- break
+ else:
+ break
######
iPath = os.listdir('/usr/local/CyberCP/public/rainloop/rainloop/v/')
@@ -2074,6 +2074,8 @@ echo $oConfig->Save() ? 'Done' : 'Error';
def AutoUpgradeAcme():
command = '/root/.acme.sh/acme.sh --upgrade --auto-upgrade'
Upgrade.executioner(command, command, 0)
+ command = '/root/.acme.sh/acme.sh --set-default-ca --server letsencrypt'
+ Upgrade.executioner(command, command, 0)
@staticmethod
def installPHP73():
@@ -2398,7 +2400,7 @@ vmail
0 2 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/upgradeCritical.py >/dev/null 2>&1
0 2 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/renew.py >/dev/null 2>&1
7 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
-0 12 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily
+0 0 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily
0 0 * * 0 /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Weekly
"""
writeToFile = open(cronPath, 'w')
diff --git a/requirments.txt b/requirments.txt
index f6a90de14..10a99b6d2 100755
--- a/requirments.txt
+++ b/requirments.txt
@@ -81,11 +81,4 @@ uritemplate==3.0.1
urllib3==1.25.11
validators==0.18.1
wcwidth==0.2.5
-websocket-client==0.57.0
-zope.component==4.6.2
-zope.deferredimport==4.3.1
-zope.deprecation==4.4.0
-zope.event==4.5.0
-zope.hookable==5.0.1
-zope.interface==5.2.0
-zope.proxy==4.3.5
\ No newline at end of file
+websocket-client==0.57.0
\ No newline at end of file
diff --git a/serverStatus/views.py b/serverStatus/views.py
index 47fafb400..7e26e9759 100755
--- a/serverStatus/views.py
+++ b/serverStatus/views.py
@@ -33,7 +33,6 @@ def serverStatusHome(request):
None, 'admin')
return proc.render()
-
def litespeedStatus(request):
try:
userID = request.session['userID']
@@ -152,7 +151,6 @@ def getFurtherDataFromLogFile(request):
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[getFurtherDataFromLogFile]")
return HttpResponse("Not Logged in as admin")
-
def services(request):
data = {}
diff --git a/static/baseTemplate/assets/themes/admin/layout.css b/static/baseTemplate/assets/themes/admin/layout.css
index 5b602b8dc..704e7c221 100755
--- a/static/baseTemplate/assets/themes/admin/layout.css
+++ b/static/baseTemplate/assets/themes/admin/layout.css
@@ -528,9 +528,9 @@ body #nav-toggle.collapsed span {
width: 100px;
}
.closed-sidebar #header-logo .logo-content-small {
- width: 62px;
+ width: 50px;
margin-left: 0;
- left: 0px;
+ left: 15px;
display: block;
}
.closed-sidebar #header-logo .logo-content-big {
diff --git a/websiteFunctions/StagingSetup.py b/websiteFunctions/StagingSetup.py
index ab18d7f08..349f2f4f6 100644
--- a/websiteFunctions/StagingSetup.py
+++ b/websiteFunctions/StagingSetup.py
@@ -252,15 +252,6 @@ class StagingSetup(multi.Thread):
logging.statusWriter(tempStatusPath, 'Completed,[200]')
- http = []
- finalHTTP = []
-
- for items in http:
- if items.find('x-litespeed-cache') > -1 or items.find('x-lsadc-cache') > -1 or items.find('x-qc-cache') > -1:
- finalHTTP.append('
%s' % (items))
- else:
- finalHTTP.append(items)
-
return 0
except BaseException as msg:
mesg = '%s. [404]' % (str(msg))
diff --git a/websiteFunctions/models.py b/websiteFunctions/models.py
index e6a705e98..6aabe3359 100755
--- a/websiteFunctions/models.py
+++ b/websiteFunctions/models.py
@@ -11,8 +11,8 @@ from datetime import datetime
class Websites(models.Model):
admin = models.ForeignKey(Administrator, on_delete=models.PROTECT)
package = models.ForeignKey(Package, on_delete=models.PROTECT)
- domain = models.CharField(max_length=50,unique=True)
- adminEmail = models.CharField(max_length=50)
+ domain = models.CharField(max_length=255,unique=True)
+ adminEmail = models.CharField(max_length=255)
phpSelection = models.CharField(max_length=10)
ssl = models.IntegerField()
state = models.IntegerField(default=1)