diff --git a/config.y b/config.y index d21b882..fd31bd3 100644 --- a/config.y +++ b/config.y @@ -156,7 +156,11 @@ KeyPair: KeyType '=' TYPE_VALUE { } | KeyType '=' TYPE_NUMBER { if (!myconfig) + { myconfig = calloc(1, sizeof(struct dg_config)); + myconfig->shed_uid = (uid_t)-1; + myconfig->shed_gid = (gid_t)-1; + } switch ($1) { @@ -184,6 +188,7 @@ KeyPair: KeyType '=' TYPE_VALUE { break; case TYPE_MAX: + set_max = 1; /* XXX XXX */ myconfig->max = $3; break; diff --git a/dgamelaunch.c b/dgamelaunch.c index 408c7cb..91244de 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -109,6 +109,7 @@ struct dg_config defconfig = { /* max = */ 64000 }; +int set_max = 0; /* XXX */ int loggedin = 0; char rcfilename[80]; char *chosen_name; @@ -181,7 +182,7 @@ create_config () myconfig->shed_gid = defconfig.shed_gid; } - if (myconfig->max == -1) myconfig->max = defconfig.max; + if (myconfig->max == 0 && !set_max) myconfig->max = defconfig.max; if (!myconfig->banner) myconfig->banner = defconfig.banner; if (!myconfig->chroot) myconfig->chroot = defconfig.chroot; if (!myconfig->nethack) myconfig->nethack = defconfig.nethack; @@ -1093,7 +1094,10 @@ readfile (int nolock) f_num++; /* prevent a buffer overrun here */ if (f_num > myconfig->max) + { + fprintf(stderr,"ERROR: number of users in database exceeds maximum. Exiting.\n"); graceful_exit (109); + } } if (!nolock) diff --git a/dgamelaunch.h b/dgamelaunch.h index 57a143d..a7f3541 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -60,6 +60,7 @@ extern struct dg_config *myconfig; extern char *chosen_name; extern int loggedin; extern int silent; +extern int set_max; /* dgamelaunch.c */ extern void create_config(void);