X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=remoteusage%2Faboriginal.mdwn;h=e00ed6fe614266b3b893bba767b19ddb6ad4ace4;hb=281ac0bd4b50ec4a1a832c688f16361390aaace4;hp=540381b752913109112f8140ba7cd1054a5bfcdd;hpb=264ce3866a61e26da9b644a522cd9e857ac94c7b;p=notmuch-wiki diff --git a/remoteusage/aboriginal.mdwn b/remoteusage/aboriginal.mdwn index 540381b..e00ed6f 100644 --- a/remoteusage/aboriginal.mdwn +++ b/remoteusage/aboriginal.mdwn @@ -7,22 +7,20 @@ other requirements and general information. This solution uses one pre-made ssh connection where the client is put into "master" mode (-M) for connection sharing. The wrapper script then uses the control socket created by this pre-made ssh connection for -its own connection. - -Write the following code to a file, for example `remote-notmuch.sh`. -There is just one line to that normally needs configuration: - - readonly SSH_CONTROL_SOCK='~'/.ssh/master-user@host:22 - -the options howto are presented after the script. +its own connection. As long as master ssh connection is live, slave +can use it. Disconnecting master all future attempts to connect +from the script will fail. ## The script +Write the following code to a file, for example `remote-notmuch.sh`. + #!/bin/bash # http://notmuchmail.org/remoteusage/aboriginal/ set -eu + #exec 2>>remote-errors; echo -- >&2; set -x # outcomment for debugging readonly SSH_CONTROL_SOCK='~'/.ssh/master-user@host:22 @@ -32,7 +30,7 @@ the options howto are presented after the script. readonly SSH_CONTROL_ARGS='-oControlMaster=no -S '$SSH_CONTROL_SOCK - if ssh $SSH_CONTROL_ARGS 0.1 $notmuch $ARGS 2>>/dev/null + if ssh -q $SSH_CONTROL_ARGS 0.1 $notmuch $ARGS then exit 0 else ev=$? fi @@ -42,6 +40,7 @@ the options howto are presented after the script. case $* in 'config get user.primary_email') echo 'nobody@nowhere.invalid'; exit 0 ;; 'config get user.name') echo 'nobody'; exit 0 ;; + 'count'*'--batch'*) while read line; do echo 1; done; exit 0 ;; 'count'*) echo 1; exit 0 ;; 'search-tags'*) echo 'errors'; exit 0 ;; 'search'*'--output=tags'*) echo 'errors'; exit 0 ;; @@ -55,6 +54,11 @@ the options howto are presented after the script. echo " See`sed '1d;2d;s/.//;q' "$0"` for help." +Note the `0.1` in ssh command line. It is used to avoid any opportunistic +behaviour ssh might do; for example if control socket is not alive ssh +would attempt to do it's own ssh connection to remote ssh server. As +address `0.1` is invalid this attempt will fail early. + ## Test Easiest way to test this script is to run the pre-made ssh connection @@ -69,10 +73,10 @@ terminal and then test the script with `./remote-notmuch.sh help` Note that the '~' is inside single quotes for a reason. In this case shell never expand it to `$HOME` -- ssh does it by not reading -`$HOME` but checking the real user home directory from `/etc/passewd`. +`$HOME` but checking the real user home directory from `/etc/passwd`. For security purposes this is just how it should be. -## Tunkkaa +## Tune The path `'~'/.ssh/master-user@host:22` might look too generic to be used as is as the control socket after initial testing (but it can @@ -97,12 +101,3 @@ to the `./remote-notmuch.sh` wrapper script testing with See the section *Configure Emacs on the client computer* in [[remoteusage|remoteusage]] how to do this. The instructions are the same. - -## Fun - -Original [BSD Licence](http://en.wikipedia.org/wiki/BSD_licenses) -is 4-clause license. -When 3 rd. clause was removed, the new license was not original anymore. -Similarly, the requirement for this version are the same as in -[[remoteusage|remoteusage]] page except the 3 rd. requirement -(password-free login) is not effective here.