| 693 | } |
| 694 | |
| 695 | boolean |
| 696 | check_user_string(const char *optstr) |
| 697 | { |
| 698 | struct passwd *pw; |
| 699 | int pwlen; |
| 700 | const char *eop, *w; |
| 701 | char *pwname = 0; |
| 702 | |
| 703 | if (optstr[0] == '*') |
| 704 | return TRUE; /* allow any user */ |
| 705 | if (sysopt.check_plname) |
| 706 | pwname = svp.plname; |
| 707 | else if ((pw = get_unix_pw()) != 0) |
| 708 | pwname = pw->pw_name; |
| 709 | if (!pwname || !*pwname) |
| 710 | return FALSE; |
| 711 | pwlen = (int) strlen(pwname); |
| 712 | eop = eos((char *) optstr); /* temporarily cast away 'const' */ |
| 713 | w = optstr; |
| 714 | while (w + pwlen <= eop) { |
| 715 | if (!*w) |
| 716 | break; |
| 717 | if (isspace(*w)) { |
| 718 | w++; |
| 719 | continue; |
| 720 | } |
| 721 | if (!strncmp(w, pwname, pwlen)) { |
| 722 | if (!w[pwlen] || isspace(w[pwlen])) |
| 723 | return TRUE; |
| 724 | } |
| 725 | while (*w && !isspace(*w)) |
| 726 | w++; |
| 727 | } |
| 728 | return FALSE; |
| 729 | } |
| 730 | |
| 731 | static struct passwd * |
| 732 | get_unix_pw(void) |
no test coverage detected