commit ac3ba726f9b4978829e4ad186b00109262fa2b93 from: Akshat Kumar via: Russ Cox date: Mon Sep 24 14:35:01 2012 UTC src/cmd: Add a repurposed import(4), called `9import', to the ports. The code is adapted from Plan 9's import(4); this allows us to speak that protocol. We don't currently support AAN (in the works) or TLS/SSL. Thanks to David for help with the man page, testing, and development. R=0intro, rsc CC=plan9port.codebot http://codereview.appspot.com/6458100 commit - 37f8ed2410ad5cbd46eda00a77f8bf4950bcf544 commit + ac3ba726f9b4978829e4ad186b00109262fa2b93 blob - 67d90a5ea8970a51b59da904c9d4cbcf128f3664 blob + 53f72167f19792032feab3fa59d6b75dc341d809 --- CONTRIBUTORS +++ CONTRIBUTORS @@ -5,6 +5,7 @@ Abhishek Kulkarni Albert Lee +Akshat Kumar André Günther Anthony Martin Anthony Sorace blob - /dev/null blob + e5b177cfbc0581be21a1684ae8b3f9a9b6e2d454 (mode 644) --- /dev/null +++ man/man4/9import.4 @@ -0,0 +1,79 @@ +.TH 9IMPORT 4 +.SH NAME +9import \- import a name space from a remote system +.SH SYNOPSIS +.B 9import +[ +.I options +] +.I system +.I file +[ +.I mountpoint +] +.SH DESCRIPTION +The +.I 9import +tool allows an arbitrary +.I file +on a remote +.I system, +with the capability of running the Plan 9 +.IR exportfs (4) +service, +to be imported into the local name space. +Usually +.I file +is a directory, so the complete +file tree under the directory is made available. +.PP +A process is started on the +remote machine, with authority of the user of +.IR 9import , +to perform work for the local machine using the +.IR exportfs (4) +service. +The default port used is TCP 17007. +If +.I mountpoint +is omitted, then +.I 9import +uses the name of the remote +.I file +as the local mount point. +.PP +The options are: +.TF "-s namexxx" +.PD +.TP +.B -A +Skip the authentication protocol. +This is useful for connecting to foreign systems like Inferno. +.TP +.B -k \fIkeypattern +Use +.I keypattern +to select a key to authenticate to the remote side +(see +.IR auth (2)). +.TP +.B -p +Push the +.IR aan (8) +filter onto the connection to protect against +temporary network outages. +.TP +.B -s \fIname +Post the connection's mountable file descriptor as +.BI /srv/ name\fR. +.SH SOURCE +.B \*9/src/cmd/9import.c +.SH SEE ALSO +.IR srv (4), +.IR aan (8), +.IR listen1 (8), +.B cs +in +.IR ndb (7) +.SH BUGS +Encryption is not implemented. blob - /dev/null blob + c74ffb50d0bc4dc7cc132f7ee493611bfa5ba2ec (mode 644) --- /dev/null +++ src/cmd/9import.c @@ -0,0 +1,239 @@ +#include +#include +#include +#include + +enum { + Encnone, + Encssl, + Enctls, +}; + +static char *encprotos[] = { + [Encnone] = "clear", + [Encssl] = "ssl", + [Enctls] = "tls", + nil, +}; + +char *keyspec = ""; +char *filterp; +char *ealgs = "rc4_256 sha1"; +int encproto = Encnone; +AuthInfo *ai; +int debug; +int doauth = 1; +int timedout; + +int connectez(char*, char*); +void sysfatal(char*, ...); +void usage(void); +int filter(int, char *, char *); + +int +catcher(void *v, char *msg) +{ + timedout = 1; + if(strcmp(msg, "alarm") == 0) + return 1; + return 0; +} + +static int +lookup(char *s, char *l[]) +{ + int i; + + for (i = 0; l[i] != 0; i++) + if (strcmp(l[i], s) == 0) + return i; + return -1; +} + +static char* +srvname(char *addr) +{ + int i; + + for(i=0; i