##// END OF EJS Templates
ssh: ban any username@host or host that starts with - (SEC)...
Augie Fackler -
r33707:e1074531 stable
parent child Browse files
Show More
@@ -23,6 +23,7 b' import unicodedata'
23 from .i18n import _
23 from .i18n import _
24 from . import (
24 from . import (
25 encoding,
25 encoding,
26 error,
26 pycompat,
27 pycompat,
27 )
28 )
28
29
@@ -91,6 +92,9 b' def parsepatchoutput(output_line):'
91 def sshargs(sshcmd, host, user, port):
92 def sshargs(sshcmd, host, user, port):
92 '''Build argument list for ssh'''
93 '''Build argument list for ssh'''
93 args = user and ("%s@%s" % (user, host)) or host
94 args = user and ("%s@%s" % (user, host)) or host
95 if '-' in args[:2]:
96 raise error.Abort(
97 _('illegal ssh hostname or username starting with -: %s') % args)
94 return port and ("%s -p %s" % (args, port)) or args
98 return port and ("%s -p %s" % (args, port)) or args
95
99
96 def isexec(f):
100 def isexec(f):
@@ -17,6 +17,7 b' import sys'
17 from .i18n import _
17 from .i18n import _
18 from . import (
18 from . import (
19 encoding,
19 encoding,
20 error,
20 osutil,
21 osutil,
21 pycompat,
22 pycompat,
22 win32,
23 win32,
@@ -199,6 +200,10 b' def sshargs(sshcmd, host, user, port):'
199 '''Build argument list for ssh or Plink'''
200 '''Build argument list for ssh or Plink'''
200 pflag = 'plink' in sshcmd.lower() and '-P' or '-p'
201 pflag = 'plink' in sshcmd.lower() and '-P' or '-p'
201 args = user and ("%s@%s" % (user, host)) or host
202 args = user and ("%s@%s" % (user, host)) or host
203 if args.startswith('-') or args.startswith('/'):
204 raise error.Abort(
205 _('illegal ssh hostname or username starting with - or /: %s') %
206 args)
202 return port and ("%s %s %s" % (args, pflag, port)) or args
207 return port and ("%s %s %s" % (args, pflag, port)) or args
203
208
204 def setflags(f, l, x):
209 def setflags(f, l, x):
General Comments 0
You need to be logged in to leave comments. Login now