Unified · Split
| @@ -263,23 +263,8 @@ static Chan* · 262 unmodified lines | ||
| 263 | 263 | sslopen(Chan *c, int omode) |
| 264 | 264 | { |
| 265 | 265 | Dstate *s, **pp; |
| 266 | − int perm; | |
| 267 | 266 | int ft; |
| 268 | 267 | |
| 269 | − perm = 0; | |
| 270 | − omode &= 3; | |
| 271 | − switch(omode) { | |
| 272 | − case OREAD: | |
| 273 | − perm = 4; | |
| 274 | − break; | |
| 275 | − case OWRITE: | |
| 276 | − perm = 2; | |
| 277 | − break; | |
| 278 | − case ORDWR: | |
| 279 | − perm = 6; | |
| 280 | − break; | |
| 281 | − } | |
| 282 | − | |
| 283 | 268 | ft = TYPE(c->qid); |
| 284 | 269 | switch(ft) { |
| 285 | 270 | default: |
| @@ -309,11 +294,7 @@ sslopen(Chan *c, int omode) · 23 unmodified lines | ||
| 309 | 294 | if(s == 0) |
| 310 | 295 | dsnew(c, pp); |
| 311 | 296 | else { |
| 312 | − if((perm & (s->perm>>6)) != perm | |
| 313 | − && (strcmp(up->user, s->user) != 0 | |
| 314 | − || (perm & s->perm) != perm)) | |
| 315 | − error(Eperm); | |
| 316 | − | |
| 297 | + devpermcheck(s->user, s->perm, omode); | |
| 317 | 298 | s->ref++; |
| 318 | 299 | } |
| 319 | 300 | unlock(&dslock); |
| @@ -1458,7 +1439,7 @@ buftochan(char *p) · 1138 unmodified lines | ||
| 1458 | 1439 | fd = strtoul(p, 0, 0); |
| 1459 | 1440 | if(fd < 0) |
| 1460 | 1441 | error(Ebadarg); |
| 1461 | − c = fdtochan(fd, -1, 0, 1); /* error check and inc ref */ | |
| 1442 | + c = fdtochan(fd, ORDWR, 1, 1); /* error check and inc ref */ | |
| 1462 | 1443 | if(devtab[c->type] == &ssldevtab){ |
| 1463 | 1444 | cclose(c); |
| 1464 | 1445 | error("cannot ssl encrypt devssl files"); |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | #include "fns.h" |
| 8 | 8 | #include "error.h" |
| 9 | 9 | |
| 10 | −#include "libsec.h" | |
| 10 | +#include <libsec.h> | |
| 11 | 11 | |
| 12 | 12 | typedef struct OneWay OneWay; |
| 13 | 13 | typedef struct Secret Secret; |
| @@ -421,21 +421,7 @@ static Chan* · 407 unmodified lines | ||
| 421 | 421 | tlsopen(Chan *c, int omode) |
| 422 | 422 | { |
| 423 | 423 | TlsRec *tr, **pp; |
| 424 | − int t, perm; | |
| 425 | − | |
| 426 | − perm = 0; | |
| 427 | − omode &= 3; | |
| 428 | − switch(omode) { | |
| 429 | − case OREAD: | |
| 430 | − perm = 4; | |
| 431 | − break; | |
| 432 | − case OWRITE: | |
| 433 | − perm = 2; | |
| 434 | − break; | |
| 435 | − case ORDWR: | |
| 436 | − perm = 6; | |
| 437 | − break; | |
| 438 | − } | |
| 424 | + int t; | |
| 439 | 425 | |
| 440 | 426 | t = TYPE(c->qid); |
| 441 | 427 | switch(t) { |
| @@ -468,10 +454,7 @@ tlsopen(Chan *c, int omode) · 26 unmodified lines | ||
| 468 | 454 | tr = *pp; |
| 469 | 455 | if(tr == nil) |
| 470 | 456 | error("must open connection using clone"); |
| 471 | − if((perm & (tr->perm>>6)) != perm | |
| 472 | − && (strcmp(up->user, tr->user) != 0 | |
| 473 | − || (perm & tr->perm) != perm)) | |
| 474 | − error(Eperm); | |
| 457 | + devpermcheck(tr->user, tr->perm, omode); | |
| 475 | 458 | if(t == Qhand){ |
| 476 | 459 | if(waserror()){ |
| 477 | 460 | unlock(&tr->hqlock); |
| @@ -1886,7 +1869,7 @@ buftochan(char *p) · 1408 unmodified lines | ||
| 1886 | 1869 | fd = strtoul(p, 0, 0); |
| 1887 | 1870 | if(fd < 0) |
| 1888 | 1871 | error(Ebadarg); |
| 1889 | − c = fdtochan(fd, -1, 0, 1); /* error check and inc ref */ | |
| 1872 | + c = fdtochan(fd, ORDWR, 1, 1); /* error check and inc ref */ | |
| 1890 | 1873 | return c; |
| 1891 | 1874 | } |
| 1892 | 1875 | |