mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
Bug fixes to ACL
This commit is contained in:
@@ -71,9 +71,7 @@ class cyberPanel:
|
||||
|
||||
def deleteWebsite(self, domainName):
|
||||
try:
|
||||
|
||||
numberOfWebsites = Websites.objects.count() + ChildDomains.objects.count()
|
||||
vhost.deleteVirtualHostConfigurations(domainName, numberOfWebsites)
|
||||
vhost.deleteVirtualHostConfigurations(domainName)
|
||||
self.printStatus(1, 'None')
|
||||
|
||||
except BaseException, msg:
|
||||
|
||||
1299
firewall/views.py
1299
firewall/views.py
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ django.setup()
|
||||
from loginSystem.models import Administrator, ACL
|
||||
from django.shortcuts import HttpResponse
|
||||
from packages.models import Package
|
||||
from websiteFunctions.models import Websites
|
||||
from websiteFunctions.models import Websites, ChildDomains
|
||||
from dns.models import Domains
|
||||
import json
|
||||
|
||||
@@ -104,6 +104,18 @@ class ACLManager:
|
||||
|
||||
return finalResponse
|
||||
|
||||
@staticmethod
|
||||
def currentContextPermission(currentACL, context):
|
||||
try:
|
||||
if currentACL['admin'] == 1:
|
||||
return 1
|
||||
elif currentACL[context] == 1:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
except:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def createDefaultACLs():
|
||||
try:
|
||||
@@ -372,17 +384,29 @@ class ACLManager:
|
||||
@staticmethod
|
||||
def checkOwnership(domain, admin, currentACL):
|
||||
|
||||
domainName = Websites.objects.get(domain=domain)
|
||||
try:
|
||||
childDomain = ChildDomains.objects.get(domain=domain)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
return 1
|
||||
elif domainName.admin == admin:
|
||||
return 1
|
||||
else:
|
||||
if domainName.admin.owner == admin.pk:
|
||||
if currentACL['admin'] == 1:
|
||||
return 1
|
||||
elif childDomain.master.admin == admin:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
if childDomain.master.admin.owner == admin.pk:
|
||||
return 1
|
||||
|
||||
except:
|
||||
domainName = Websites.objects.get(domain=domain)
|
||||
|
||||
if currentACL['admin'] == 1:
|
||||
return 1
|
||||
elif domainName.admin == admin:
|
||||
return 1
|
||||
else:
|
||||
if domainName.admin.owner == admin.pk:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -590,8 +590,7 @@ class ApplicationInstaller(multi.Thread):
|
||||
|
||||
command = 'sudo GIT_SSH_COMMAND="ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" git clone ' \
|
||||
'--depth 1 --no-single-branch git@' + defaultProvider +'.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath
|
||||
result = subprocess.check_output(shlex.split(command))
|
||||
|
||||
subprocess.check_output(shlex.split(command))
|
||||
except subprocess.CalledProcessError, msg:
|
||||
statusFile = open(tempStatusPath, 'w')
|
||||
statusFile.writelines('Failed to clone repository, make sure you deployed your key to repository. [404]')
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/usr/local/CyberCP/bin/python2
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import django
|
||||
sys.path.append('/usr/local/CyberCP')
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||
django.setup()
|
||||
from websiteFunctions.models import Websites
|
||||
import json
|
||||
|
||||
|
||||
class ChildDomainManager:
|
||||
def __init__(self, masterDomain = None, childDomain = None):
|
||||
self.masterDomain = masterDomain
|
||||
self.childDomain = childDomain
|
||||
|
||||
def findChildDomainsJson(self):
|
||||
master = Websites.objects.get(domain=self.masterDomain)
|
||||
childDomains = master.childdomains_set.all()
|
||||
|
||||
json_data = "["
|
||||
checker = 0
|
||||
|
||||
for items in childDomains:
|
||||
dic = {
|
||||
'childDomain': items.domain,
|
||||
'path': items.path,
|
||||
'childLunch': '/websites/' + self.masterDomain + '/' + items.domain
|
||||
}
|
||||
|
||||
if checker == 0:
|
||||
json_data = json_data + json.dumps(dic)
|
||||
checker = 1
|
||||
else:
|
||||
json_data = json_data + ',' + json.dumps(dic)
|
||||
|
||||
json_data = json_data + ']'
|
||||
|
||||
return json_data
|
||||
1176
plogical/firewallManager.py
Normal file
1176
plogical/firewallManager.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -336,7 +336,7 @@ WantedBy=multi-user.target"""
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
|
||||
passwordCMD = "use " + dbName + ";insert into loginSystem_acl (id, name) values (3,'user');"
|
||||
passwordCMD = "use " + dbName + ";insert into loginSystem_acl (id, name, createDatabase, deleteDatabase, listDatabases, createDNSZone, deleteZone, addDeleteRecords, createEmail, deleteEmail, emailForwarding, changeEmailPassword, dkimManager, createFTPAccount, deleteFTPAccount, listFTPAccounts, createBackup, manageSSL) values (3,'user', 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);"
|
||||
command = 'sudo mysql --host=' + host + ' --port=' + port + ' -u ' + dbUser + ' -p' + password + ' -e "' + passwordCMD + '"'
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
@@ -351,6 +351,11 @@ WantedBy=multi-user.target"""
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
|
||||
passwordCMD = "use " + dbName + ";alter table loginSystem_administrator drop initUserAccountsLimit;"
|
||||
command = 'sudo mysql --host=' + host + ' --port=' + port + ' -u ' + dbUser + ' -p' + password + ' -e "' + passwordCMD + '"'
|
||||
cmd = shlex.split(command)
|
||||
subprocess.call(cmd)
|
||||
|
||||
os.chdir(cwd)
|
||||
|
||||
except OSError, msg:
|
||||
|
||||
@@ -452,11 +452,12 @@ RewriteFile .htaccess
|
||||
return [0,"223 [IO Error with main config file [createConfigInMainVirtualHostFile]]"]
|
||||
|
||||
@staticmethod
|
||||
def deleteVirtualHostConfigurations(virtualHostName, numberOfSites):
|
||||
def deleteVirtualHostConfigurations(virtualHostName):
|
||||
|
||||
try:
|
||||
|
||||
## Deleting master conf
|
||||
numberOfSites = str(Websites.objects.count() + ChildDomains.objects.count())
|
||||
vhost.deleteCoreConf(virtualHostName, numberOfSites)
|
||||
|
||||
delWebsite = Websites.objects.get(domain=virtualHostName)
|
||||
@@ -999,4 +1000,5 @@ RewriteFile .htaccess
|
||||
except BaseException, msg:
|
||||
logging.CyberCPLogFileWriter.writeToFile(
|
||||
str(msg) + "223 [IO Error with main config file [createConfigInMainDomainHostFile]]")
|
||||
return [0, "223 [IO Error with main config file [createConfigInMainDomainHostFile]]"]
|
||||
return [0, "223 [IO Error with main config file [createConfigInMainDomainHostFile]]"]
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from os.path import join
|
||||
from os import listdir, rmdir
|
||||
from shutil import move
|
||||
from multiprocessing import Process
|
||||
from websiteFunctions.models import Websites, ChildDomains
|
||||
from websiteFunctions.models import Websites, ChildDomains, aliasDomains
|
||||
from loginSystem.models import Administrator
|
||||
from packages.models import Package
|
||||
import subprocess
|
||||
@@ -137,8 +137,7 @@ class virtualHostUtilities:
|
||||
return 1, 'None'
|
||||
|
||||
except BaseException, msg:
|
||||
numberOfWebsites = str(Websites.objects.count() + ChildDomains.objects.count())
|
||||
vhost.deleteVirtualHostConfigurations(virtualHostName, numberOfWebsites)
|
||||
vhost.deleteVirtualHostConfigurations(virtualHostName)
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createVirtualHost]")
|
||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, str(msg) + " [404]")
|
||||
return 0, str(msg)
|
||||
@@ -597,10 +596,14 @@ class virtualHostUtilities:
|
||||
else:
|
||||
vhost.createAliasSSLMap(confPath, masterDomain, aliasDomain)
|
||||
|
||||
website = Websites.objects.get(domain=masterDomain)
|
||||
|
||||
newAlias = aliasDomains(master=website, aliasDomain = aliasDomain)
|
||||
newAlias.save()
|
||||
|
||||
print "1,None"
|
||||
|
||||
except BaseException, msg:
|
||||
|
||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [createAlias]")
|
||||
print "0," + str(msg)
|
||||
|
||||
@@ -664,6 +667,9 @@ class virtualHostUtilities:
|
||||
writeToFile.close()
|
||||
installUtilities.installUtilities.reStartLiteSpeed()
|
||||
|
||||
delAlias = aliasDomains.objects.get(aliasDomain=aliasDomain)
|
||||
delAlias.delete()
|
||||
|
||||
print "1,None"
|
||||
|
||||
|
||||
@@ -1018,7 +1024,7 @@ def main():
|
||||
|
||||
virtualHostUtilities.createVirtualHost(args.virtualHostName, args.administratorEmail, args.phpVersion, args.virtualHostUser, int(args.ssl), dkimCheck, openBasedir, args.websiteOwner, args.package, tempStatusPath)
|
||||
elif args.function == "deleteVirtualHostConfigurations":
|
||||
vhost.deleteVirtualHostConfigurations(args.virtualHostName,int(args.numberOfSites))
|
||||
vhost.deleteVirtualHostConfigurations(args.virtualHostName)
|
||||
elif args.function == "createDomain":
|
||||
try:
|
||||
dkimCheck = int(args.dkimCheck)
|
||||
|
||||
1942
plogical/website.py
Normal file
1942
plogical/website.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,9 +6,7 @@ from django.http import HttpResponse
|
||||
import json
|
||||
import plogical.CyberCPLogFileWriter as logging
|
||||
from plogical.tuning import tuning
|
||||
from loginSystem.models import Administrator
|
||||
from loginSystem.views import loadLoginPage
|
||||
from websiteFunctions.models import Websites,ChildDomains
|
||||
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||
import subprocess
|
||||
import shlex
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user