(Arne Babenhauserheide)
2013-08-23: use FTPS instead of FTP to avoid streaming cleartext passwords. use FTPS instead of FTP to avoid streaming cleartext passwords.
diff --git a/staticsite.py b/staticsite.py
--- a/staticsite.py
+++ b/staticsite.py
@@ -403,7 +403,7 @@ def getincoming(ui, repo, otheruri, othe
pass
# cannot do that for ftp or freenet insertion uris (freenet
# separates insertion and retrieval by private/public key)
- isftpuri = otheruri.startswith("ftp://")
+ isftpuri = otheruri.startswith("ftp://") or otheruri.startswith("ftps://")
isfreenetpriv = _freenetprivkeystring in otheruri
if isftpuri or isfreenetpriv:
chlist = []
@@ -434,7 +434,8 @@ def getoutgoing(ui, repo, otheruri, othe
# cannot do that for ftp or freenet insertion uris (freenet
# separates insertion and retrieval by private/public key)
ui.debug("[staticsite] getoutgoing: checkkeys\n")
- isftpuri = otheruri.startswith("ftp://")
+ isftpuri = otheruri.startswith("ftp://") or otheruri.startswith("ftps://")
+
isfreenetpriv = "AQECAAE/" in otheruri
if isftpuri or isfreenetpriv:
chlist = []
@@ -861,7 +862,8 @@ def upload(ui, repo, target, ftpstring,
ftppath = "/".join(serverandpath.split("/")[1:])
timeout = 10
try:
- ftp = ftplib.FTP(server, user, password, "", timeout)
+ ftp = ftplib.FTP_TLS(server, user, password, "", timeout=timeout)
+ ftp.prot_p()
except socket.timeout:
ui.warn(_("connection to "), server, _(" timed out after "), timeout, _(" seconds.\n"))
return
@@ -1024,6 +1026,7 @@ def ftppush(orig, *args, **opts):
# first create the site at ._site
target = "._site"
ftpstring = path.replace("ftp://", "")
+ ftpstring = path.replace("ftps://", "")
# fix the options to fit those of the site command
opts["name"] = opts["sitename"]
opts["upload"] = ftpstring
@@ -1056,7 +1059,7 @@ class FTPRepository(peerrepository):
self.create = create
self.ui = ui
self.path = path
- self.capabilities = set(["ftp"])
+ self.capabilities = set(["ftp", "ftps"])
def lock(self):
"""We cannot really lock FTP repos, yet.
@@ -1113,6 +1116,7 @@ class RepoContainer(object):
return FTPRepository(ui, url, create)
hg.schemes["ftp"] = RepoContainer()
+hg.schemes["ftps"] = RepoContainer()
def test():
import subprocess as sp