From 79561774450c8abf7c2cb42b08575a3ca27010dc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 16 Apr 2013 13:49:39 -0400 Subject: [PATCH] webapp: Include the repository directory in the mangled hostname and ssh key name, so that a locked down ssh key for one repository is not re-used when setting up additional repositories on the same server. --- Assistant/Ssh.hs | 25 +++++++++++++------ debian/changelog | 3 +++ ..._foo_not___126____47__bar__47____34__.mdwn | 3 +++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Assistant/Ssh.hs b/Assistant/Ssh.hs index 487f62c912..5312eaf77f 100644 --- a/Assistant/Ssh.hs +++ b/Assistant/Ssh.hs @@ -210,18 +210,27 @@ setSshConfig sshdata config = do , ("Port", show $ sshPort sshdata) ] +{- This hostname is specific to a given repository on the ssh host, + - so it is based on the real hostname, the username, and the directory. + -} mangleSshHostName :: SshData -> String -mangleSshHostName sshdata = "git-annex-" ++ host ++ (maybe "-" ('-':) user) +mangleSshHostName sshdata = "git-annex-" ++ T.unpack (sshHostName sshdata) + ++ "-" ++ filter safe extra where - host = T.unpack $ sshHostName sshdata - user = T.unpack <$> sshUserName sshdata + extra = join "_" $ map T.unpack $ catMaybes + [ sshUserName sshdata + , Just $ sshDirectory sshdata + ] + safe c + | isAlphaNum c = True + | c == '_' = True + | otherwise = False +{- Extracts the real hostname from a mangled ssh hostname. -} unMangleSshHostName :: String -> String -unMangleSshHostName h - | "git-annex-" `isPrefixOf` h = join "-" (beginning $ drop 2 dashbits) - | otherwise = h - where - dashbits = split "-" h +unMangleSshHostName h = case split "-" h of + ("git":"annex":rest) -> join "-" (beginning rest) + _ -> h {- Does ssh have known_hosts data for a hostname? -} knownHost :: Text -> IO Bool diff --git a/debian/changelog b/debian/changelog index 54e1c5e809..023a3e7d6f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -36,6 +36,9 @@ git-annex (4.20130406) UNRELEASED; urgency=low * Avoid using runghc, as that needs ghci. * webapp: When a repository's group is changed, rescan for transfers. * webapp: Added animations. + * webapp: Include the repository directory in the mangled hostname and + ssh key name, so that a locked down ssh key for one repository is not + re-used when setting up additional repositories on the same server. -- Joey Hess Sat, 06 Apr 2013 15:24:15 -0400 diff --git a/doc/bugs/Cannot_sync_repos_setup_using_webapp:___34__git-annex-shell:_Only_allowed_to_access___126____47__foo_not___126____47__bar__47____34__.mdwn b/doc/bugs/Cannot_sync_repos_setup_using_webapp:___34__git-annex-shell:_Only_allowed_to_access___126____47__foo_not___126____47__bar__47____34__.mdwn index ba538abffe..4d11546505 100644 --- a/doc/bugs/Cannot_sync_repos_setup_using_webapp:___34__git-annex-shell:_Only_allowed_to_access___126____47__foo_not___126____47__bar__47____34__.mdwn +++ b/doc/bugs/Cannot_sync_repos_setup_using_webapp:___34__git-annex-shell:_Only_allowed_to_access___126____47__foo_not___126____47__bar__47____34__.mdwn @@ -24,3 +24,6 @@ Machine 2: Ubuntu 12.04 with Git-Annex 4.20130405 installed using cabal. ###Please provide any additional information below. +> [[done]]; when setting up a new repo it will now use +> a ssh key that is different for each repository on the host. +> --[[Joey]]