From 7b3bcd72d7e1d5533f51adbc291b0e319d731a9e Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 9 Apr 2007 16:42:14 +0000 Subject: [PATCH] Config-file variable allow_new_nicks git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@360 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- config.l | 1 + config.y | 7 +++++++ dgamelaunch.c | 7 +++++-- dgamelaunch.h | 1 + dgl-common.c | 2 ++ examples/dgamelaunch.conf | 3 +++ 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/config.l b/config.l index d41dcb5..c736d1b 100644 --- a/config.l +++ b/config.l @@ -57,6 +57,7 @@ COMMENT ^#.* "shed_gid" { return TYPE_SGID; } "maxusers" { return TYPE_MAX; } "maxnicklen" { return TYPE_MAXNICKLEN; } +"allow_new_nicks" { return TYPE_ALLOW_REGISTRATION; } "game_num" { return TYPE_GAMENUM; } diff --git a/config.y b/config.y index 58a554e..465eb2e 100644 --- a/config.y +++ b/config.y @@ -32,6 +32,7 @@ static const char* lookup_token (int t); %token TYPE_SUSER TYPE_SGROUP TYPE_SGID TYPE_SUID TYPE_MAX TYPE_MAXNICKLEN %token TYPE_PATH_CHDIR TYPE_PATH_MKDIR TYPE_GAME_SHORT_NAME +%token TYPE_ALLOW_REGISTRATION %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 @@ -282,6 +283,10 @@ KeyPair: KeyType '=' TYPE_VALUE { num_games = ncnf; break; + case TYPE_ALLOW_REGISTRATION: + globalconfig.allow_registration = $3; + break; + case TYPE_MAX: globalconfig.max = $3; break; @@ -305,6 +310,7 @@ KeyType : TYPE_SUSER { $$ = TYPE_SUSER; } | TYPE_MAXNICKLEN { $$ = TYPE_MAXNICKLEN; } | TYPE_GAMENUM { $$ = TYPE_GAMENUM; } | TYPE_PATH_CHROOT { $$ = TYPE_PATH_CHROOT; } + | TYPE_ALLOW_REGISTRATION { $$ = TYPE_ALLOW_REGISTRATION; } | TYPE_PATH_GAME { $$ = TYPE_PATH_GAME; } | TYPE_NAME_GAME { $$ = TYPE_NAME_GAME; } | TYPE_GAME_SHORT_NAME { $$ = TYPE_GAME_SHORT_NAME; } @@ -340,6 +346,7 @@ const char* lookup_token (int t) case TYPE_PATH_MKDIR: return "mkdir"; case TYPE_PATH_GAME: return "game_path"; case TYPE_NAME_GAME: return "game_name"; + case TYPE_ALLOW_REGISTRATION: return "allow_new_nicks"; case TYPE_GAME_SHORT_NAME: return "short_name"; case TYPE_PATH_DGLDIR: return "dglroot"; case TYPE_PATH_SPOOL: return "spooldir"; diff --git a/dgamelaunch.c b/dgamelaunch.c index 15aeff2..7a83ce8 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -774,7 +774,10 @@ drawmenu () { mvaddstr (banner.len + 2, 1, "Not logged in."); mvaddstr (banner.len + 4, 1, "l) Login"); - mvaddstr (banner.len + 5, 1, "r) Register new user"); + if (globalconfig.allow_registration) + mvaddstr (banner.len + 5, 1, "r) Register new user"); + else + mvaddstr (banner.len + 5, 1, " Register new user - DISABLED"); mvaddstr (banner.len + 6, 1, "w) Watch games in progress"); mvaddstr (banner.len + 7, 1, "q) Quit"); mvaddstr (banner.len + 11, 1, "=> "); @@ -1619,7 +1622,7 @@ gamemenuloop(int game) graceful_exit(0);*/ /* break; */ case 'r': - if (!loggedin) /*not visible to loggedin */ + if (!loggedin && globalconfig.allow_registration) newuser (); break; case 'l': diff --git a/dgamelaunch.h b/dgamelaunch.h index af87eb3..035380a 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -71,6 +71,7 @@ struct dg_globalconfig gid_t shed_gid; char* passwd; char* lockfile; + int allow_registration; /* allow registering new nicks */ }; /* Global variables */ diff --git a/dgl-common.c b/dgl-common.c index f07c759..f9d3839 100644 --- a/dgl-common.c +++ b/dgl-common.c @@ -276,6 +276,8 @@ create_config () FILE *config_file = NULL; int tmp; + if (!globalconfig.allow_registration) globalconfig.allow_registration = 1; + if (config) { if ((config_file = fopen(config, "r")) != NULL) diff --git a/examples/dgamelaunch.conf b/examples/dgamelaunch.conf index 76542b7..2925fef 100644 --- a/examples/dgamelaunch.conf +++ b/examples/dgamelaunch.conf @@ -10,6 +10,9 @@ # Max amount of registered users to allow. maxusers = 64000 +# Allow registration of new nicks? (0 or 1) +allow_new_nicks = 1 + # 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.