summaryrefslogtreecommitdiff
path: root/appl/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'appl/cmd')
-rw-r--r--appl/cmd/auth/logind.b4
-rw-r--r--appl/cmd/auth/passwd.b25
-rw-r--r--appl/cmd/ip/bootpd.b18
-rw-r--r--appl/cmd/ip/tftpd.b18
-rw-r--r--appl/cmd/listen.b12
-rw-r--r--appl/cmd/lockfs.b15
-rw-r--r--appl/cmd/styxlisten.b2
7 files changed, 42 insertions, 52 deletions
diff --git a/appl/cmd/auth/logind.b b/appl/cmd/auth/logind.b
index f9d14616..1bf17b15 100644
--- a/appl/cmd/auth/logind.b
+++ b/appl/cmd/auth/logind.b
@@ -13,6 +13,8 @@ include "keyring.m";
kr: Keyring;
IPint: import kr;
+include "dial.m";
+
include "security.m";
ssl: SSL;
@@ -62,7 +64,7 @@ init(nil: ref Draw->Context, nil: list of string)
kill(tpid, "kill");
}
-dologin(c: ref Sys->Connection): string
+dologin(c: ref Dial->Connection): string
{
ivec: array of byte;
diff --git a/appl/cmd/auth/passwd.b b/appl/cmd/auth/passwd.b
index b001cb16..2c5306b6 100644
--- a/appl/cmd/auth/passwd.b
+++ b/appl/cmd/auth/passwd.b
@@ -8,6 +8,9 @@ include "draw.m";
include "keyring.m";
kr: Keyring;
+include "dial.m";
+ dial: Dial;
+
include "security.m";
auth: Auth;
@@ -39,6 +42,9 @@ init(nil: ref Draw->Context, args: list of string)
kr = load Keyring Keyring->PATH;
if(kr == nil)
noload(Keyring->PATH);
+ dial = load Dial Dial->PATH;
+ if(dial == nil)
+ noload(Dial->PATH);
auth = load Auth Auth->PATH;
if(auth == nil)
noload(Auth->PATH);
@@ -156,8 +162,8 @@ err(s: string)
mountsrv(ai: ref Keyring->Authinfo): string
{
- (rc, c) := sys->dial(netmkaddr(signer, "net", "infkey"), nil);
- if(rc < 0)
+ c := dial->dial(dial->netmkaddr(signer, "net", "infkey"), nil);
+ if(c == nil)
err(sys->sprint("can't dial %s: %r", signer));
(fd, id_or_err) := auth->client("sha1/rc4_256", ai, c.dfd);
if(fd == nil)
@@ -220,21 +226,6 @@ putsecret(oldhash: array of byte, secret: array of byte): string
return nil;
}
-netmkaddr(addr, net, svc: string): string
-{
- if(net == nil)
- net = "net";
- (n, nil) := sys->tokenize(addr, "!");
- if(n <= 1){
- if(svc== nil)
- return sys->sprint("%s!%s", net, addr);
- return sys->sprint("%s!%s!%s", net, addr, svc);
- }
- if(svc == nil || n > 2)
- return addr;
- return sys->sprint("%s!%s", addr, svc);
-}
-
readline(io: ref Sys->FD, mode: string): (int, string)
{
r : int;
diff --git a/appl/cmd/ip/bootpd.b b/appl/cmd/ip/bootpd.b
index 71fea6f6..789c3e8a 100644
--- a/appl/cmd/ip/bootpd.b
+++ b/appl/cmd/ip/bootpd.b
@@ -18,6 +18,9 @@ include "attrdb.m";
attrdb: Attrdb;
Attr, Db, Dbentry, Tuples: import attrdb;
+include "dial.m";
+ dial: Dial;
+
include "ip.m";
ip: IP;
IPaddr, Udphdr: import ip;
@@ -63,6 +66,9 @@ init(nil: ref Draw->Context, args: list of string)
if(attrdb == nil)
loadfail(Attrdb->PATH);
attrdb->init();
+ dial = load Dial Dial->PATH;
+ if(dial == nil)
+ loadfail(Dial->PATH);
ip = load IP IP->PATH;
if(ip == nil)
loadfail(IP->PATH);
@@ -120,8 +126,8 @@ init(nil: ref Draw->Context, args: list of string)
addr = net+"/udp!*!499";
if(debug)
sys->fprint(stderr, "bootpd: announcing %s\n", addr);
- (ok, c) := sys->announce(addr);
- if(ok < 0)
+ c := dial->announce(addr);
+ if(c == nil)
error(sys->sprint("can't announce %s: %r", addr));
if(sys->fprint(c.cfd, "headers") < 0)
error(sys->sprint("can't set headers mode: %r"));
@@ -146,7 +152,7 @@ error(s: string)
raise "fail:error";
}
-server(c: Sys->Connection)
+server(c: ref Sys->Connection)
{
buf := array[2048] of byte;
badread := 0;
@@ -298,12 +304,12 @@ send(hdr: ref Udphdr, msg: array of byte)
lport := "67";
if(testing)
lport = "499";
- (n, c) := sys->dial(replyaddr, lport);
- if(n < 0) {
+ c := dial->dial(replyaddr, lport);
+ if(c == nil) {
sys->fprint(stderr, "bootpd: can't dial %s for reply: %r\n", replyaddr);
return;
}
- n = sys->write(c.dfd, msg, len msg);
+ n := sys->write(c.dfd, msg, len msg);
if(n != len msg)
sys->fprint(stderr, "bootpd: udp write error: %r\n");
}
diff --git a/appl/cmd/ip/tftpd.b b/appl/cmd/ip/tftpd.b
index c7edef4e..57d80cd5 100644
--- a/appl/cmd/ip/tftpd.b
+++ b/appl/cmd/ip/tftpd.b
@@ -8,6 +8,9 @@ include "draw.m";
include "arg.m";
+include "dial.m";
+ dial: Dial;
+
include "ip.m";
ip: IP;
IPaddr, Udphdr: import ip;
@@ -34,7 +37,7 @@ port := 69;
Udphdrsize: con IP->Udphdrlen;
-tftpcon: Sys->Connection;
+tftpcon: ref Sys->Connection;
tftpreq: ref Sys->FD;
dokill(pid: int, scope: string)
@@ -152,6 +155,10 @@ init(nil: ref Draw->Context, args: list of string)
sys->pctl(Sys->NEWPGRP|Sys->FORKFD|Sys->FORKNS, nil);
stderr = sys->fildes(2);
+ dial = load Dial Dial->PATH;
+ if(dial == nil)
+ fatal("can't load Dial");
+
arg := load Arg Arg->PATH;
if(arg == nil)
fatal("can't load Arg");
@@ -206,8 +213,8 @@ mainthing()
raddr := sys->sprint("%s/udp!%s!%d", net, hdr.raddr.text(), hdr.rport);
DBG(sys->sprint("raddr=%s", raddr));
- (err, cx) := sys->dial(raddr, nil);
- if(err < 0)
+ cx := dial->dial(raddr, nil);
+ if(cx == nil)
fatal("dialing "+raddr);
# showbuf("bigbuf", bigbuf[0:dlen]);
@@ -492,9 +499,8 @@ fatal(msg: string)
openlisten()
{
name := net+"/udp!*!" + string port;
- err := 0;
- (err, tftpcon) = sys->announce(name);
- if(err < 0)
+ tftpcon = dial->announce(name);
+ if(tftpcon == nil)
fatal("can't announce "+name);
if(sys->fprint(tftpcon.cfd, "headers") < 0)
fatal("can't set header mode");
diff --git a/appl/cmd/listen.b b/appl/cmd/listen.b
index 61c5ecf9..8ccaa15b 100644
--- a/appl/cmd/listen.b
+++ b/appl/cmd/listen.b
@@ -151,12 +151,12 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string,
}
sync <-= nil;
- listench := chan of (int, ref Sys->Connection);
- authch := chan of (string, ref Sys->Connection);
+ listench := chan of (int, ref Dial->Connection);
+ authch := chan of (string, ref Dial->Connection);
spawn listener(listench, acon, addr);
for (;;) {
user := "";
- ccon: ref Sys->Connection;
+ ccon: ref Dial->Connection;
alt {
(lok, c) := <-listench =>
if (lok == -1){
@@ -187,7 +187,7 @@ listen1(drawctxt: ref Draw->Context, addr: string, argv: list of string,
}
}
-listener(listench: chan of (int, ref Sys->Connection), c: ref Sys->Connection, addr: string)
+listener(listench: chan of (int, ref Dial->Connection), c: ref Dial->Connection, addr: string)
{
for (;;) {
nc := dial->listen(c);
@@ -210,8 +210,8 @@ listener(listench: chan of (int, ref Sys->Connection), c: ref Sys->Connection, a
}
}
-authenticator(authch: chan of (string, ref Sys->Connection),
- c: ref Sys->Connection, algs: list of string, addr: string)
+authenticator(authch: chan of (string, ref Dial->Connection),
+ c: ref Dial->Connection, algs: list of string, addr: string)
{
err: string;
(c.dfd, err) = auth->server(algs, serverkey, c.dfd, 0);
diff --git a/appl/cmd/lockfs.b b/appl/cmd/lockfs.b
index 766c6f64..26a9ccf4 100644
--- a/appl/cmd/lockfs.b
+++ b/appl/cmd/lockfs.b
@@ -735,21 +735,6 @@ doreq(greq: ref Ureq): (ref Sys->FD, string)
return (fd, err);
}
-netmkaddr(addr, net, svc: string): string
-{
- if(net == nil)
- net = "net";
- (n, nil) := sys->tokenize(addr, "!");
- if(n <= 1){
- if(svc== nil)
- return sys->sprint("%s!%s", net, addr);
- return sys->sprint("%s!%s!%s", net, addr, svc);
- }
- if(svc == nil || n > 2)
- return addr;
- return sys->sprint("%s!%s", addr, svc);
-}
-
user(): string
{
fd := sys->open("/dev/user", sys->OREAD);
diff --git a/appl/cmd/styxlisten.b b/appl/cmd/styxlisten.b
index ae9f7b45..22182e25 100644
--- a/appl/cmd/styxlisten.b
+++ b/appl/cmd/styxlisten.b
@@ -108,7 +108,7 @@ init(ctxt: ref Draw->Context, argv: list of string)
spawn listener(c, popen(ctxt, cmd, lsync), authinfo, algs, lsync);
}
-listener(c: ref Sys->Connection, mfd: ref Sys->FD, authinfo: ref Keyring->Authinfo, algs: list of string, lsync: chan of int)
+listener(c: ref Dial->Connection, mfd: ref Sys->FD, authinfo: ref Keyring->Authinfo, algs: list of string, lsync: chan of int)
{
lsync <-= sys->pctl(0, nil);
for (;;) {