move junk around, genericize things
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@287 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
61c7349a86
commit
4d45d4d263
|
@ -1,11 +1,13 @@
|
|||
1.4.5 (????/??/??)
|
||||
* Reset offset if necessary to show at least one game to avoid things
|
||||
* Reset offset if necessary to show at least one game to avoid things
|
||||
like "(15-14 of 14)".
|
||||
* Provide several examples for dgl-create-chroot.conf.
|
||||
* Backup the savefile before starting nethack to help prevent more
|
||||
lost games. Note this must be explicitly configured in the
|
||||
configuration file.
|
||||
* Added ^W for delete word in mygetnstr().
|
||||
* Begun generalization of code so that someone can get it to work
|
||||
with stuff like Slash'EM etc. easier.
|
||||
|
||||
1.4.4 (2004/03/07)
|
||||
* Show total number of games in progress below the list, useful if
|
||||
|
|
3
config.l
3
config.l
|
@ -58,7 +58,8 @@ COMMENT ^#.*
|
|||
"maxusers" { return TYPE_MAX; }
|
||||
|
||||
"chroot_path" { return TYPE_PATH_CHROOT; }
|
||||
"nethack" { return TYPE_PATH_NETHACK; }
|
||||
"game_name" { return TYPE_NAME_GAME; }
|
||||
"game_path" { return TYPE_PATH_GAME; }
|
||||
"dglroot" { return TYPE_PATH_DGLDIR; }
|
||||
"spooldir" { return TYPE_PATH_SPOOL; }
|
||||
"banner" { return TYPE_PATH_BANNER; }
|
||||
|
|
20
config.y
20
config.y
|
@ -26,7 +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_GAME TYPE_NAME_GAME TYPE_PATH_DGLDIR TYPE_PATH_SPOOL
|
||||
%token TYPE_PATH_BANNER TYPE_PATH_CANNED TYPE_PATH_CHROOT
|
||||
%token TYPE_PATH_PASSWD TYPE_PATH_LOCKFILE TYPE_PATH_SAVEFILEFMT
|
||||
%token TYPE_MALSTRING
|
||||
|
@ -113,9 +113,14 @@ KeyPair: KeyType '=' TYPE_VALUE {
|
|||
myconfig->chroot = strdup ($3);
|
||||
break;
|
||||
|
||||
case TYPE_PATH_NETHACK:
|
||||
if (myconfig->nethack) free(myconfig->nethack);
|
||||
myconfig->nethack = strdup ($3);
|
||||
case TYPE_PATH_GAME:
|
||||
if (myconfig->game_path) free(myconfig->game_path);
|
||||
myconfig->game_path = strdup ($3);
|
||||
break;
|
||||
|
||||
case TYPE_NAME_GAME:
|
||||
if (myconfig->game_name) free (myconfig->game_name);
|
||||
myconfig->game_name = strdup($3);
|
||||
break;
|
||||
|
||||
case TYPE_PATH_DGLDIR:
|
||||
|
@ -214,7 +219,8 @@ KeyType : TYPE_SUSER { $$ = TYPE_SUSER; }
|
|||
| TYPE_SGID { $$ = TYPE_SGID; }
|
||||
| TYPE_MAX { $$ = TYPE_MAX; }
|
||||
| TYPE_PATH_CHROOT { $$ = TYPE_PATH_CHROOT; }
|
||||
| TYPE_PATH_NETHACK { $$ = TYPE_PATH_NETHACK; }
|
||||
| TYPE_PATH_GAME { $$ = TYPE_PATH_GAME; }
|
||||
| TYPE_NAME_GAME { $$ = TYPE_NAME_GAME; }
|
||||
| TYPE_PATH_DGLDIR { $$ = TYPE_PATH_DGLDIR; }
|
||||
| TYPE_PATH_SPOOL { $$ = TYPE_PATH_SPOOL; }
|
||||
| TYPE_PATH_BANNER { $$ = TYPE_PATH_BANNER; }
|
||||
|
@ -236,11 +242,13 @@ const char* lookup_token (int t)
|
|||
case TYPE_SGID: return "shed_gid";
|
||||
case TYPE_MAX: return "maxusers";
|
||||
case TYPE_PATH_CHROOT: return "chroot_path";
|
||||
case TYPE_PATH_NETHACK: return "nethack";
|
||||
case TYPE_PATH_GAME: return "game_path";
|
||||
case TYPE_NAME_GAME: return "game_name";
|
||||
case TYPE_PATH_DGLDIR: return "dglroot";
|
||||
case TYPE_PATH_SPOOL: return "spooldir";
|
||||
case TYPE_PATH_BANNER: return "banner";
|
||||
case TYPE_PATH_CANNED: return "rc_template";
|
||||
case TYPE_PATH_SAVEFILEFMT: return "savefilefmt";
|
||||
default: abort();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -689,7 +689,7 @@ drawmenu ()
|
|||
mvaddstr (banner.len + 5, 1, "e) Change email address");
|
||||
mvaddstr (banner.len + 6, 1, "o) Edit option file");
|
||||
mvaddstr (banner.len + 7, 1, "w) Watch games in progress");
|
||||
mvaddstr (banner.len + 8, 1, "p) Play nethack!");
|
||||
mvprintw (banner.len + 8, 1, "p) Play %s!", myconfig->game_name);
|
||||
mvaddstr (banner.len + 9, 1, "q) Quit");
|
||||
mvaddstr (banner.len + 11, 1, "=> ");
|
||||
}
|
||||
|
@ -1391,8 +1391,6 @@ backup_savefile (void)
|
|||
return n >= 0;
|
||||
}
|
||||
|
||||
/* TODO: Some of the messages here (sorry no nethack for you!) are nethack specific
|
||||
* as may be some code... don't think so though. Globalize it. */
|
||||
int
|
||||
purge_stale_locks (void)
|
||||
{
|
||||
|
@ -1453,7 +1451,8 @@ purge_stale_locks (void)
|
|||
|
||||
#define HUP_WAIT 10 /* seconds before HUPPING */
|
||||
mvprintw (3, 1,
|
||||
"There are some stale Nethack processes, will recover in %d seconds.", HUP_WAIT);
|
||||
"There are some stale %s processes, will recover in %d seconds.",
|
||||
myconfig->game_name, HUP_WAIT);
|
||||
mvaddstr (4, 1,
|
||||
"Press a key NOW if you don't want this to happen!");
|
||||
|
||||
|
@ -1494,8 +1493,8 @@ purge_stale_locks (void)
|
|||
sleep (1);
|
||||
if (seconds == 10)
|
||||
{
|
||||
mvaddstr (3, 1,
|
||||
"Couldn't terminate one of your stale Nethack processes gracefully.");
|
||||
mvprintw (3, 1,
|
||||
"Couldn't terminate one of your stale %s processes gracefully.", myconfig->game_name);
|
||||
mvaddstr (4, 1, "Force its termination? [yn] ");
|
||||
if (tolower (getch ()) == 'y')
|
||||
{
|
||||
|
@ -1505,8 +1504,8 @@ purge_stale_locks (void)
|
|||
else
|
||||
{
|
||||
endwin ();
|
||||
fprintf (stderr, "Sorry, no nethack for you now, please "
|
||||
"contact the admin.\n");
|
||||
fprintf (stderr, "Sorry, no %s for you now, please "
|
||||
"contact the admin.\n", myconfig->game_name);
|
||||
graceful_exit (1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ struct dg_game
|
|||
struct dg_config
|
||||
{
|
||||
char* chroot;
|
||||
char* nethack;
|
||||
char* game_path;
|
||||
char* game_name;
|
||||
char* dglroot;
|
||||
char* lockfile;
|
||||
char* passwd;
|
||||
|
|
|
@ -18,7 +18,8 @@ extern int yyparse ();
|
|||
struct dg_config *myconfig = NULL;
|
||||
struct dg_config defconfig = {
|
||||
/* chroot = */ "/var/lib/dgamelaunch/",
|
||||
/* nethack = */ "/bin/nethack",
|
||||
/* game_path = */ "/bin/nethack",
|
||||
/* game_name = */ "NetHack",
|
||||
/* dglroot = */ "/dgldir/",
|
||||
/* lockfile = */ "/dgl-lock",
|
||||
/* passwd = */ "/dgl-login",
|
||||
|
@ -232,7 +233,8 @@ create_config ()
|
|||
if (myconfig->max == 0 && !set_max) myconfig->max = defconfig.max;
|
||||
if (!myconfig->banner) myconfig->banner = defconfig.banner;
|
||||
if (!myconfig->chroot) myconfig->chroot = defconfig.chroot;
|
||||
if (!myconfig->nethack) myconfig->nethack = defconfig.nethack;
|
||||
if (!myconfig->game_path) myconfig->game_path = defconfig.game_path;
|
||||
if (!myconfig->game_name) myconfig->game_name = defconfig.game_name;
|
||||
if (!myconfig->dglroot) myconfig->dglroot = defconfig.dglroot;
|
||||
if (!myconfig->rcfile) myconfig->rcfile = defconfig.rcfile;
|
||||
if (!myconfig->spool) myconfig->spool = defconfig.spool;
|
||||
|
|
|
@ -26,8 +26,9 @@ maxusers = 64000
|
|||
# Path to a prepared chroot jail.
|
||||
chroot_path = "/var/lib/dgamelaunch/"
|
||||
|
||||
# From inside the jail, the location of the nethack binary.
|
||||
nethack = "/bin/nethack"
|
||||
# From inside the jail, the location of the binary to be launched.
|
||||
game_path = "/bin/nethack"
|
||||
game_name = "NetHack"
|
||||
|
||||
# From inside the jail, dgamelaunch's working directory for rcfiles/ttyrec/etc
|
||||
dglroot = "/dgldir/"
|
4
ttyrec.c
4
ttyrec.c
|
@ -262,7 +262,7 @@ dooutput ()
|
|||
void
|
||||
doshell (char *username)
|
||||
{
|
||||
char *argv1 = myconfig->nethack;
|
||||
char *argv1 = myconfig->game_path;
|
||||
char *argv2 = "-u";
|
||||
char *myargv[10];
|
||||
|
||||
|
@ -279,7 +279,7 @@ doshell (char *username)
|
|||
myargv[2] = username;
|
||||
myargv[3] = 0;
|
||||
|
||||
execvp (myconfig->nethack, myargv);
|
||||
execvp (myconfig->game_path, myargv);
|
||||
|
||||
fail ();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue