windows webapp: fix rsync.net support

This commit is contained in:
Joey Hess 2014-02-14 15:42:35 -04:00
parent 8613f226b3
commit fd09798e40
4 changed files with 44 additions and 18 deletions

View file

@ -25,6 +25,11 @@ import qualified Remote.GCrypt as GCrypt
import Annex.UUID import Annex.UUID
import Logs.UUID import Logs.UUID
#ifdef mingw32_HOST_OS
import Utility.Tmp
import Utility.Rsync
#endif
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.Map as M import qualified Data.Map as M
import Network.Socket import Network.Socket
@ -468,8 +473,18 @@ enableRsyncNetGCrypt sshinput reponame =
notencrypted = error "Unexpectedly found a non-encrypted git repository, instead of the expected encrypted git repository." notencrypted = error "Unexpectedly found a non-encrypted git repository, instead of the expected encrypted git repository."
notinstalled = error "internal" notinstalled = error "internal"
{- Prepares rsync.net ssh key, and if successful, runs an action with {- Prepares rsync.net ssh key and creates the directory that will be
- its SshData. -} - used on rsync.net. If successful, runs an action with its SshData.
-
- To append the ssh key to rsync.net's authorized_keys, their
- documentation recommends a dd methodd, where the line is fed
- in to ssh over stdin.
-
- On Windows, ssh password prompting happens on stdin, so cannot
- feed the key in that way. Instead, first rsync down any current
- authorized_keys file, then modifiy it, and then rsync it back up.
- This means 2 password prompts rather than one for Windows.
-}
prepRsyncNet :: SshInput -> String -> (SshData -> Handler Html) -> Handler Html prepRsyncNet :: SshInput -> String -> (SshData -> Handler Html) -> Handler Html
prepRsyncNet sshinput reponame a = do prepRsyncNet sshinput reponame a = do
knownhost <- liftIO $ maybe (return False) knownHost (inputHostname sshinput) knownhost <- liftIO $ maybe (return False) knownHost (inputHostname sshinput)
@ -480,25 +495,37 @@ prepRsyncNet sshinput reponame a = do
, needsPubKey = True , needsPubKey = True
, sshCapabilities = [RsyncCapable] , sshCapabilities = [RsyncCapable]
} }
let sshhost = genSshHost (sshHostName sshdata) (sshUserName sshdata)
let torsyncnet cmd = filter (not . null)
[ if knownhost then "" else sshOpt "StrictHostKeyChecking" "no"
, sshhost
, cmd
]
#ifndef mingw32_HOST_OS
{- I'd prefer to separate commands with && , but {- I'd prefer to separate commands with && , but
- rsync.net's shell does not support that. - rsync.net's shell does not support that. -}
-
- The dd method of appending to the authorized_keys file is the
- one recommended by rsync.net documentation. I touch the file first
- to not need to use a different method to create it.
-}
let remotecommand = intercalate ";" let remotecommand = intercalate ";"
[ "mkdir -p .ssh" [ "mkdir -p .ssh"
, "touch .ssh/authorized_keys" , "touch .ssh/authorized_keys"
, "dd of=.ssh/authorized_keys oflag=append conv=notrunc" , "dd of=.ssh/authorized_keys oflag=append conv=notrunc"
, "mkdir -p " ++ T.unpack (sshDirectory sshdata) , "mkdir -p " ++ T.unpack (sshDirectory sshdata)
] ]
let sshopts = filter (not . null) sshSetup (torsyncnet remotecommand) (Just $ sshPubKey keypair) (a sshdata)
[ if knownhost then "" else sshOpt "StrictHostKeyChecking" "no" #else
, genSshHost (sshHostName sshdata) (sshUserName sshdata) liftIO $ withTmpDir "rsyncnet" $ \tmpdir -> do
, remotecommand createDirectory $ tmpdir </> ".ssh"
(oldkeys, _) <- sshTranscript (torsyncnet "cat .ssh/authorized_keys") Nothing
writeFile (tmpdir </> ".ssh" </> "authorized_keys")
(sshPubKey keypair ++ "\n" ++ oldkeys)
liftIO $ putStrLn "May need to prompt for your rsync.net password one more time..."
void $ rsync
[ Param "-r"
, File $ tmpdir </> ".ssh/"
, Param $ sshhost ++ ":.ssh/"
] ]
sshSetup sshopts (Just $ sshPubKey keypair) $ a sshdata let remotecommand = "mkdir -p " ++ T.unpack (sshDirectory sshdata)
sshSetup (torsyncnet remotecommand) Nothing (a sshdata)
#endif
isRsyncNet :: Maybe Text -> Bool isRsyncNet :: Maybe Text -> Bool
isRsyncNet Nothing = False isRsyncNet Nothing = False

2
debian/changelog vendored
View file

@ -6,7 +6,7 @@ git-annex (5.20140211) UNRELEASED; urgency=medium
* Preferred content expressions can use metadata=field=value * Preferred content expressions can use metadata=field=value
to limit them to acting on files that have particular metadata. to limit them to acting on files that have particular metadata.
* Add progress display for transfers to/from external special remotes. * Add progress display for transfers to/from external special remotes.
* Windows webapp: Can set up box.com, Amazon S3 remotes. * Windows webapp: Can set up box.com, Amazon S3, and rsync.net remotes
* Windows webapp: Can create repos on removable drives. * Windows webapp: Can create repos on removable drives.
* Windows: Ensure HOME is set, as needed by bundled cygwin utilities. * Windows: Ensure HOME is set, as needed by bundled cygwin utilities.

View file

@ -81,3 +81,5 @@ Options:
-q --quiet avoid verbose output -q --quiet avoid verbose output
etc etc
"""]] """]]
> [[fixed|done]]; both for regular remote ssh servers, and for rsync.net --[[Joey]]

View file

@ -31,9 +31,6 @@ now! --[[Joey]]
* Local pairing seems to fail, after acking on Linux box, it stalls. * Local pairing seems to fail, after acking on Linux box, it stalls.
* rsync.net setup fails. See
<http://git-annex.branchable.com/bugs/assistant_unable_to_auth___40__windows__41__/>
* gcrypt is not ported to windows (and as a shell script, may need * gcrypt is not ported to windows (and as a shell script, may need
to be rewritten) to be rewritten)