]> skyeroc.xyz Git - dgamelaunch/commitdiff
Document error codes. Make all error conditions return unique error codes.
authorPasi Kallinen <paxed@alt.org>
Mon, 10 Oct 2011 19:06:20 +0000 (19:06 +0000)
committerPasi Kallinen <paxed@alt.org>
Mon, 10 Oct 2011 19:06:20 +0000 (19:06 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@619 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

README
config.l
config.y
dgamelaunch.c

diff --git a/README b/README
index 37985b723d0c079facf7fffca9518952c3a2ec50..1ebbcf99e18a8d1c6eb541e2f22bdcde61d7f1b8 100644 (file)
--- a/README
+++ b/README
@@ -115,3 +115,71 @@ works, a shell login or (x)inetd will work with the correct configuration.
 If you have problems with dgamelaunch's display make sure that your chroot's
 /etc/terminfo directory (or whatever directory your ncurses uses) is
 populated.
+
+
+ERROR CODES
+===========
+
+   1   Could not terminate stale processes
+   2   Cannot chroot()
+   3   Cannot chdir()
+   4   Cannot setgroups()
+   5   Cannot setgid()
+   6   Cannot setuid()
+   7   Caught HUP
+   8   Cannot run as root: Config file has shed_user = "root"
+   9   Cannot run as root: Config file has shed_user set to UID 0 user.
+  10   Could not setup player
+  11   Cannot run as root: Config file has shed_uid = 0
+  12   Config file has an unrecognized token
+  13   Config file: Negative value not accepted
+  20   No menu defined, or no banner found for menu
+  61   Cannot openpty()
+  62   Cannot open /dev/ptmx
+  65   Cannot open master ptsname
+  68   Cannot fcntl inprogress-lock
+  70   Cannot write to inprogress-lock
+  71   ftok() error for shm_key, no "dgamelaunch" file found?
+  72   ftok() error for shm_sem_key, no "dgamelaunch" file found?
+  73   shmget() error, cannot connect to shared memory
+  74   smat() error, cannot attach to shared memory
+  75   Nothing in shared memory?
+  76   sem_init() error, could not initialize shared memory
+  77   sem_wait() error
+  78   sem_post() error
+  95   Cannot fnctl lockfile
+  96   sqlite3_open() failed when checking user existence: could not open login database
+  97   sqlite3_open() failed in writefile()
+  98   sqlite3_exec() failed in writefile()
+  99   Could not open password file
+ 100   Username field too long in login file
+ 101   Email field too long in login file
+ 102   password field too long in login file
+ 103   env field too long in login file
+ 104   Cannot read config file
+ 105   Cannot read default config file
+ 106   Cannot open lockfile or password file
+ 107   fcntl failed on login database in writefile()
+ 108   sqlite3_exec() failed when checking user existence.
+ 109   Too many registered users. (see maxusers setting in config file)
+ 110   Login failed
+ 111   Two users trying to register at the same time
+ 112   Error changing password: cannot have ':' in password
+ 113   Error parsing configuration file
+ 114   exec-command fork failed
+ 115   could not read lock file in writefile()
+ 116   Too many registered users. (see maxusers setting in config file)
+ 117   wall error: no message to send
+ 118   wall error: no players
+ 119   User has a retarded terminal
+ 120   wall error: message too long
+ 121   wall error: "from" username is too short
+ 122   Error changing password: struct "me" does not exist
+ 123   chdir() failed in dgl commands.
+ 140   populate_games(): Cannot open inprogress-dir
+ 145   populate_games(): Inprogress-filename does not have ':' in it
+ 146   populate_games(): Inprogress-filename does not have ': in it (pt. 2)
+ 200   purge_stale_locks(): could not open inprogress-dir
+ 201   purge_stale_locks(): inprogress-file did not have ':' in it
+ 202   purge_stale_locks(): could not read inprogress-file
+ 203   purge_stale_locks(): could not get inprogress-file contents
index 382064310008940ed76535a29f4c059eed56c5b6..467cbd0cd0a52046e243cdee856f63d901b6170b 100644 (file)
--- a/config.l
+++ b/config.l
@@ -27,7 +27,7 @@ WHITE         [\t ]*
 {NEGNUMBER} {
   fprintf(stderr,"%s:%d: negative value not accepted! Fix it now!\n",
       config, line);
-  graceful_exit(1);
+  graceful_exit(13);
 }
 
 {NUMBER} { 
@@ -126,7 +126,7 @@ DEFINE              { return TYPE_DEFINE_GAME; }
 
 [0-9a-zA-Z_]+ {
   fprintf(stderr, "%s:%d:%d unrecognized token \"%s\"\n", config, line, col, yytext);
-  graceful_exit(1);
+  graceful_exit(12);
 }
 
 %%
index 0216abe69ab92b9daaad6ab29d5d6667f2bba65f..e6d847d81e713d89a63ade9a888f54bc51761cd8 100644 (file)
--- a/config.y
+++ b/config.y
@@ -140,7 +140,7 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']'
       if (!strcmp($3, "root"))
       {
         fprintf(stderr, "%s:%d: I refuse to run as root! Aborting.\n", config, line);
-       graceful_exit(1);
+       graceful_exit(8);
       }
       globalconfig.shed_user = strdup($3);
       if ((usr = getpwnam($3)) != NULL)
@@ -155,7 +155,7 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']'
        else
        {
          fprintf(stderr, "%s:%d: I refuse to run as %s (uid 0!) Aborting.\n", config, line, $3);
-         graceful_exit(1);
+         graceful_exit(9);
        }
       }
       else
@@ -247,7 +247,7 @@ KeyPair: TYPE_CMDQUEUE '[' TYPE_CMDQUEUENAME ']'
       if ($3 == 0)
       {
         fprintf(stderr, "%s:%d: I refuse to run as uid 0 (root)! Aborting.\n", config, line);
-        graceful_exit(1);
+        graceful_exit(11);
       }
 
       globalconfig.shed_uid = $3;
index bbbf3ca88f6de0daeaaafe5d5ab8dc82937da231..3641b1c7226b889376424d0855241c184fedbb35 100644 (file)
@@ -175,7 +175,7 @@ ttyrec_getpty ()
 #ifdef HAVE_OPENPTY
     if (openpty (&master, &slave, NULL, NULL, NULL) == -1) {
        debug_write("cannot openpty");
-       graceful_exit (62);
+       graceful_exit (61);
     }
 #else
     if ((master = open ("/dev/ptmx", O_RDWR)) < 0) {
@@ -329,7 +329,7 @@ catch_sighup (int signum)
   signals_release();
 #endif
   debug_write("catchup sighup");
-  graceful_exit (2);
+  graceful_exit (7);
 }
 
 /* ************************************************************* */
@@ -1978,7 +1978,7 @@ readfile (int nolock)
       }
       if (fcntl (fileno (fpl), F_SETLKW, &fl) == -1) {
          debug_write("cannot fcntl lockfile");
-        graceful_exit (114);
+        graceful_exit (95);
       }
     }
 
