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:
Pasi Kallinen
2016-02-05 20:39:13 +02:00
parent 0ca477486d
commit fe006b9c0a
8 changed files with 27 additions and 2 deletions

View File

@@ -3276,6 +3276,10 @@ SEDUCE
0 or 1 to disable or enable, respectively, the SEDUCE option (see the source
for details on this function).
.lp
CHECK_PLNAME
Setting this to 1 will make the EXPLORERS, WIZARDS, and SHELLERS check
for the player name instead of the user's login name.
.lp
CHECK_SAVE_UID
0 or 1 to disable or enable, respectively, the UID checking for savefiles.
.pg

View File

@@ -3905,6 +3905,10 @@ A string explaining how to recover a game on this system (no default value).
0 or 1 to disable or enable, respectively, the SEDUCE option (see the source)
for details on this function.
%.lp
\item[\ib{CHECK\verb+_+PLNAME}]
Setting this to 1 will make the EXPLORERS, WIZARDS, and SHELLERS check
for the player name instead of the user's login name.
%.lp
\item[\ib{CHECK\verb+_+SAVE\verb+_+UID}]
0 or 1 to disable or enable, respectively, the UID checking for savefiles.
\elist

View File

@@ -179,6 +179,8 @@ X11: enable a scroll bar in menu windows
X11: support pre-selected entries in menu windows
X11: make the extended command menu be easier to use and look a little nicer
X11: make the getline text entry widget display a bigger text entry area
unix: add CHECK_PLNAME-option to sysconf to make WIZARDS, EXPLORERS, and
SHELLERS check player name instead of user's login name
General New Features

View File

@@ -22,6 +22,7 @@ struct sysopt {
int maxplayers;
int seduce;
int check_save_uid; /* restoring savefile checks UID? */
int check_plname; /* use plname for checking wizards/explorers/shellers */
/* record file */
int persmax;

View File

@@ -2264,6 +2264,10 @@ int src;
&& match_varname(buf, "CHECK_SAVE_UID", 14)) {
n = atoi(bufp);
sysopt.check_save_uid = n;
} else if (src == SET_IN_SYS
&& match_varname(buf, "CHECK_PLNAME", 12)) {
n = atoi(bufp);
sysopt.check_plname = n;
} else if (match_varname(buf, "SEDUCE", 6)) {
n = !!atoi(bufp); /* XXX this could be tighter */
/* allow anyone to turn it off, but only sysconf to turn it on*/

View File

@@ -72,6 +72,7 @@ sys_early_init()
#endif
sysopt.check_save_uid = 1;
sysopt.check_plname = 0;
sysopt.seduce = 1; /* if it's compiled in, default to on */
sysopt_seduce_set(sysopt.seduce);
return;

View File

@@ -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

View File

@@ -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;
}