diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /appl/cmd/auth/countersigner.b | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'appl/cmd/auth/countersigner.b')
| -rw-r--r-- | appl/cmd/auth/countersigner.b | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/appl/cmd/auth/countersigner.b b/appl/cmd/auth/countersigner.b new file mode 100644 index 00000000..a444f807 --- /dev/null +++ b/appl/cmd/auth/countersigner.b @@ -0,0 +1,59 @@ +implement Countersigner; + +include "sys.m"; + sys: Sys; + +include "draw.m"; + draw: Draw; + +include "keyring.m"; + kr: Keyring; + +include "security.m"; + +Countersigner: module +{ + init: fn(ctxt: ref Draw->Context, argv: list of string); +}; + +stderr, stdin, stdout: ref Sys->FD; + +init(nil: ref Draw->Context, nil: list of string) +{ + sys = load Sys Sys->PATH; + kr = load Keyring Keyring->PATH; + + stdin = sys->fildes(0); + stdout = sys->fildes(1); + stderr = sys->fildes(2); + + sys->pctl(Sys->FORKNS, nil); + if(sys->chdir("/keydb") < 0){ + sys->fprint(stderr, "countersigner: no key database\n"); + raise "fail:no keydb"; + } + + # get boxid + buf := kr->getmsg(stdin); + if(buf == nil){ + sys->fprint(stderr, "countersigner: client hung up\n"); + raise "fail:hungup"; + } + boxid := string buf; + + # read file + file := "countersigned/"+boxid; + fd := sys->open(file, Sys->OREAD); + if(fd == nil){ + sys->fprint(stderr, "countersigner: can't open %s: %r\n", file); + raise "fail:bad boxid"; + } + blind := kr->getmsg(fd); + if(blind == nil){ + sys->fprint(stderr, "countersigner: can't read %s\n", file); + raise "fail:no blind"; + } + + # answer client + kr->sendmsg(stdout, blind, len blind); +} |
