]> skyeroc.xyz Git - dgamelaunch/commitdiff
Kludge to detect 'maxusers = 0' and handle f_num > myconfig->max more smoothly
authorJoshua Kwan <joshk@triplehelix.org>
Sun, 1 Feb 2004 08:20:28 +0000 (08:20 +0000)
committerJoshua Kwan <joshk@triplehelix.org>
Sun, 1 Feb 2004 08:20:28 +0000 (08:20 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@205 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

config.y
dgamelaunch.c
dgamelaunch.h

index d21b8826dabe26c7cd05235553e5663cd027818d..fd31bd3f619d090daf4cab0ce1f8ebc1a167dc60 100644 (file)
--- 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;
 
index 408c7cba9efc8019b3abc95c0303c20b8b2996fb..91244def7850f43a995c17a6f753615170adb1aa 100644 (file)
@@ -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)
index 57a143dc8826f31b74045b30747ed6fa27673753..a7f3541bfff9ea351192b792880cf07b7f570f94 100644 (file)
@@ -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);