@@ -2054,7 +2054,7 @@ readfile (int nolock)
           b++;
           if ((b - n) >= 1024) {
              debug_write("env field too long");
-            graceful_exit (102);
+            graceful_exit (103);
          }
         }
 
@@ -2157,7 +2157,7 @@ userexist (char *cname, int isnew)
     if (ret) {
        sqlite3_close(db);
        debug_write("sqlite3_open failed");
-       graceful_exit(109);
+       graceful_exit(96);
     }
 
     if (userexist_tmp_me) {
@@ -2278,7 +2278,7 @@ writefile (int requirenew)
     {
        signals_release();
       debug_write("passwd file fopen failed");
-      graceful_exit (104);
+      graceful_exit (99);
     }
 
   for (i = 0; i < f_num; i++)
@@ -2345,7 +2345,7 @@ writefile (int requirenew)
     if (ret) {
        sqlite3_close(db);
        debug_write("writefile sqlite3_open failed");
-       graceful_exit(107);
+       graceful_exit(97);
     }
 
     sqlite3_busy_timeout(db, 10000);
@@ -2356,7 +2356,7 @@ writefile (int requirenew)
     if (ret != SQLITE_OK) {
        sqlite3_close(db);
        debug_write("writefile sqlite3_exec failed");
-       graceful_exit(106);
+       graceful_exit(98);
     }
     sqlite3_close(db);
 }
@@ -2719,32 +2719,32 @@ main (int argc, char** argv)
       if (chroot (globalconfig.chroot))
        {
          perror ("cannot change root directory");
-         graceful_exit (1);
+         graceful_exit (2);
        }
 
       if (chdir ("/"))
        {
          perror ("cannot chdir to root directory");
-         graceful_exit (1);
+         graceful_exit (3);
        }
 
       /* shed privs. this is done immediately after chroot. */
       if (setgroups (1, &globalconfig.shed_gid) == -1)
        {
          perror ("setgroups");
-         graceful_exit (1);
+         graceful_exit (4);
        }
 
       if (setgid (globalconfig.shed_gid) == -1)
        {
          perror ("setgid");
-         graceful_exit (1);
+         graceful_exit (5);
        }
 
       if (setuid (globalconfig.shed_uid) == -1)
        {
          perror ("setuid");
-         graceful_exit (1);
+         graceful_exit (6);
        }
     }
 
@@ -2792,7 +2792,7 @@ main (int argc, char** argv)
          }
          else {
                fprintf(stdout, "Setup of %s failed.\n", p);
-               graceful_exit(1);
+               graceful_exit(10);
          }
   }
 
@@ -2844,7 +2844,7 @@ main (int argc, char** argv)
 
   freebanner(&banner);
   banner_var_free();
-  graceful_exit (1);
+  graceful_exit (20);
 
   return 1;
 }