From 942ee14d0ff1ee172858d5a0615c10c872583d39 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 13 Jun 2016 11:01:05 +0300 Subject: [PATCH] Move generic usernames to sysconf --- include/config.h | 5 ----- include/sys.h | 1 + src/files.c | 3 +++ src/role.c | 21 ++++++++++----------- src/sys.c | 4 ++++ sys/unix/sysconf | 5 +++++ 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/config.h b/include/config.h index 47b2951cc..9fc7dc6fe 100644 --- a/include/config.h +++ b/include/config.h @@ -364,11 +364,6 @@ */ #endif /* CHDIR */ -/* If GENERIC_USERNAMES is defined, and the player's username is found - * in the list, prompt for character name instead of using username. - * A public server should probably disable this. */ -#define GENERIC_USERNAMES "play player game games nethack nethacker" - /* * Section 3: Definitions that may vary with system type. * For example, both schar and uchar should be short ints on diff --git a/include/sys.h b/include/sys.h index d2989a842..bf652ede2 100644 --- a/include/sys.h +++ b/include/sys.h @@ -13,6 +13,7 @@ struct sysopt { or "one or two" or "one, two, or three", &c */ char *explorers; /* like wizards, but for access to explore mode */ char *shellers; /* like wizards, for ! command (-DSHELL); also ^Z */ + char *genericusers; /* usernames that prompt for user name */ char *debugfiles; /* files to show debugplines in. '*' is all. */ int env_dbgfl; /* 1: debugfiles comes from getenv("DEBUGFILES") * so sysconf's DEBUGFILES shouldn't override it; diff --git a/src/files.c b/src/files.c index 51a76f188..646737dab 100644 --- a/src/files.c +++ b/src/files.c @@ -2263,6 +2263,9 @@ int src; free((genericptr_t) sysopt.debugfiles); sysopt.debugfiles = dupstr(bufp); } + } else if (src == SET_IN_SYS && match_varname(buf, "GENERICUSERS", 12)) { + if (sysopt.genericusers) free(sysopt.genericusers); + sysopt.genericusers = dupstr(bufp); } else if (src == SET_IN_SYS && match_varname(buf, "SUPPORT", 7)) { if (sysopt.support) free((genericptr_t) sysopt.support); diff --git a/src/role.c b/src/role.c index 3bee60d61..5a1a4ab56 100644 --- a/src/role.c +++ b/src/role.c @@ -1700,18 +1700,17 @@ plnamesuffix() char *sptr, *eptr; int i; -#ifdef GENERIC_USERNAMES - { - /* some generic user names will be ignored in favor of prompting */ - const char *uptr = GENERIC_USERNAMES; - - i = (int) strlen(plname); - if ((sptr = strstri(uptr, plname)) != 0 - && (sptr == uptr || sptr[-1] == ' ') - && (sptr[i] == ' ' || sptr[i] == '\0')) - *plname = '\0'; /* call askname() */ + /* some generic user names will be ignored in favor of prompting */ + if (sysopt.genericusers) { + if (*sysopt.genericusers == '*') *plname = '\0'; + else { + i = (int)strlen(plname); + if ((sptr = strstri(sysopt.genericusers, plname)) != 0 + && (sptr == sysopt.genericusers || sptr[-1] == ' ') + && (sptr[i] == ' ' || sptr[i] == '\0')) + *plname = '\0'; /* call askname() */ + } } -#endif do { if (!*plname) diff --git a/src/sys.c b/src/sys.c index c56e75fec..deab17eb5 100644 --- a/src/sys.c +++ b/src/sys.c @@ -35,6 +35,7 @@ sys_early_init() sysopt.env_dbgfl = 0; /* haven't checked getenv("DEBUGFILES") yet */ sysopt.shellers = (char *) 0; sysopt.explorers = (char *) 0; + sysopt.genericusers = (char *) 0; sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */ /* record file */ @@ -94,6 +95,9 @@ sysopt_release() if (sysopt.debugfiles) free((genericptr_t) sysopt.debugfiles), sysopt.debugfiles = (char *) 0; + if (sysopt.genericusers) + free((genericptr_t) sysopt.genericusers), + sysopt.genericusers = (char *) 0; #ifdef PANICTRACE if (sysopt.gdbpath) free((genericptr_t) sysopt.gdbpath), sysopt.gdbpath = (char *) 0; diff --git a/sys/unix/sysconf b/sys/unix/sysconf index 85ab25bf7..f7426f785 100644 --- a/sys/unix/sysconf +++ b/sys/unix/sysconf @@ -30,6 +30,11 @@ EXPLORERS=* # Uses the same syntax as the WIZARDS and EXPLORERS options above. #SHELLERS= +# If the user name is found in this list, prompt for username instead. +# Uses the same syntax as the WIZARDS option above. +# A public server should probably disable this. +GENERICUSERS=play player game games nethack nethacker + # Use the player name for matching WIZARDS, EXPLORERS and SHELLERS, # instead of the user's login name. #CHECK_PLNAME=1 -- 2.40.0