]> granicus.if.org Git - nethack/commitdiff
Add CHECK_PLNAME to sysconf
authorPasi Kallinen <paxed@alt.org>
Fri, 5 Feb 2016 18:39:13 +0000 (20:39 +0200)
committerPasi Kallinen <paxed@alt.org>
Fri, 5 Feb 2016 18:39:17 +0000 (20:39 +0200)
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.

doc/Guidebook.mn
doc/Guidebook.tex
doc/fixes36.1
include/sys.h
src/files.c
src/sys.c
sys/unix/sysconf
sys/unix/unixmain.c

index f03853b6c2e93e036682a807c58b5f38cef93007..a6a39f44128edc84cdb84e2359c1ed5509e4729c 100644 (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
index 110f4248c216ba771b436a472756f83de8ab337d..5f13e784f7dd82b28b883abf5f130a51bcbd2cfb 100644 (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
index f8bb03ff7be661c7cc27828f263d095cc923539f..47120a06d205f0b2b09c6cc031bf3ecc7b58e48b 100644 (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
index 10b7c3c5f588cd6e367f03f6b4fdd1352f49b269..d2989a84282f99f79be6a04da4c39b6e79dec4a8 100644 (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;
index f8a767257853f4a0c46e2ded1cdbe2b219255220..8553bc309a17e161431b86ad48fccac4a708ee8a 100644 (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*/
index 96c080ea45263ef64899e5c4852cca40faa11e62..c56e75feca6b9f1dee2a3b27107e4423b4ea78bd 100644 (file)
--- a/src/sys.c
+++ b/src/sys.c
@@ -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;
index 1347a7a9e0d0f0b8086e9811df930c6b4c899832..85ab25bf741a06524eff8126ecfb12626cbd4a42 100644 (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
index 506618f14cb133e5bbdd917d29ec44d97a28c386..2d6452ce84c89957b37e9148de226790fe9c7ed9 100644 (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;
         }