Add CHECK_PLNAME to sysconf
Setting CHECK_PLNAME to 1 makes WIZARDS, EXPLORERS, and SHELLERS check the player name instead of the user's login name. This is mostly useful for public servers which have external login system and don't create user accounts for players.
This commit is contained in:
@@ -30,6 +30,10 @@ EXPLORERS=*
|
||||
# Uses the same syntax as the WIZARDS and EXPLORERS options above.
|
||||
#SHELLERS=
|
||||
|
||||
# Use the player name for matching WIZARDS, EXPLORERS and SHELLERS,
|
||||
# instead of the user's login name.
|
||||
#CHECK_PLNAME=1
|
||||
|
||||
# Limit the number of simultaneous games (see also nethack.sh).
|
||||
# Valid values are 0-25.
|
||||
# Commenting this out or setting the value to 0 constructs lock files
|
||||
|
||||
@@ -621,11 +621,16 @@ char *optstr;
|
||||
struct passwd *pw = get_unix_pw();
|
||||
int pwlen;
|
||||
char *eop, *w;
|
||||
char *pwname;
|
||||
if (optstr[0] == '*')
|
||||
return TRUE; /* allow any user */
|
||||
if (!pw)
|
||||
return FALSE;
|
||||
pwlen = strlen(pw->pw_name);
|
||||
if (sysopt.check_plname)
|
||||
pwname = plname;
|
||||
else
|
||||
pwname = pw->pw_name;
|
||||
pwlen = strlen(pwname);
|
||||
eop = eos(optstr);
|
||||
w = optstr;
|
||||
while (w + pwlen <= eop) {
|
||||
@@ -635,7 +640,7 @@ char *optstr;
|
||||
w++;
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(w, pw->pw_name, pwlen)) {
|
||||
if (!strncmp(w, pwname, pwlen)) {
|
||||
if (!w[pwlen] || isspace(w[pwlen]))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user