summaryrefslogtreecommitdiff
path: root/appl/cmd/cpu.b
diff options
context:
space:
mode:
Diffstat (limited to 'appl/cmd/cpu.b')
-rw-r--r--appl/cmd/cpu.b37
1 files changed, 10 insertions, 27 deletions
diff --git a/appl/cmd/cpu.b b/appl/cmd/cpu.b
index 75728e57..ed538c75 100644
--- a/appl/cmd/cpu.b
+++ b/appl/cmd/cpu.b
@@ -4,18 +4,18 @@ include "sys.m";
sys: Sys;
stderr: ref Sys->FD;
include "draw.m";
- Context: import Draw;
include "string.m";
str: String;
include "arg.m";
include "keyring.m";
include "security.m";
+include "dial.m";
DEFCMD: con "/dis/sh";
CPU: module
{
- init: fn(ctxt: ref Context, argv: list of string);
+ init: fn(ctxt: ref Draw->Context, argv: list of string);
};
badmodule(p: string)
@@ -33,7 +33,7 @@ usage()
# The default level of security is NOSSL, unless
# the keyring directory doesn't exist, in which case
# it's disallowed.
-init(nil: ref Context, argv: list of string)
+init(nil: ref Draw->Context, argv: list of string)
{
sys = load Sys Sys->PATH;
stderr = sys->fildes(2);
@@ -50,6 +50,8 @@ init(nil: ref Context, argv: list of string)
kr := load Keyring Keyring->PATH;
if (kr == nil) badmodule(Keyring->PATH);
+ dial := load Dial Dial->PATH;
+
arg->init(argv);
alg := "";
while ((opt := arg->opt()) != 0) {
@@ -79,7 +81,7 @@ init(nil: ref Context, argv: list of string)
user := getuser();
kd := "/usr/" + user + "/keyring/";
- cert := kd + netmkaddr(mach, "tcp", "");
+ cert := kd + dial->netmkaddr(mach, "tcp", "");
if (!exists(cert)) {
cert = kd + "default";
if (!exists(cert)) {
@@ -88,14 +90,10 @@ init(nil: ref Context, argv: list of string)
}
}
- # To make visible remotely
- if(!exists("/dev/draw/new"))
- sys->bind("#d", "/dev", Sys->MBEFORE);
-
- (ok, c) := sys->dial(netmkaddr(mach, "net", "rstyx"), nil);
- if(ok < 0){
- sys->fprint(stderr, "Error: cpu: dial: %r\n");
- return;
+ c := dial->dial(dial->netmkaddr(mach, "net", "rstyx"), nil);
+ if(c == nil){
+ sys->fprint(stderr, "cpu: can't dial %s: %r\n", mach);
+ raise "fail:dial";
}
ai := kr->readauthinfo(cert);
@@ -151,18 +149,3 @@ getuser(): string
return string buf[0:n];
}
-
-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);
-}