Improve check on whether user supplied a command
authorPaul Crowley <paul@lshift.net>
Mon, 12 Oct 2009 16:52:06 +0100
changeset 108 00b48d7bdfa0
parent 107 84e9e33d866b
child 109 72100d3ed1bd
Improve check on whether user supplied a command
src/hg-ssh
--- a/src/hg-ssh	Mon Oct 12 16:25:02 2009 +0100
+++ b/src/hg-ssh	Mon Oct 12 16:52:06 2009 +0100
@@ -89,9 +89,11 @@
     if os.path.isfile(f):
         ruleset.rules.readfile(f)
 
-cmd = os.environ.get('SSH_ORIGINAL_COMMAND', '')
+cmd = os.environ.get('SSH_ORIGINAL_COMMAND', None)
 try:
-    if cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'):
+    if cmd is None:
+        fail("direct logins on the hg account prohibited")
+    elif cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'):
         repo = getrepo("read", cmd[6:-14])
         if not os.path.isdir(repo + "/.hg"):
             fail("no such repository %s" % repo)
@@ -104,8 +106,6 @@
         if d != "" and not os.path.isdir(d):
             os.makedirs(d)
         dispatch.dispatch(['init', repo])
-    elif cmd == "":
-        fail("direct logins on the hg account prohibited ")
     else:
         fail("illegal command %r" % cmd)
 except ruleset.AccessException: