Allow setting max nick length in the dgl config file, while still retaining backwards compatibility with old-style, up to 20-char
long nicks. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@347 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
687239516b
commit
731caa2fcf
1
config.l
1
config.l
|
@ -56,6 +56,7 @@ COMMENT ^#.*
|
|||
"shed_uid" { return TYPE_SUID; }
|
||||
"shed_gid" { return TYPE_SGID; }
|
||||
"maxusers" { return TYPE_MAX; }
|
||||
"maxnicklen" { return TYPE_MAXNICKLEN; }
|
||||
|
||||
"game_num" { return TYPE_GAMENUM; }
|
||||
|
||||
|
|
8
config.y
8
config.y
|
@ -30,7 +30,7 @@ static const char* lookup_token (int t);
|
|||
unsigned long i;
|
||||
}
|
||||
|
||||
%token TYPE_SUSER TYPE_SGROUP TYPE_SGID TYPE_SUID TYPE_MAX
|
||||
%token TYPE_SUSER TYPE_SGROUP TYPE_SGID TYPE_SUID TYPE_MAX TYPE_MAXNICKLEN
|
||||
%token TYPE_PATH_GAME TYPE_NAME_GAME TYPE_PATH_DGLDIR TYPE_PATH_SPOOL
|
||||
%token TYPE_PATH_BANNER TYPE_PATH_CANNED TYPE_PATH_CHROOT TYPE_GAMENUM
|
||||
%token TYPE_PATH_PASSWD TYPE_PATH_LOCKFILE TYPE_PATH_SAVEFILEFMT
|
||||
|
@ -270,6 +270,10 @@ KeyPair: KeyType '=' TYPE_VALUE {
|
|||
globalconfig.max = $3;
|
||||
break;
|
||||
|
||||
case TYPE_MAXNICKLEN:
|
||||
globalconfig.max_newnick_len = $3;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "%s:%d: token %s does not take a number, bailing out\n",
|
||||
config, line, lookup_token($1));
|
||||
|
@ -282,6 +286,7 @@ KeyType : TYPE_SUSER { $$ = TYPE_SUSER; }
|
|||
| TYPE_SUID { $$ = TYPE_SUID; }
|
||||
| TYPE_SGID { $$ = TYPE_SGID; }
|
||||
| TYPE_MAX { $$ = TYPE_MAX; }
|
||||
| TYPE_MAXNICKLEN { $$ = TYPE_MAXNICKLEN; }
|
||||
| TYPE_GAMENUM { $$ = TYPE_GAMENUM; }
|
||||
| TYPE_PATH_CHROOT { $$ = TYPE_PATH_CHROOT; }
|
||||
| TYPE_PATH_GAME { $$ = TYPE_PATH_GAME; }
|
||||
|
@ -309,6 +314,7 @@ const char* lookup_token (int t)
|
|||
case TYPE_SUID: return "shed_uid";
|
||||
case TYPE_SGID: return "shed_gid";
|
||||
case TYPE_MAX: return "maxusers";
|
||||
case TYPE_MAXNICKLEN: return "maxnicklen";
|
||||
case TYPE_GAMENUM: return "game_num";
|
||||
case TYPE_PATH_CHROOT: return "chroot_path";
|
||||
case TYPE_PATH_GAME: return "game_path";
|
||||
|
|
|
@ -837,7 +837,7 @@ void
|
|||
autologin (char* user, char *pass)
|
||||
{
|
||||
int me_index = -1;
|
||||
if ((me_index = userexist(user)) != -1)
|
||||
if ((me_index = userexist(user, 0)) != -1)
|
||||
{
|
||||
me = users[me_index];
|
||||
if (passwordgood(pass))
|
||||
|
@ -877,6 +877,7 @@ loginprompt (int from_ttyplay)
|
|||
|
||||
refresh ();
|
||||
|
||||
/* keep this at 20 chars for hysterical raisins */
|
||||
mygetnstr (user_buf, 20, 1);
|
||||
|
||||
if (user_buf && *user_buf == '\0')
|
||||
|
@ -884,7 +885,7 @@ loginprompt (int from_ttyplay)
|
|||
|
||||
error = 1;
|
||||
|
||||
if ((me_index = userexist (user_buf)) != -1)
|
||||
if ((me_index = userexist (user_buf, 0)) != -1)
|
||||
{
|
||||
me = users[me_index];
|
||||
error = 0;
|
||||
|
@ -953,12 +954,14 @@ newuser ()
|
|||
{
|
||||
clear ();
|
||||
|
||||
sprintf(buf, "%i character max.", globalconfig.max_newnick_len);
|
||||
|
||||
drawbanner (1, 1);
|
||||
|
||||
mvaddstr (5, 1, "Welcome new user. Please enter a username.");
|
||||
mvaddstr (6, 1,
|
||||
"Only characters and numbers are allowed, with no spaces.");
|
||||
mvaddstr (7, 1, "20 character max.");
|
||||
mvaddstr (7, 1, buf);
|
||||
mvaddstr (9, 1, "=> ");
|
||||
|
||||
if (error == 1)
|
||||
|
@ -969,8 +972,8 @@ newuser ()
|
|||
|
||||
refresh ();
|
||||
|
||||
mygetnstr (buf, 20, 1);
|
||||
if (userexist (buf) == -1)
|
||||
mygetnstr (buf, globalconfig.max_newnick_len, 1);
|
||||
if (userexist (buf, 1) == -1)
|
||||
error = 0;
|
||||
else
|
||||
error = 1;
|
||||
|
@ -1189,13 +1192,13 @@ readfile (int nolock)
|
|||
/* ************************************************************* */
|
||||
|
||||
int
|
||||
userexist (char *cname)
|
||||
userexist (char *cname, int isnew)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < f_num; i++)
|
||||
{
|
||||
if (!strncasecmp (cname, users[i]->username, 20))
|
||||
if (!strncasecmp (cname, users[i]->username, (isnew ? globalconfig.max_newnick_len : 20)))
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -1714,7 +1717,7 @@ authenticate ()
|
|||
return 1;
|
||||
}
|
||||
|
||||
if ((me_index = userexist (user_buf)) != -1)
|
||||
if ((me_index = userexist (user_buf, 0)) != -1)
|
||||
{
|
||||
me = users[me_index];
|
||||
if (passwordgood (pw_buf))
|
||||
|
|
|
@ -62,6 +62,7 @@ struct dg_globalconfig
|
|||
char* dglroot;
|
||||
char* banner;
|
||||
unsigned long max;
|
||||
int max_newnick_len; /* maximum length of new registered names. must be less than 20 chars. */
|
||||
char* shed_user;
|
||||
char* shed_group;
|
||||
uid_t shed_uid;
|
||||
|
@ -102,7 +103,7 @@ extern void newuser(void);
|
|||
extern void autologin(char *user, char *pass);
|
||||
extern int passwordgood(char *cpw);
|
||||
extern int readfile(int nolock);
|
||||
extern int userexist(char *cname);
|
||||
extern int userexist(char *cname, int isnew);
|
||||
extern void write_canned_rcfile(int game, char *target);
|
||||
extern void editoptions(int game);
|
||||
extern void writefile(int requirenew);
|
||||
|
|
|
@ -338,6 +338,7 @@ create_config ()
|
|||
if (!globalconfig.chroot) globalconfig.chroot = "/var/lib/dgamelaunch/";
|
||||
|
||||
if (globalconfig.max == 0) globalconfig.max = 64000;
|
||||
if (globalconfig.max_newnick_len == 0) globalconfig.max_newnick_len = 20;
|
||||
if (!globalconfig.dglroot) globalconfig.dglroot = "/dgldir/";
|
||||
if (!globalconfig.banner) globalconfig.banner = "/dgl-banner";
|
||||
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
# Max amount of registered users to allow.
|
||||
maxusers = 64000
|
||||
|
||||
# Max length for newly registered nicks. Must be less than 20.
|
||||
# By default, NetHack only stores the first 10 chars of a name into
|
||||
# the record/logfile.
|
||||
maxnicklen = 10
|
||||
|
||||
# Path to a prepared chroot jail.
|
||||
chroot_path = "/var/lib/dgamelaunch/"
|
||||
|
||||
|
|
Loading…
Reference in New Issue