Skip to content
Permalink
Browse files

bug fix in zone listing

  • Loading branch information...
usmannasir committed Aug 16, 2019
1 parent d495ce4 commit afdbc36df53588eb494cf699f62261a292b25390
Showing with 61 additions and 143 deletions.
  1. +40 −137 dns/dnsManager.py
  2. +19 −6 plogical/acl.py
  3. +2 −0 websiteFunctions/StagingSetup.py
@@ -50,146 +50,49 @@ def NSCreation(self, userID = None, data = None):
if ACLManager.currentContextPermission(currentACL, 'createNameServer') == 0:
return ACLManager.loadErrorJson('NSCreation', 0)


domainForNS = data['domainForNS']
ns1 = data['ns1']
ns2 = data['ns2']
firstNSIP = data['firstNSIP']
secondNSIP = data['secondNSIP']

if Domains.objects.filter(name=domainForNS).count() == 0:
DNS.dnsTemplate(domainForNS, admin)

newZone = Domains.objects.get(name=domainForNS)

## NS1


record = Records(domainOwner=newZone,
domain_id=newZone.id,
name=ns1,
type="A",
content=firstNSIP,
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()

## NS2

record = Records(domainOwner=newZone,
domain_id=newZone.id,
name=ns2,
type="A",
content=secondNSIP,
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()

final_dic = {'NSCreation': 1, 'error_message': "None"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)

try:
pdns = PDNSStatus.objects.get(pk=1)
if pdns.type == 'MASTER':
newZone = Domains(admin=admin, name=domainForNS, type="MASTER")
else:
newZone = Domains(admin=admin, name=domainForNS, type="NATIVE")
except:
newZone = Domains(admin=admin, name=domainForNS, type="NATIVE")

newZone.save()

content = "ns1." + domainForNS + " hostmaster." + domainForNS + " 1 10800 3600 604800 3600"

soaRecord = Records(domainOwner=newZone,
domain_id=newZone.id,
name=domainForNS,
type="SOA",
content=content,
ttl=3600,
prio=0,
disabled=0,
auth=1)
soaRecord.save()

## NS1

record = Records(domainOwner=newZone,
domain_id=newZone.id,
name=domainForNS,
type="NS",
content=ns1,
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()

record = Records(domainOwner=newZone,
domain_id=newZone.id,
name=ns1,
type="A",
content=firstNSIP,
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()

## NS2


record = Records(domainOwner=newZone,
domain_id=newZone.id,
name=domainForNS,
type="NS",
content=ns2,
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()

record = Records(domainOwner=newZone,
domain_id=newZone.id,
name=ns2,
type="A",
content=secondNSIP,
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()

final_dic = {'NSCreation': 1, 'error_message': "None"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
else:

newZone = Domains.objects.get(name=domainForNS)

## NS1

record = Records(domainOwner=newZone,
domain_id=newZone.id,
name=domainForNS,
type="NS",
content=ns1,
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()

record = Records(domainOwner=newZone,
domain_id=newZone.id,
name=ns1,
type="A",
content=firstNSIP,
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()

## NS2


record = Records(domainOwner=newZone,
domain_id=newZone.id,
name=domainForNS,
type="NS",
content=ns2,
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()

record = Records(domainOwner=newZone,
domain_id=newZone.id,
name=ns2,
type="A",
content=secondNSIP,
ttl=3600,
prio=0,
disabled=0,
auth=1)
record.save()

final_dic = {'NSCreation': 1, 'error_message': "None"}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)
except BaseException, msg:
final_dic = {'NSCreation': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
@@ -273,7 +176,7 @@ def getCurrentRecordsForDomain(self, userID = None, data = None):
currentSelection = data['currentSelection']

admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(zoneDomain, admin, currentACL) == 1:
if ACLManager.checkOwnershipZone(zoneDomain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
@@ -350,10 +253,10 @@ def addDNSRecord(self, userID = None, data = None):
ttl = int(data['ttl'])

admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(zoneDomain, admin, currentACL) == 1:
if ACLManager.checkOwnershipZone(zoneDomain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
return ACLManager.loadErrorJson()

zone = Domains.objects.get(name=zoneDomain)
value = ""
@@ -520,7 +423,7 @@ def deleteDNSRecord(self, userID = None, data = None):

admin = Administrator.objects.get(pk=userID)

if ACLManager.checkOwnership(delRecord.domainOwner.name, admin, currentACL) == 1:
if ACLManager.checkOwnershipZone(delRecord.domainOwner.name, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
@@ -565,7 +468,7 @@ def submitZoneDeletion(self, userID = None, data = None):
return ACLManager.loadErrorJson('delete_status', 0)


if ACLManager.checkOwnership(zoneDomain, admin, currentACL) == 1:
if ACLManager.checkOwnershipZone(zoneDomain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadError()
@@ -444,22 +444,22 @@ def findAllDomains(currentACL, userID):
domainsList = []

if currentACL['admin'] == 1:
domains = Websites.objects.all()
domains = Domains.objects.all()
for items in domains:
domainsList.append(items.domain)
domainsList.append(items.name)
else:
admin = Administrator.objects.get(pk=userID)
domains = admin.websites_set.all()
domains = admin.domains_set.all()

for items in domains:
domainsList.append(items.domain)
domainsList.append(items.name)

admins = Administrator.objects.filter(owner=admin.pk)

for items in admins:
doms = items.websites_set.all()
doms = items.domains_set.all()
for dom in doms:
domainsList.append(dom.domain)
domainsList.append(dom.name)

return domainsList

@@ -490,6 +490,19 @@ def checkOwnership(domain, admin, currentACL):
else:
return 0

@staticmethod
def checkOwnershipZone(domain, admin, currentACL):
domain = Domains.objects.get(name=domain)

if currentACL['admin'] == 1:
return 1
elif domain.admin == admin:
return 1
elif domain.admin.owner == admin.pk:
return 1
else:
return 0

@staticmethod
def executeCall(command):
try:
@@ -97,6 +97,8 @@ def startCloning(self):

command = "sed -i 's/%s/%s/g' %s" % (masterDomain, domain, databasePath)
ProcessUtilities.executioner(command, 'cyberpanel')
command = "sed -i 's/%s/%s/g' %s" % ('https', 'http', databasePath)
ProcessUtilities.executioner(command, 'cyberpanel')

if not mysqlUtilities.restoreDatabaseBackup(dbNameRestore, '/home/cyberpanel', None, 1, dbName):
try:

0 comments on commit afdbc36

Please sign in to comment.
You can’t perform that action at this time.