]> skyeroc.xyz Git - dgamelaunch/commitdiff
SECURITY: accept only argument following -f for dgamelaunch.conf path
authorJoshua Kwan <joshk@triplehelix.org>
Mon, 2 Feb 2004 22:57:54 +0000 (22:57 +0000)
committerJoshua Kwan <joshk@triplehelix.org>
Mon, 2 Feb 2004 22:57:54 +0000 (22:57 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@218 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

README
dgamelaunch.c

diff --git a/README b/README
index e24e22948b7716cde0570070e15bfd79605456a5..6d6453644ca62e99b779ca0a04cd3ec80905ac01 100644 (file)
--- a/README
+++ b/README
@@ -77,14 +77,14 @@ service telnet
   wait      = no
   user      = root
   server    = /usr/sbin/in.telnetd
-  server_args     = -h -L /opt/nethack/nethack.dtype.org/dgamelaunch -q /etc/dgamelaunch.conf
+  server_args     = -h -L /opt/nethack/nethack.dtype.org/dgamelaunch -q -f /etc/dgamelaunch.conf
   rlimit_cpu      = 3600
   bind      = 64.71.163.206
 }
 
 A classic inetd line would look like this:
 
-telnet stream tcp nowait root.root /usr/sbin/tcpd /usr/sbin/in.telnetd -h -L /usr/sbin/dgamelaunch -q /etc/dgamelaunch.conf
+telnet stream tcp nowait root.root /usr/sbin/tcpd /usr/sbin/in.telnetd -h -L /usr/sbin/dgamelaunch -q -f /etc/dgamelaunch.conf
 
 In both cases, the -L specifies an alternate login program (telnetlogin is
 invoked by default) and -h prevents revealing of a login banner (for 
@@ -100,6 +100,9 @@ telnetd uses -p instead, and you can't give arguments (arguments appropriate
 to standard login are used), so it's necessary to start a shell script from
 it.  Some other telnetds do not support anything like this at all.
 
+The -f option, followed by a filename, specifies the path to the config file
+to use for dgamelaunch.
+
 For dgamelaunch, the -q option will silence errors pertaining to the server
 configuration. This is recommended for use within inetd to prevent spamming
 the clients, but when testing and setting up we strongly suggest you leave it
index 3408a3211587d9ea39dc1d8173b16ea0196f4650..e6074e40fd948bccc4a801873be6c5a346a56c5c 100644 (file)
@@ -1480,33 +1480,29 @@ main (int argc, char** argv)
   unsigned int len;
   int c;
 
-  while ((c = getopt(argc, argv, "qh:p")) != -1)
+  while ((c = getopt(argc, argv, "qh:p:f:")) != -1)
   {
     switch (c)
     {
       case 'q':
        silent = 1; break;
 
+      case 'f':
+       if (config)
+       {
+         if (!silent)
+           fprintf(stderr, "warning: using %s\n", argv[optind]);
+         free(config);
+       }
+         
+       config = strdup(optarg);
+       break;
+       
       default:
        break; /*ignore */
     }
   }
   
-  if (optind < argc)
-  {
-    while (optind < argc)
-    {
-      if (config)
-      {
-       if (!silent)
-         fprintf(stderr, "warning: using %s\n", argv[optind]);
-       free(config);
-      }
-      config = strdup(argv[optind]);
-      optind++;
-    }
-  }
-
   create_config();
 
   /* signal handlers */