bug fix for git private repos

This commit is contained in:
root 2019-02-21 17:19:04 +05:00
parent d9e968a840
commit 5d104c30d1
3 changed files with 34 additions and 16 deletions

View File

@ -13,6 +13,8 @@ class secMiddleware:
#logging.writeToFile(request.body)
data = json.loads(request.body)
for key, value in data.iteritems():
if request.path.find('gitNotify') > -1:
break
if type(value) == str or type(value) == unicode:
pass
else:

View File

@ -547,6 +547,8 @@ class ApplicationInstaller(multi.Thread):
externalApp = website.externalApp
finalPath = "/home/" + domainName + "/public_html/"
## Security Check
if finalPath.find("..") > -1:
@ -575,8 +577,7 @@ class ApplicationInstaller(multi.Thread):
statusFile.close()
try:
command = 'sudo git clone https://' + defaultProvider +'.com/' + username + '/' + reponame + ' -b ' + branch + ' ' + finalPath
command = 'sudo git clone --depth 1 --no-single-branch git@' + defaultProvider +'.com:' + username + '/' + reponame + '.git -b ' + branch + ' ' + finalPath
subprocess.check_output(shlex.split(command))
except subprocess.CalledProcessError, msg:
statusFile = open(tempStatusPath, 'w')
@ -870,7 +871,6 @@ class ApplicationInstaller(multi.Thread):
githubBranch = self.extraArgs['githubBranch']
admin = self.extraArgs['admin']
try:
website = Websites.objects.get(domain=domainName)
finalPath = "/home/" + domainName + "/public_html/"
@ -879,18 +879,16 @@ class ApplicationInstaller(multi.Thread):
finalPath = childDomain.path
try:
command = 'sudo GIT_SSH_COMMAND="ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no" git -C ' + finalPath + ' checkout -b ' + githubBranch
command = 'sudo git --git-dir=' + finalPath + '/.git checkout -b ' + githubBranch
subprocess.check_output(shlex.split(command))
except subprocess.CalledProcessError, msg:
logging.writeToFile('Failed to change branch: ' + str(msg))
return 0
##
except:
try:
command = 'sudo git --git-dir=' + finalPath + '/.git checkout ' + githubBranch
subprocess.check_output(shlex.split(command))
except subprocess.CalledProcessError, msg:
logging.writeToFile('Failed to change branch: ' + str(msg))
return 0
return 0
except BaseException, msg:
logging.writeToFile('Failed to change branch: ' + str(msg))
return 0

View File

@ -1758,10 +1758,28 @@ class WebsiteManager:
return render(request, 'websiteFunctions/setupGit.html',
{'domainName': self.domain, 'installed': 1, 'webhookURL': webhookURL})
else:
command = "sudo ssh-keygen -f /root/.ssh/" + self.domain + " -t rsa -N ''"
command = "sudo ssh-keygen -f /root/.ssh/git -t rsa -N ''"
ProcessUtilities.executioner(command)
command = 'sudo cat /root/.ssh/' + self.domain + '.pub'
###
configContent = """Host github.com
IdentityFile /root/.ssh/git
"""
path = "/home/cyberpanel/config"
writeToFile = open(path, 'w')
writeToFile.writelines(configContent)
writeToFile.close()
command = 'sudo mv ' + path + ' /root/.ssh/config'
ProcessUtilities.executioner(command)
command = 'sudo chown root:root /root/.ssh/config'
ProcessUtilities.executioner(command)
command = 'sudo cat /root/.ssh/git.pub'
deploymentKey = subprocess.check_output(shlex.split(command)).strip('\n')
return render(request, 'websiteFunctions/setupGit.html',