From f0fd01bf1be50dc46c8170afd86795fb2a85883b Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 25 Mar 2000 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2000-03-25 --- port/devproc.c | 4 ++++ port/devssl.c | 31 ++++++++++++++++++++++++------- port/proc.c | 10 ++++++++-- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/port/devproc.c b/port/devproc.c index 1047204e7097584e7d4e9b553c11d8c9db38dc16..8a9424f38acc3b1010aba020e747889adf75e018 100644 --- a/port/devproc.c +++ b/port/devproc.c @@ -560,6 +560,8 @@ procread(Chan *c, void *va, long n, vlong off) return sizeof(Waitmsg); case Qns: + if(p->pgrp == nil) + error(Ebadusefd); mw = c->aux; if(mw->cddone) return 0; @@ -584,6 +586,8 @@ procread(Chan *c, void *va, long n, vlong off) case Qnoteid: return readnum(offset, va, n, p->noteid, NUMSIZE); case Qfd: + if(p->fgrp == nil) + error(Ebadusefd); return procfds(p, va, n, offset); } error(Egreg); diff --git a/port/devssl.c b/port/devssl.c index 7198fed608a7ef9e66a2342fd0f38984bf072942..7db77acfb48fccfa7431c1522cbb58c2ee772f30 100644 --- a/port/devssl.c +++ b/port/devssl.c @@ -97,8 +97,8 @@ enum{ }; #define TYPE(x) ((x).path & 0xf) -#define CONV(x) (((x).path >> 4)&(Maxdstate-1)) -#define QID(c, y) (((c)<<4) | (y)) +#define CONV(x) (((x).path >> 5)&(Maxdstate-1)) +#define QID(c, y) (((c)<<5) | (y)) static void ensure(Dstate*, Block**, int); static void consume(Block**, uchar*, int); @@ -112,6 +112,16 @@ static void sslhangup(Dstate*); static Dstate* dsclone(Chan *c); static void dsnew(Chan *c, Dstate **); +char *sslnames[] = { +[Qclonus] "clone", +[Qdata] "data", +[Qctl] "ctl", +[Qsecretin] "secretin", +[Qsecretout] "secretout", +[Qencalgs] "encalgs", +[Qhashalgs] "hashalgs", +}; + static int sslgen(Chan *c, Dirtab *d, int nd, int s, Dir *dp) { @@ -126,18 +136,18 @@ sslgen(Chan *c, Dirtab *d, int nd, int s, Dir *dp) case Qtopdir: if(s == DEVDOTDOT){ q.path = QID(0, Qtopdir)|CHDIR; - devdir(c, q, "#D", 0, eve, 0555, dp); + devdir(c, q, "#D", 0, eve, CHDIR|0555, dp); return 1; } if(s > 0) return -1; q.path = QID(0, Qprotodir)|CHDIR; - devdir(c, q, "ssl", 0, eve, 0555, dp); + devdir(c, q, "ssl", 0, eve, CHDIR|0555, dp); return 1; case Qprotodir: if(s == DEVDOTDOT){ q.path = QID(0, Qtopdir)|CHDIR; - devdir(c, q, ".", 0, eve, 0555, dp); + devdir(c, q, ".", 0, eve, CHDIR|0555, dp); return 1; } if(s < dshiwat) { @@ -148,7 +158,7 @@ sslgen(Chan *c, Dirtab *d, int nd, int s, Dir *dp) nm = ds->user; else nm = eve; - devdir(c, q, name, 0, nm, 0555, dp); + devdir(c, q, name, 0, nm, CHDIR|0555, dp); return 1; } if(s > dshiwat) @@ -159,7 +169,7 @@ sslgen(Chan *c, Dirtab *d, int nd, int s, Dir *dp) case Qconvdir: if(s == DEVDOTDOT){ q.path = QID(0, Qprotodir)|CHDIR; - devdir(c, q, "ssl", 0, eve, 0555, dp); + devdir(c, q, "ssl", 0, eve, CHDIR|0555, dp); return 1; } ds = dstate[CONV(c->qid)]; @@ -197,6 +207,13 @@ sslgen(Chan *c, Dirtab *d, int nd, int s, Dir *dp) } devdir(c, q, p, 0, nm, 0660, dp); return 1; + case Qclonus: + devdir(c, c->qid, sslnames[TYPE(c->qid)], 0, eve, 0555, dp); + return 1; + default: + ds = dstate[CONV(c->qid)]; + devdir(c, c->qid, sslnames[TYPE(c->qid)], 0, ds->user, 0660, dp); + return 1; } return -1; } diff --git a/port/proc.c b/port/proc.c index 52fb21de2662a01d7a6c5a581f7ab5daab5424bf..cf991297f0d61e55ab482bfcfedc591ff9a30798 100644 --- a/port/proc.c +++ b/port/proc.c @@ -747,13 +747,19 @@ pexit(char *exitstr, int freemem) closefgrp(fgrp); qunlock(&up->debug); } - if(up->egrp) + if(up->egrp){ closeegrp(up->egrp); - if(up->rgrp) + up->egrp = nil; + } + if(up->rgrp){ closergrp(up->rgrp); + up->rgrp = nil; + } cclose(up->dot); + up->dot = nil; closepgrp(up->pgrp); + up->pgrp = nil; /* * if not a kernel process and have a parent,