webapp: Fix bug when setting up a remote ssh repo repeatedly on the same server.
The ssh setup first runs ssh to the real hostname, to probe if a ssh key is needed. If one is, it generates a mangled hostname that uses a key. This mangled hostname was being used to ssh into the server to set up the key. But if the server already had the key set up, and it was locked down, the setup would fail. This changes it to use the real hostname when sshing in to set up the key, which avoids the problem. Note that it will redundantly set up the key on the ssh server. But it's the same key; the ssh key generation code uses the key if it already exists.
This commit is contained in:
parent
4b3abb35f8
commit
10072157cb
2 changed files with 8 additions and 6 deletions
|
@ -284,18 +284,18 @@ makeSsh rsync setup sshdata
|
||||||
| needsPubKey sshdata = do
|
| needsPubKey sshdata = do
|
||||||
keypair <- liftIO genSshKeyPair
|
keypair <- liftIO genSshKeyPair
|
||||||
sshdata' <- liftIO $ setupSshKeyPair keypair sshdata
|
sshdata' <- liftIO $ setupSshKeyPair keypair sshdata
|
||||||
makeSsh' rsync setup sshdata' (Just keypair)
|
makeSsh' rsync setup sshdata sshdata' (Just keypair)
|
||||||
| sshPort sshdata /= 22 = do
|
| sshPort sshdata /= 22 = do
|
||||||
sshdata' <- liftIO $ setSshConfig sshdata []
|
sshdata' <- liftIO $ setSshConfig sshdata []
|
||||||
makeSsh' rsync setup sshdata' Nothing
|
makeSsh' rsync setup sshdata sshdata' Nothing
|
||||||
| otherwise = makeSsh' rsync setup sshdata Nothing
|
| otherwise = makeSsh' rsync setup sshdata sshdata Nothing
|
||||||
|
|
||||||
makeSsh' :: Bool -> (Remote -> Handler ()) -> SshData -> Maybe SshKeyPair -> Handler RepHtml
|
makeSsh' :: Bool -> (Remote -> Handler ()) -> SshData -> SshData -> Maybe SshKeyPair -> Handler RepHtml
|
||||||
makeSsh' rsync setup sshdata keypair =
|
makeSsh' rsync setup origsshdata sshdata keypair = do
|
||||||
sshSetup [sshhost, remoteCommand] "" $
|
sshSetup [sshhost, remoteCommand] "" $
|
||||||
makeSshRepo rsync setup sshdata
|
makeSshRepo rsync setup sshdata
|
||||||
where
|
where
|
||||||
sshhost = genSshHost (sshHostName sshdata) (sshUserName sshdata)
|
sshhost = genSshHost (sshHostName origsshdata) (sshUserName origsshdata)
|
||||||
remotedir = T.unpack $ sshDirectory sshdata
|
remotedir = T.unpack $ sshDirectory sshdata
|
||||||
remoteCommand = shellWrap $ intercalate "&&" $ catMaybes
|
remoteCommand = shellWrap $ intercalate "&&" $ catMaybes
|
||||||
[ Just $ "mkdir -p " ++ shellEscape remotedir
|
[ Just $ "mkdir -p " ++ shellEscape remotedir
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -5,6 +5,8 @@ git-annex (4.20130622) UNRELEASED; urgency=low
|
||||||
* bup: Handle /~/ in bup remote paths.
|
* bup: Handle /~/ in bup remote paths.
|
||||||
Thanks, Oliver Matthews
|
Thanks, Oliver Matthews
|
||||||
* fsck: Ensures that direct mode is used for files when it's enabled.
|
* fsck: Ensures that direct mode is used for files when it's enabled.
|
||||||
|
* webapp: Fix bug when setting up a remote ssh repo repeatedly on the same
|
||||||
|
server.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Fri, 21 Jun 2013 13:16:17 -0400
|
-- Joey Hess <joeyh@debian.org> Fri, 21 Jun 2013 13:16:17 -0400
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue