Add ability to change location of passwd and lockfile.
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@137 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
7c8eebf836
commit
8b9c796b10
2
config.l
2
config.l
|
@ -59,6 +59,8 @@ LONGCOMMENT "/*"
|
||||||
"spooldir" { return TYPE_PATH_SPOOL; }
|
"spooldir" { return TYPE_PATH_SPOOL; }
|
||||||
"banner" { return TYPE_PATH_BANNER; }
|
"banner" { return TYPE_PATH_BANNER; }
|
||||||
"rc_template" { return TYPE_PATH_CANNED; }
|
"rc_template" { return TYPE_PATH_CANNED; }
|
||||||
|
"passwd" { return TYPE_PATH_PASSWD; }
|
||||||
|
"lockfile" { return TYPE_PATH_LOCKFILE; }
|
||||||
|
|
||||||
\n { line++; col = 0; }
|
\n { line++; col = 0; }
|
||||||
|
|
||||||
|
|
25
config.y
25
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_SUSER TYPE_SGROUP TYPE_SGID TYPE_SUID TYPE_MAX
|
||||||
%token TYPE_PATH_NETHACK TYPE_PATH_DGLDIR TYPE_PATH_SPOOL
|
%token TYPE_PATH_NETHACK TYPE_PATH_DGLDIR TYPE_PATH_SPOOL
|
||||||
%token TYPE_PATH_BANNER TYPE_PATH_CANNED TYPE_PATH_CHROOT
|
%token TYPE_PATH_BANNER TYPE_PATH_CANNED TYPE_PATH_CHROOT
|
||||||
|
%token TYPE_PATH_PASSWD TYPE_PATH_LOCKFILE
|
||||||
%token <s> TYPE_VALUE
|
%token <s> TYPE_VALUE
|
||||||
%token <i> TYPE_NUMBER
|
%token <i> TYPE_NUMBER
|
||||||
%type <kt> KeyType
|
%type <kt> KeyType
|
||||||
|
@ -84,32 +85,42 @@ KeyPair: KeyType '=' TYPE_VALUE {
|
||||||
|
|
||||||
case TYPE_PATH_CHROOT:
|
case TYPE_PATH_CHROOT:
|
||||||
if (myconfig->chroot) free(myconfig->chroot);
|
if (myconfig->chroot) free(myconfig->chroot);
|
||||||
myconfig->chroot = strdup ($3);
|
myconfig->chroot = strdup ($3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_PATH_NETHACK:
|
case TYPE_PATH_NETHACK:
|
||||||
if (myconfig->nethack) free(myconfig->nethack);
|
if (myconfig->nethack) free(myconfig->nethack);
|
||||||
myconfig->nethack = strdup ($3);
|
myconfig->nethack = strdup ($3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_PATH_DGLDIR:
|
case TYPE_PATH_DGLDIR:
|
||||||
if (myconfig->dglroot) free(myconfig->dglroot);
|
if (myconfig->dglroot) free(myconfig->dglroot);
|
||||||
myconfig->dglroot = strdup ($3);
|
myconfig->dglroot = strdup ($3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_PATH_BANNER:
|
case TYPE_PATH_BANNER:
|
||||||
if (myconfig->banner) free(myconfig->banner);
|
if (myconfig->banner) free(myconfig->banner);
|
||||||
myconfig->banner = strdup($3);
|
myconfig->banner = strdup($3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_PATH_CANNED:
|
case TYPE_PATH_CANNED:
|
||||||
if (myconfig->rcfile) free(myconfig->rcfile);
|
if (myconfig->rcfile) free(myconfig->rcfile);
|
||||||
myconfig->rcfile = strdup($3);
|
myconfig->rcfile = strdup($3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_PATH_SPOOL:
|
case TYPE_PATH_SPOOL:
|
||||||
if (myconfig->spool) free (myconfig->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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -171,6 +182,8 @@ KeyType : TYPE_SUSER { $$ = TYPE_SUSER; }
|
||||||
| TYPE_PATH_SPOOL { $$ = TYPE_PATH_SPOOL; }
|
| TYPE_PATH_SPOOL { $$ = TYPE_PATH_SPOOL; }
|
||||||
| TYPE_PATH_BANNER { $$ = TYPE_PATH_BANNER; }
|
| TYPE_PATH_BANNER { $$ = TYPE_PATH_BANNER; }
|
||||||
| TYPE_PATH_CANNED { $$ = TYPE_PATH_CANNED; }
|
| TYPE_PATH_CANNED { $$ = TYPE_PATH_CANNED; }
|
||||||
|
| TYPE_PATH_PASSWD { $$ = TYPE_PATH_PASSWD; }
|
||||||
|
| TYPE_PATH_LOCKFILE { $$ = TYPE_PATH_LOCKFILE; }
|
||||||
;
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
|
@ -109,6 +109,8 @@ struct dg_config defconfig = {
|
||||||
"/var/lib/dgamelaunch/",
|
"/var/lib/dgamelaunch/",
|
||||||
"/bin/nethack",
|
"/bin/nethack",
|
||||||
"/dgldir/",
|
"/dgldir/",
|
||||||
|
"/dgl-lock",
|
||||||
|
"/dgl-login",
|
||||||
"/dgl-banner",
|
"/dgl-banner",
|
||||||
"/dgl-default-rcfile",
|
"/dgl-default-rcfile",
|
||||||
"/var/mail/",
|
"/var/mail/",
|
||||||
|
@ -1000,14 +1002,14 @@ readfile (int nolock)
|
||||||
|
|
||||||
if (!nolock)
|
if (!nolock)
|
||||||
{
|
{
|
||||||
fpl = fopen ("/dgl-lock", "r");
|
fpl = fopen (myconfig->lockfile, "r");
|
||||||
if (!fpl)
|
if (!fpl)
|
||||||
graceful_exit (106);
|
graceful_exit (106);
|
||||||
if (fcntl (fileno (fpl), F_SETLKW, &fl) == -1)
|
if (fcntl (fileno (fpl), F_SETLKW, &fl) == -1)
|
||||||
graceful_exit (114);
|
graceful_exit (114);
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = fopen ("/dgl-login", "r");
|
fp = fopen (myconfig->passwd, "r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
graceful_exit (106);
|
graceful_exit (106);
|
||||||
|
|
||||||
|
@ -1191,7 +1193,7 @@ writefile (int requirenew)
|
||||||
fl.l_start = 0;
|
fl.l_start = 0;
|
||||||
fl.l_len = 0;
|
fl.l_len = 0;
|
||||||
|
|
||||||
fpl = fopen ("/dgl-lock", "r+");
|
fpl = fopen (myconfig->lockfile, "r+");
|
||||||
if (!fpl)
|
if (!fpl)
|
||||||
graceful_exit (115);
|
graceful_exit (115);
|
||||||
if (fcntl (fileno (fpl), F_SETLK, &fl))
|
if (fcntl (fileno (fpl), F_SETLK, &fl))
|
||||||
|
@ -1202,7 +1204,7 @@ writefile (int requirenew)
|
||||||
freefile ();
|
freefile ();
|
||||||
readfile (1);
|
readfile (1);
|
||||||
|
|
||||||
fp = fopen ("/dgl-login", "w");
|
fp = fopen (myconfig->passwd, "w");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
graceful_exit (104);
|
graceful_exit (104);
|
||||||
|
|
||||||
|
|
|
@ -38,4 +38,9 @@ banner = "/dgl-banner"
|
||||||
# From inside the jail, the default .nethackrc that is copied for new users.
|
# From inside the jail, the default .nethackrc that is copied for new users.
|
||||||
rc_template = "/dgl-default-rcfile"
|
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"
|
||||||
|
|
|
@ -42,6 +42,8 @@ struct dg_config
|
||||||
char* chroot;
|
char* chroot;
|
||||||
char* nethack;
|
char* nethack;
|
||||||
char* dglroot;
|
char* dglroot;
|
||||||
|
char* lockfile;
|
||||||
|
char* passwd;
|
||||||
char* banner;
|
char* banner;
|
||||||
char* rcfile;
|
char* rcfile;
|
||||||
char* spool;
|
char* spool;
|
||||||
|
|
Loading…
Reference in New Issue