changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/rimport

changeset 5096: 65abc13ef7a1
child: c392f6b2122c
author: cinap_lenrek@felloff.net
date: Sun, 14 Feb 2016 05:18:33 +0100
permissions: -rwxr-xr-x
description: adding experimental rcpu service

this is a reimplementation of cpu and import utilities in rc using a tlsclient
and tlssrv as the encryption and authentication layers. there is only one new
service, which after authentication and encryption setup accepts an arbitrary
rc script over the network and executes it with the standard filedescriptors
redirected to the conversaion (this is *after* authentication and in the
context of the authorized user).

the new rcpu program has a few improvements over cpu(1):

- doesnt mangle program arguments
- the remote process will get the clients standard file descriptors, so error
and output are separated and you can consume the clients input from the
remote side :-)
- forwards error status of remote process

theres no backwards mode for rimport, but a new program called rexport
for the same purpose.

all these services use exportfs without the bolted on initial handshake,
so the hope is to clean up exportfs in the future and remove all the ugly
crap in there.
1 #!/bin/rc
2 rfork e
3 
4 argv0=$0
5 fn usage {
6  echo 'usage:' $argv0 '[options] host tree [mountpoint]' >[1=2]
7  exit 'usage'
8 }
9 
10 fn domount {
11  if(~ $#sname 1){
12  rm -f /srv/$sname
13  echo -n 0 >/srv/$sname
14  }
15  ~ $#mtpt 0 || mount -n $mopt /fd/0 $mtpt
16 }
17 
18 tree=()
19 mopt=()
20 mtpt=()
21 sname=()
22 exportfs=/bin/exportfs
23 connect=/bin/rconnect
24 
25 while(~ $1 -*){
26  switch($1){
27  case -p; connect=($connect $1)
28  case -[abcCnq]*; mopt=($mopt $1)
29  case *
30  ~ $#* 1 && usage
31  switch($1){
32  case -[uk]; connect=($connect $1 $2)
33  case -s; sname=`{basename $2}
34  case *; usage
35  }
36  shift
37  }
38  shift
39 }
40 switch($#*){
41 case 2 3; tree=$2; mtpt=$$#*
42 case *; usage
43 }
44 
45 fn pvar {
46  while(! ~ $#* 0){
47  ~ $#$1 0 || path=/dev/null builtin whatis $1
48  shift
49  }
50 }
51 
52 exec $connect $1 <{pvar tree; echo exec $exportfs -r '$tree'} domount