Merge branch 'v2.1.1' into v2.1.1-usman

This commit is contained in:
Usman Nasir
2021-06-29 20:35:38 +05:00
25 changed files with 310 additions and 134 deletions

View File

@@ -194,7 +194,7 @@ fixperms_cyberpanel () {
echo "Fixing public_html...."
tput sgr0
#Fix perms of public_html itself
chown "$verbose" "$account":"$account" "$HOMEDIR"/public_html
chown "$verbose" "$account":nobody "$HOMEDIR"/public_html
chmod "$verbose" 755 "$HOMEDIR"/public_html
tput bold

View File

@@ -10,6 +10,12 @@ class secMiddleware:
HIGH = 0
LOW = 1
def get_client_ip(request):
ip = request.META.get('HTTP_CF_CONNECTING_IP')
if ip is None:
ip = request.META.get('REMOTE_ADDR')
return ip
def __init__(self, get_response):
self.get_response = get_response
@@ -17,7 +23,7 @@ class secMiddleware:
try:
uID = request.session['userID']
admin = Administrator.objects.get(pk=uID)
ipAddr = request.META.get('REMOTE_ADDR')
ipAddr = get_client_ip(request)
if ipAddr.find('.') > -1:
if request.session['ipAddr'] == ipAddr or admin.securityLevel == secMiddleware.LOW:
@@ -25,20 +31,19 @@ class secMiddleware:
else:
del request.session['userID']
del request.session['ipAddr']
logging.writeToFile(request.META.get('REMOTE_ADDR'))
logging.writeToFile(get_client_ip(request))
final_dic = {'error_message': "Session reuse detected, IPAddress logged.",
"errorMessage": "Session reuse detected, IPAddress logged."}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
else:
ipAddr = request.META.get('REMOTE_ADDR').split(':')[:3]
ipAddr = get_client_ip(request).split(':')[:3]
if request.session['ipAddr'] == ipAddr or admin.securityLevel == secMiddleware.LOW:
pass
else:
del request.session['userID']
del request.session['ipAddr']
logging.writeToFile(request.META.get('REMOTE_ADDR'))
logging.writeToFile(get_client_ip(request))
final_dic = {'error_message': "Session reuse detected, IPAddress logged.",
"errorMessage": "Session reuse detected, IPAddress logged."}
final_json = json.dumps(final_dic)

View File

@@ -696,7 +696,7 @@ class BackupManager:
finalDic['port'] = "22"
try:
finalDic['user'] = data['user']
finalDic['user'] = data['userName']
except:
finalDic['user'] = "root"

View File

@@ -22,7 +22,6 @@
</h3>
<div class="example-box-wrapper">
<form action="/" class="form-horizontal bordered-row">

View File

@@ -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 {

View File

@@ -90,7 +90,8 @@
<link rel="stylesheet" type="text/css" href="{% static 'baseTemplate/custom-js/pnotify.custom.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'websiteFunctions/websiteFunctions.css' %}">
<link rel="icon" type="image/png" href="{% static 'baseTemplate/assets/finalBase/favicon.png' %}">
<link type="text/css" href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet"/>
<link type="text/css" href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css"
rel="stylesheet"/>
{% block styles %}
{% endblock %}
@@ -115,11 +116,6 @@
<body>
<div id="sb-site">
<!------- ng-controller="systemStatusInfo" ------------>
<div class="sb-slidebar bg-black sb-right sb-style-overlay">
<div class="scrollable-content scrollable-slim-sidebar">
@@ -174,7 +170,6 @@
</div>
</div>
<div id="loading">
<div class="spinner">
<div class="bounce1"></div>
@@ -203,60 +198,20 @@
<i class="glyph-icon icon-angle-left"></i>
</a>
</div>
<div id="header-nav-left">
<div ng-controller="adminController" class="user-account-btn dropdown">
<a href="#" title="{% trans 'My Account' %}" class="user-profile clearfix"
data-toggle="dropdown">
<img width="28" src="{% static 'baseTemplate/assets/image-resources/gravatar.png' %}"
alt="Profile image">
<span>{$ currentAdmin $}</span>
<i class="glyph-icon icon-angle-down"></i>
</a>
<div class="dropdown-menu float-left">
<div class="box-sm">
<div class="login-box clearfix">
<div class="user-img">
<a href="#" title="{% trans '' %}" class="change-img">Change photo</a>
<img src="{% static 'baseTemplate/assets/image-resources/gravatar.png' %}"
alt="">
</div>
<div class="user-info">
<span>
{$ currentAdmin $}
<i>{$ admin_type $}</i>
</span>
<a href="{% url 'modifyUsers' %}"
title="{% trans 'Edit profile' %}">{% trans "Edit profile" %}</a>
<a href="{% url 'viewProfile' %}"
title="{% trans 'View Profile' %}">{% trans "View Profile" %}</a>
</div>
</div>
<div class="divider"></div>
<div class="pad5A button-pane button-pane-alt text-center">
<a href="{% url 'logout' %}" class="btn display-block font-normal btn-danger">
<i class="glyph-icon icon-power-off"></i>
{% trans "Logout" %}
</a>
</div>
</div>
</div>
</div>
</div><!-- #header-nav-left -->
<div ng-controller="loadAvg" id="header-nav-right">
<a class="hide-on-phone" style="background-color: none;width: 33px" href="#" class="hdr-btn"
<a class="hide-on-phone" style="background-color: unset;width: 33px" href="#" class="hdr-btn"
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
<span class="badge bg-yellow">{$ one $}</span>
</a>
<a class="hide-on-phone" style="background-color: none;width: 33px" href="#" class="hdr-btn"
<a class="hide-on-phone" style="background-color: unset;width: 33px" href="#" class="hdr-btn"
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
<span class="badge bg-yellow">{$ two $}</span>
</a>
<a class="hide-on-phone" style="background-color: none;width: 33px" href="#" class="hdr-btn"
<a class="hide-on-phone" style="background-color: unset;width: 33px" href="#" class="hdr-btn"
title="{% trans 'CPU Load Average' %}" data-placement="bottom">
<span class="badge bg-yellow">{$ three $}</span>
</a>
@@ -324,20 +279,19 @@
</a>
</div><!-- #header-nav-right -->
</div>
<!-- #header-nav-right -->
</div>
<div id="page-sidebar">
<div class="scroll-sidebar">
<ul id="sidebar-menu">
<li class="header"><span>{% trans "Overview" %}</span></li>
<li>
<a href="#" title="{% trans 'Server IP Address' %}">
<i class="glyph-icon tooltip-button icon-laptop" title="{% trans 'Server IP Address' %}"
data-original-title=".icon-laptop"></i>
<span style="color: #db6868;font-weight: bold;" id="serverIPAddress"></span>
<span style="color: #db6868;font-weight: bold;">{{ ipAddress }}</span>
</a>
<a href="{% url 'index' %}" title="{% trans 'Dashboard' %}">
<i class="glyph-icon icon-dashboard"></i>
@@ -711,7 +665,7 @@
{% endif %}
</ul>
</div><!-- .sidebar-submenu -->
</div>
</li>
@@ -740,7 +694,7 @@
{% endif %}
</ul>
</div><!-- .sidebar-submenu -->
</div>
</li>
{% if admin %}
@@ -1047,10 +1001,8 @@
{% endif %}
</ul><!-- #sidebar-menu -->
</div>
</div>
<div id="page-content-wrapper">
<div id="page-content">
@@ -1061,13 +1013,8 @@
</div>
</div>
</div>
<!-- WIDGETS -->
<!-- Sparklines charts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script src="{% static 'baseTemplate/custom-js/pnotify.custom.min.js' %}"></script>
@@ -1084,7 +1031,6 @@
<script src="{% static 'serverLogs/serverLogs.js' %}?ver={{ version }}"></script>
<script src="{% static 'emailPremium/emailPremium.js' %}?ver={{ version }}"></script>
<script src="{% static 'emailMarketing/emailMarketing.js' %}?ver={{ version }}"></script>
<script type="text/javascript" src="{% static 'baseTemplate/assets/finalJS/final.js' %}"></script>
<script src="{% static 'backup/backup.js' %}?ver={{ version }}"></script>
<script src="{% static 'managePHP/managePHP.js' %}?ver={{ version }}"></script>

View File

@@ -66,6 +66,8 @@ def getAdminStatus(request):
def getSystemStatus(request):
try:
val = request.session['userID']
currentACL = ACLManager.loadedACL(val)
HTTPData = SystemInformation.getSystemInformation()
json_data = json.dumps(HTTPData)
return HttpResponse(json_data)

View File

@@ -73,6 +73,15 @@ Panel_Version=${Temp_Value:12:3}
Panel_Build=${Temp_Value:25:1}
Branch_Name="v${Panel_Version}.${Panel_Build}"
if [[ $Branch_Name = v*.*.* ]] ; then
echo -e "\nBranch name fetched...$Branch_Name"
else
echo -e "\nUnable to fetch Branch name..."
echo -e "\nPlease try again in few moments, if this error still happens, please contact support"
exit
fi
Base_Number="1.9.3"
Total_RAM=$(free -m | awk '/Mem:/ { print $2 }')
@@ -165,12 +174,7 @@ Retry_Command() {
# shellcheck disable=SC2034
for i in {1..50};
do
if [[ "$i" = "50" ]] ; then
echo "command $1 failed for 50 times, exit..."
exit 2
else
$1 && break || echo -e "\n$1 has failed for $i times\nWait for 3 seconds and try again...\n"; sleep 3;
fi
done
}
@@ -234,6 +238,16 @@ if [[ ! -f /etc/os-release ]] ; then
exit
fi
# Reference: https://unix.stackexchange.com/questions/116539/how-to-detect-the-desktop-environment-in-a-bash-script
if [ -z "$XDG_CURRENT_DESKTOP" ]; then
echo "Desktop OS not detected. Proceeding"
else
echo "$XDG_CURRENT_DESKTOP defined appears to be a desktop OS. Bailing as CyberPanel is incompatible."
echo -e "\nCyberPanel is supported on server OS types only. Such as Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, Ubuntu 20.10 x86_64, CentOS 7.x, CentOS 8.x, AlmaLinux 8.x and CloudLinux 7.x...\n"
exit
fi
if ! uname -m | grep -q 64 ; then
echo -e "x64 system is required...\n"
exit
@@ -462,7 +476,7 @@ else
Admin_Pass="1234567"
else
if [[ ${#1} -lt 8 ]]; then
echo -e "\nPassword lenth less than 8 digital, please choose a more complicated password.\n"
echo -e "\nPassword length less than 8 digital, please choose a more complicated password.\n"
exit
fi
Admin_Pass="${1}"
@@ -720,7 +734,7 @@ elif [[ $Tmp_Input =~ ^(s|S) ]]; then
exit
fi
if [[ ${#Tmp_Input} -lt 8 ]]; then
echo -e "\nPassword lenth less than 8 digital, please choose a more complicated password.\n"
echo -e "\nPassword length less than 8 digital, please choose a more complicated password.\n"
exit
fi
Tmp_Input1=$Tmp_Input
@@ -964,7 +978,7 @@ if [[ "$Server_OS" = "CentOS" ]] ; then
yum -y groupinstall development
Check_Return
elif [[ "$Server_OS_Version" = "8" ]] ; then
dnf install -y zip wget strace net-tools curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-devel curl-devel git platform-python-devel tar socat python3 zip unzip bind-utils
dnf install -y libnsl zip wget strace net-tools curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-devel curl-devel git platform-python-devel tar socat python3 zip unzip bind-utils
Check_Return
dnf install -y gpgme-devel
Check_Return
@@ -995,7 +1009,7 @@ else
update-locale LC_ALL="en_US.UTF-8"
fi
Debug_Log2 "Installing required virtual enviroment,3"
Debug_Log2 "Installing required virtual environment,3"
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
@@ -1042,7 +1056,7 @@ Debug_Log2 "Necessary components installed..,5"
}
Pre_Install_System_Tweak() {
Debug_Log2 "Setting up sytem tweak...,20"
Debug_Log2 "Setting up system tweak...,20"
Line_Number=$(grep -n "127.0.0.1" /etc/hosts | cut -d: -f 1)
My_Hostname=$(hostname)
@@ -1100,12 +1114,6 @@ if ! grep -q "pid_max" /etc/rc.local 2>/dev/null ; then
echo "echo 1000000 > /proc/sys/kernel/pid_max
echo 1 > /sys/kernel/mm/ksm/run" >>/etc/rc.local
chmod +x /etc/rc.local
fi
if grep -q "nf_conntrack_max" /etc/sysctl.conf ; then
sysctl -w net.netfilter.nf_conntrack_max=2097152 > /dev/null
sysctl -w net.nf_conntrack_max=2097152 > /dev/null
echo "net.netfilter.nf_conntrack_max=2097152" >> /etc/sysctl.conf
echo "net.nf_conntrack_max=2097152" >> /etc/sysctl.conf
fi
echo "fs.file-max = 65535" >>/etc/sysctl.conf
sysctl -p >/dev/null
@@ -1214,8 +1222,8 @@ else
fi
if ./lshttpd -V |& grep "ERROR" || ./lshttpd -V |& grep "expire in 0 days" ; then
echo -e "\n\nIt apeears to have some issue with license , please check above result..."
Debug_Log2 "It appears to have some issue with LiteSpeed License, make sure you are using correct serial key. [404]"
echo -e "\n\nThere appears to be an issue with license , please check above result..."
Debug_Log2 "There appears to be an issue with LiteSpeed License, make sure you are using correct serial key. [404]"
exit
fi
@@ -1832,6 +1840,7 @@ fi
# If valid hostname is set that resolves externally we can issue an ssl. This will create the hostname as a website so we can issue the SSL and do our first login without SSL warnings or exceptions needed.
HostName=$(hostname --fqdn); [ -n "$(dig @1.1.1.1 +short "$HostName")" ] && echo "$HostName resolves to valid IP. Setting up hostname SSL" && cyberpanel createWebsite --package Default --owner admin --domainName $(hostname --fqdn) --email root@localhost --php 7.4 && cyberpanel hostNameSSL --domainName $(hostname --fqdn)
}
Post_Install_CN_Replacement() {

View File

@@ -41,7 +41,7 @@
<nav id="navBar" class="navbar navbar-expand-lg navbar-light bg-light">
<div class="header-logo">
<a href="#"><img src="{% static 'filemanager/images/fileManager.png' %}"> <span style="display: none" id="domainNameInitial">{{ domainName }}</span></a>
<a href="/websites/{{ domainName }}"><img src="{% static 'filemanager/images/fileManager.png' %}"> <span style="display: none" id="domainNameInitial">{{ domainName }}</span></a>
</div>
<!--- second bar ---->

View File

@@ -1680,7 +1680,7 @@ imap_folder_list_limit = 0
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
*/3 * * * * if ! find /home/*/public_html/ -maxdepth 2 -type f -newer /usr/local/lsws/cgid -name '.htaccess' -exec false {} +; then /usr/local/lsws/bin/lswsctrl restart; fi
"""
@@ -2214,7 +2214,7 @@ def main():
distro = get_distro()
checks = preFlightsChecks("/usr/local/lsws/", args.publicip, "/usr/local", cwd, "/usr/local/CyberCP", distro,
remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport)
#checks.mountTemp()
checks.mountTemp()
if args.port == None:
port = "8090"

View File

@@ -139,6 +139,8 @@ SecFilterSelective ARGS &quot;or.+1[[:space:]]*=[[:space:]]1|or 1=1--'|'.+--&quo
SecFilterSelective ARGS &quot;into[[:space:]]+outfile|load[[:space:]]+data|/\*.+\*/&quot;</ruleSet>
</censorshipRuleSet>
<bubbleWrap>1</bubbleWrap>
<bubbleWrapCmd>/bin/bwrap --ro-bind /usr /usr --ro-bind /lib /lib --ro-bind-try /lib64 /lib64 --ro-bind /bin /bin --ro-bind /sbin /sbin --dir /var --ro-bind-try /var/www /var/www --dir /tmp --proc /proc --symlink../tmp var/tmp --dev /dev --ro-bind-try /etc/localtime /etc/localtime --ro-bind-try /etc/ld.so.cache /etc/ld.so.cache --ro-bind-try /etc/resolv.conf /etc/resolv.conf --ro-bind-try /etc/ssl /etc/ssl --ro-bind-try /etc/pki /etc/pki --ro-bind-try /etc/man_db.conf /etc/man_db.conf --ro-bind-try /usr/local/bin/msmtp /etc/alternatives/mta --ro-bind-try /usr/local/bin/msmtp /usr/sbin/exim --bind-try $HOMEDIR $HOMEDIR --bind-try /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock --bind-try /home/mysql/mysql.sock /home/mysql/mysql.sock --bind-try /tmp/mysql.sock /tmp/mysql.sock --bind-try /run/mysqld/mysqld.sock /run/mysqld/mysqld.sock --bind-try /var/run/mysqld/mysqld.sock /var/run/mysqld/mysqld.sock '$COPY-TRY /etc/exim.jail/$USER.conf $HOMEDIR/.msmtprc' --unshare-all --share-net --die-with-parent --dir /run/user/$UID $PASSWD 65534 $GROUP 65534</bubbleWrapCmd>
<accessDenyDir>
<dir>/</dir>
<dir>/etc/*</dir>

View File

@@ -10,7 +10,7 @@
<div class="container">
<div id="page-title">
<h2>{% trans "List Email Accounts" %}
<h2>{% trans "List Email Accounts" %} - <a target="_blank" href="https://go.cyberpanel.net/DebugEmail" style="height: 23px;line-height: 21px;" class="btn btn-border btn-alt border-red btn-link font-red" title=""><span>{% trans "Debug Email Issues" %}</span></a>
<a class="pull-right btn btn-primary" href="{% url "createEmailAccount" %}">{% trans "Create Email" %}</a>
</h2>
<p>{% trans "List Emails Accounts. Change their passwords or delete them." %}</p>

View File

@@ -18,7 +18,11 @@ def managePowerDNS(request):
data = {}
data['status'] = 1
try:
pdnsStatus = PDNSStatus.objects.get(pk=1)
except:
pdnsStatus = PDNSStatus(type='NATIVE', serverStatus=1)
pdnsStatus.save()
if pdnsStatus.type == 'MASTER':
counter = 1

View File

@@ -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

View File

@@ -238,6 +238,5 @@ def main():
if __name__ == "__main__":
main()

View File

@@ -121,7 +121,7 @@ class FTPUtilities:
path = path.lstrip("/")
if path != 'None':
path = "/home/" + domainName + "/public_html/" + path
path = "/home/" + domainName + "/" + path
## Security Check

View File

@@ -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)

View File

@@ -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'
else:
command = 'apt-get -y install dovecot-mysql dovecot-imapd dovecot-pop3d'
ProcessUtilities.executioner(command)
else:
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')

View File

@@ -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)

View File

@@ -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')

View File

@@ -82,10 +82,3 @@ 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

View File

@@ -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 = {}

View File

@@ -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 {

View File

@@ -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('<strong>%s</strong>' % (items))
else:
finalHTTP.append(items)
return 0
except BaseException as msg:
mesg = '%s. [404]' % (str(msg))

View File

@@ -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)