MCPcopy Create free account
hub / github.com/NetHack/NetHack / check_user_string

Function check_user_string

sys/unix/unixmain.c:695–729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

693}
694
695boolean
696check_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
731static struct passwd *
732get_unix_pw(void)

Callers 3

authorize_wizard_modeFunction · 0.70
authorize_explore_modeFunction · 0.70
doshFunction · 0.70

Calls 3

eosFunction · 0.85
isspaceFunction · 0.85
get_unix_pwFunction · 0.70

Tested by

no test coverage detected