]> skyeroc.xyz Git - dgamelaunch/commitdiff
Add ability to change location of passwd and lockfile.
authorJoshua Kwan <joshk@triplehelix.org>
Wed, 21 Jan 2004 01:57:44 +0000 (01:57 +0000)
committerJoshua Kwan <joshk@triplehelix.org>
Wed, 21 Jan 2004 01:57:44 +0000 (01:57 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@137 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

config.l
config.y
dgamelaunch.c
dgamelaunch.conf
dgamelaunch.h

index 8ee48a6731097df743860dbaa39f1d83d46d5934..11146c4f1762ed3478332196ea9935e3e1e79e7f 100644 (file)
--- a/config.l
+++ b/config.l
@@ -59,6 +59,8 @@ LONGCOMMENT   "/*"
 "spooldir"     { return TYPE_PATH_SPOOL; }
 "banner"       { return TYPE_PATH_BANNER; }
 "rc_template"  { return TYPE_PATH_CANNED; }
+"passwd"       { return TYPE_PATH_PASSWD; }
+"lockfile"     { return TYPE_PATH_LOCKFILE; }
 
 \n             { line++; col = 0; }
 
index c211e26027a8c85a32f0addd84d53a40b8214d38..53824440551aaf21a6493e41d64abbee95cd8531 100644 (file)
--- a/config.y
+++ b/config.y
@@ -26,6 +26,7 @@ static const char* lookup_token (int t);
 %token TYPE_SUSER TYPE_SGROUP TYPE_SGID TYPE_SUID TYPE_MAX
 %token TYPE_PATH_NETHACK TYPE_PATH_DGLDIR TYPE_PATH_SPOOL
 %token TYPE_PATH_BANNER TYPE_PATH_CANNED TYPE_PATH_CHROOT
+%token TYPE_PATH_PASSWD TYPE_PATH_LOCKFILE
 %token <s> TYPE_VALUE
 %token <i> TYPE_NUMBER
 %type  <kt> KeyType
@@ -84,32 +85,42 @@ KeyPair: KeyType '=' TYPE_VALUE {
 
     case TYPE_PATH_CHROOT:
       if (myconfig->chroot) free(myconfig->chroot);
-        myconfig->chroot = strdup ($3);
+      myconfig->chroot = strdup ($3);
       break;
 
     case TYPE_PATH_NETHACK:
       if (myconfig->nethack) free(myconfig->nethack);
-        myconfig->nethack = strdup ($3);
+      myconfig->nethack = strdup ($3);
       break;
 
     case TYPE_PATH_DGLDIR:
       if (myconfig->dglroot) free(myconfig->dglroot);
-        myconfig->dglroot = strdup ($3);
+      myconfig->dglroot = strdup ($3);
       break;
 
     case TYPE_PATH_BANNER:
       if (myconfig->banner) free(myconfig->banner);
-        myconfig->banner = strdup($3);
+      myconfig->banner = strdup($3);
       break;
 
     case TYPE_PATH_CANNED:
       if (myconfig->rcfile) free(myconfig->rcfile);
-        myconfig->rcfile = strdup($3);
+      myconfig->rcfile = strdup($3);
       break;
 
     case TYPE_PATH_SPOOL:
       if (myconfig->spool) free (myconfig->spool);
-        myconfig->spool = strdup($3);
+      myconfig->spool = strdup($3);
+      break;
+
+    case TYPE_PATH_LOCKFILE:
+      if (myconfig->lockfile) free (myconfig->lockfile);
+      myconfig->lockfile = strdup($3);
+      break;
+
+    case TYPE_PATH_PASSWD:
+      if (myconfig->passwd) free(myconfig->passwd);
+      myconfig->passwd = strdup($3);
       break;
 
     default:
@@ -171,6 +182,8 @@ KeyType : TYPE_SUSER        { $$ = TYPE_SUSER; }
        | TYPE_PATH_SPOOL       { $$ = TYPE_PATH_SPOOL; }
        | TYPE_PATH_BANNER      { $$ = TYPE_PATH_BANNER; }
        | TYPE_PATH_CANNED      { $$ = TYPE_PATH_CANNED; }
+       | TYPE_PATH_PASSWD      { $$ = TYPE_PATH_PASSWD; }
+       | TYPE_PATH_LOCKFILE    { $$ = TYPE_PATH_LOCKFILE; }
        ;
 
 %%
index e1dab337b94bef82dfea01e551565635bfa3311b..a6c07b0d55495bbccd315f0281a5c78ff378e5f1 100644 (file)
@@ -109,6 +109,8 @@ struct dg_config defconfig = {
   "/var/lib/dgamelaunch/",
   "/bin/nethack",
   "/dgldir/",
+  "/dgl-lock",
+  "/dgl-login",
   "/dgl-banner",
   "/dgl-default-rcfile",
   "/var/mail/",
@@ -1000,14 +1002,14 @@ readfile (int nolock)
 
   if (!nolock)
     {
-      fpl = fopen ("/dgl-lock", "r");
+      fpl = fopen (myconfig->lockfile, "r");
       if (!fpl)
         graceful_exit (106);
       if (fcntl (fileno (fpl), F_SETLKW, &fl) == -1)
         graceful_exit (114);
     }
 
-  fp = fopen ("/dgl-login", "r");
+  fp = fopen (myconfig->passwd, "r");
   if (!fp)
     graceful_exit (106);
 
@@ -1191,7 +1193,7 @@ writefile (int requirenew)
   fl.l_start = 0;
   fl.l_len = 0;
 
-  fpl = fopen ("/dgl-lock", "r+");
+  fpl = fopen (myconfig->lockfile, "r+");
   if (!fpl)
     graceful_exit (115);
   if (fcntl (fileno (fpl), F_SETLK, &fl))
@@ -1202,7 +1204,7 @@ writefile (int requirenew)
   freefile ();
   readfile (1);
 
-  fp = fopen ("/dgl-login", "w");
+  fp = fopen (myconfig->passwd, "w");
   if (!fp)
     graceful_exit (104);
 
index dfed64bcd6010e4fa8922ca7d9f04cb05aa5a68f..9fdd20464d049cbe6a6bb8b3e5eb90543f40f7a8 100644 (file)
@@ -38,4 +38,9 @@ banner = "/dgl-banner"
 # From inside the jail, the default .nethackrc that is copied for new users.
 rc_template = "/dgl-default-rcfile"
 
+# The defaults are usually just fine for this. passwd refers to the file
+# that stores the user database, and lockfile is only used internally by
+# dgamelaunch.
 
+passwd = "/dgl-login"
+lockfile = "/dgl-lock"
index e980ee1475f5e328108182eede2cdf78117536aa..f8189ada91ddc9c1b28a038527fc3b0ef51e90c5 100644 (file)
@@ -42,6 +42,8 @@ struct dg_config
   char* chroot;
   char* nethack;
   char* dglroot;
+  char* lockfile;
+  char* passwd;
   char* banner;
   char* rcfile;
   char* spool;