|
Lines 488-511
static int
Link Here
|
| 488 |
match_cfg_line_group(const char *grps, int line, const char *user) |
488 |
match_cfg_line_group(const char *grps, int line, const char *user) |
| 489 |
{ |
489 |
{ |
| 490 |
int result = 0; |
490 |
int result = 0; |
| 491 |
u_int ngrps = 0; |
|
|
| 492 |
char *arg, *p, *cp, *grplist[MAX_MATCH_GROUPS]; |
| 493 |
struct passwd *pw; |
491 |
struct passwd *pw; |
| 494 |
|
492 |
|
| 495 |
/* |
|
|
| 496 |
* Even if we do not have a user yet, we still need to check for |
| 497 |
* valid syntax. |
| 498 |
*/ |
| 499 |
arg = cp = xstrdup(grps); |
| 500 |
while ((p = strsep(&cp, ",")) != NULL && *p != '\0') { |
| 501 |
if (ngrps >= MAX_MATCH_GROUPS) { |
| 502 |
error("line %d: too many groups in Match Group", line); |
| 503 |
result = -1; |
| 504 |
goto out; |
| 505 |
} |
| 506 |
grplist[ngrps++] = p; |
| 507 |
} |
| 508 |
|
| 509 |
if (user == NULL) |
493 |
if (user == NULL) |
| 510 |
goto out; |
494 |
goto out; |
| 511 |
|
495 |
|
|
Lines 515-531
match_cfg_line_group(const char *grps, i
Link Here
|
| 515 |
} else if (ga_init(pw->pw_name, pw->pw_gid) == 0) { |
499 |
} else if (ga_init(pw->pw_name, pw->pw_gid) == 0) { |
| 516 |
debug("Can't Match group because user %.100s not in any group " |
500 |
debug("Can't Match group because user %.100s not in any group " |
| 517 |
"at line %d", user, line); |
501 |
"at line %d", user, line); |
| 518 |
} else if (ga_match(grplist, ngrps) != 1) { |
502 |
} else if (ga_match_pattern_list(grps) != 1) { |
| 519 |
debug("user %.100s does not match group %.100s at line %d", |
503 |
debug("user %.100s does not match group list %.100s at line %d", |
| 520 |
user, arg, line); |
504 |
user, grps, line); |
| 521 |
} else { |
505 |
} else { |
| 522 |
debug("user %.100s matched group %.100s at line %d", user, |
506 |
debug("user %.100s matched group list %.100s at line %d", user, |
| 523 |
arg, line); |
507 |
grps, line); |
| 524 |
result = 1; |
508 |
result = 1; |
| 525 |
} |
509 |
} |
| 526 |
out: |
510 |
out: |
| 527 |
ga_free(); |
511 |
ga_free(); |
| 528 |
xfree(arg); |
|
|
| 529 |
return result; |
512 |
return result; |
| 530 |
} |
513 |
} |
| 531 |
|
514 |
|