devssl, devtls: fix permission checks

This commit is contained in:
cinap_lenrek 2016-05-11 02:10:05 +02:00
parent a630e17bd7
commit cb4b187f10
2 changed files with 3 additions and 39 deletions

View file

@ -263,23 +263,8 @@ static Chan*
sslopen(Chan *c, int omode) sslopen(Chan *c, int omode)
{ {
Dstate *s, **pp; Dstate *s, **pp;
int perm;
int ft; int ft;
perm = 0;
omode &= 3;
switch(omode) {
case OREAD:
perm = 4;
break;
case OWRITE:
perm = 2;
break;
case ORDWR:
perm = 6;
break;
}
ft = TYPE(c->qid); ft = TYPE(c->qid);
switch(ft) { switch(ft) {
default: default:
@ -309,11 +294,7 @@ sslopen(Chan *c, int omode)
if(s == 0) if(s == 0)
dsnew(c, pp); dsnew(c, pp);
else { else {
if((perm & (s->perm>>6)) != perm devpermcheck(s->user, s->perm, omode);
&& (strcmp(up->user, s->user) != 0
|| (perm & s->perm) != perm))
error(Eperm);
s->ref++; s->ref++;
} }
unlock(&dslock); unlock(&dslock);

View file

@ -424,21 +424,7 @@ static Chan*
tlsopen(Chan *c, int omode) tlsopen(Chan *c, int omode)
{ {
TlsRec *tr, **pp; TlsRec *tr, **pp;
int t, perm; int t;
perm = 0;
omode &= 3;
switch(omode) {
case OREAD:
perm = 4;
break;
case OWRITE:
perm = 2;
break;
case ORDWR:
perm = 6;
break;
}
t = TYPE(c->qid); t = TYPE(c->qid);
switch(t) { switch(t) {
@ -471,10 +457,7 @@ tlsopen(Chan *c, int omode)
tr = *pp; tr = *pp;
if(tr == nil) if(tr == nil)
error("must open connection using clone"); error("must open connection using clone");
if((perm & (tr->perm>>6)) != perm devpermcheck(tr->user, tr->perm, omode);
&& (strcmp(up->user, tr->user) != 0
|| (perm & tr->perm) != perm))
error(Eperm);
if(t == Qhand){ if(t == Qhand){
if(waserror()){ if(waserror()){
unlock(&tr->hqlock); unlock(&tr->hqlock);