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:17 +02:00
parent 0ca477486d
commit fe006b9c0a
8 changed files with 27 additions and 2 deletions
+4
View File
@@ -3276,6 +3276,10 @@ SEDUCE
0 or 1 to disable or enable, respectively, the SEDUCE option (see the source 0 or 1 to disable or enable, respectively, the SEDUCE option (see the source
for details on this function). for details on this function).
.lp .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 CHECK_SAVE_UID
0 or 1 to disable or enable, respectively, the UID checking for savefiles. 0 or 1 to disable or enable, respectively, the UID checking for savefiles.
.pg .pg
+4
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) 0 or 1 to disable or enable, respectively, the SEDUCE option (see the source)
for details on this function. for details on this function.
%.lp %.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}] \item[\ib{CHECK\verb+_+SAVE\verb+_+UID}]
0 or 1 to disable or enable, respectively, the UID checking for savefiles. 0 or 1 to disable or enable, respectively, the UID checking for savefiles.
\elist \elist
+2
View File
@@ -179,6 +179,8 @@ X11: enable a scroll bar in menu windows
X11: support pre-selected entries 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 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 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 General New Features
+1
View File
@@ -22,6 +22,7 @@ struct sysopt {
int maxplayers; int maxplayers;
int seduce; int seduce;
int check_save_uid; /* restoring savefile checks UID? */ int check_save_uid; /* restoring savefile checks UID? */
int check_plname; /* use plname for checking wizards/explorers/shellers */
/* record file */ /* record file */
int persmax; int persmax;
+4
View File
@@ -2264,6 +2264,10 @@ int src;
&& match_varname(buf, "CHECK_SAVE_UID", 14)) { && match_varname(buf, "CHECK_SAVE_UID", 14)) {
n = atoi(bufp); n = atoi(bufp);
sysopt.check_save_uid = n; 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)) { } else if (match_varname(buf, "SEDUCE", 6)) {
n = !!atoi(bufp); /* XXX this could be tighter */ n = !!atoi(bufp); /* XXX this could be tighter */
/* allow anyone to turn it off, but only sysconf to turn it on*/ /* allow anyone to turn it off, but only sysconf to turn it on*/
+1
View File
@@ -72,6 +72,7 @@ sys_early_init()
#endif #endif
sysopt.check_save_uid = 1; sysopt.check_save_uid = 1;
sysopt.check_plname = 0;
sysopt.seduce = 1; /* if it's compiled in, default to on */ sysopt.seduce = 1; /* if it's compiled in, default to on */
sysopt_seduce_set(sysopt.seduce); sysopt_seduce_set(sysopt.seduce);
return; return;
+4
View File
@@ -30,6 +30,10 @@ EXPLORERS=*
# Uses the same syntax as the WIZARDS and EXPLORERS options above. # Uses the same syntax as the WIZARDS and EXPLORERS options above.
#SHELLERS= #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). # Limit the number of simultaneous games (see also nethack.sh).
# Valid values are 0-25. # Valid values are 0-25.
# Commenting this out or setting the value to 0 constructs lock files # Commenting this out or setting the value to 0 constructs lock files
+7 -2
View File
@@ -621,11 +621,16 @@ char *optstr;
struct passwd *pw = get_unix_pw(); struct passwd *pw = get_unix_pw();
int pwlen; int pwlen;
char *eop, *w; char *eop, *w;
char *pwname;
if (optstr[0] == '*') if (optstr[0] == '*')
return TRUE; /* allow any user */ return TRUE; /* allow any user */
if (!pw) if (!pw)
return FALSE; return FALSE;
pwlen = strlen(pw->pw_name); if (sysopt.check_plname)
pwname = plname;
else
pwname = pw->pw_name;
pwlen = strlen(pwname);
eop = eos(optstr); eop = eos(optstr);
w = optstr; w = optstr;
while (w + pwlen <= eop) { while (w + pwlen <= eop) {
@@ -635,7 +640,7 @@ char *optstr;
w++; w++;
continue; continue;
} }
if (!strncmp(w, pw->pw_name, pwlen)) { if (!strncmp(w, pwname, pwlen)) {
if (!w[pwlen] || isspace(w[pwlen])) if (!w[pwlen] || isspace(w[pwlen]))
return TRUE; return TRUE;
} }