From 8b9c796b10eada38203999ed8c5300902d96c690 Mon Sep 17 00:00:00 2001 From: Joshua Kwan Date: Wed, 21 Jan 2004 01:57:44 +0000 Subject: [PATCH] Add ability to change location of passwd and lockfile. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@137 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- config.l | 2 ++ config.y | 25 +++++++++++++++++++------ dgamelaunch.c | 10 ++++++---- dgamelaunch.conf | 5 +++++ dgamelaunch.h | 2 ++ 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/config.l b/config.l index 8ee48a6..11146c4 100644 --- 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; } diff --git a/config.y b/config.y index c211e26..5382444 100644 --- 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 TYPE_VALUE %token TYPE_NUMBER %type 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; } ; %% diff --git a/dgamelaunch.c b/dgamelaunch.c index e1dab33..a6c07b0 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -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); diff --git a/dgamelaunch.conf b/dgamelaunch.conf index dfed64b..9fdd204 100644 --- a/dgamelaunch.conf +++ b/dgamelaunch.conf @@ -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" diff --git a/dgamelaunch.h b/dgamelaunch.h index e980ee1..f8189ad 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -42,6 +42,8 @@ struct dg_config char* chroot; char* nethack; char* dglroot; + char* lockfile; + char* passwd; char* banner; char* rcfile; char* spool; -- 2.47.3