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
"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; }
}
%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
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:
| 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; }
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();
}
}
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, "=> ");
}
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)
{
#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!");
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')
{
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);
}
}
+++ /dev/null
-# This is a sample dgamelaunch configuration file. Only bash-style comments
-# are allowed, such as this. Each configuration option will be explained
-# along with its default value.
-
-# The following two options are fairly insecure. They will force us to
-# load the password/group database into memory while still having root
-# privileges. Replace them with shed_uid/shed_gid entries as soon as
-# possible if you decide to use them. dgamelaunch will inform you of
-# the uids/gids corresponding to your choices when it loads.
-#
-# Note that shed_uid and shed_gid will always take precedence over
-# shed_user and shed_group if they are specified.
-
-# shed_user: username to shed privileges to
-shed_user = "games"
-# shed_group: group name to shed privileges to
-shed_group = "games"
-
-# Preferably, you may use the respective gids/uids. This is for Debian:
-shed_uid = 5
-shed_gid = 60
-
-# Max amount of registered users to allow.
-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, dgamelaunch's working directory for rcfiles/ttyrec/etc
-dglroot = "/dgldir/"
-
-# From inside the jail, where dgamelaunch should put mail - should match up with
-# NetHack settings.
-spooldir = "/var/mail/"
-
-# From inside the jail, location of a banner file that contains no more than
-# 14 lines of 80-column width text. Any more will be truncated.
-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"
-
-# From inside the jail, the path to the savefile. %u is replaced by the
-# decimal representation of shed_uid, %n is replaced by the player's
-# user name. Before starting the game, this file is copied to its name
-# with ".bak" appended. Set to an empty string to disable this copying.
-savefilefmt = "/var/games/nethack/save/%u%n.gz"
struct dg_config
{
char* chroot;
- char* nethack;
+ char* game_path;
+ char* game_name;
char* dglroot;
char* lockfile;
char* passwd;
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",
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;
+++ /dev/null
-#!/bin/sh
-# Example configuration, for my FreeBSD 4 machine, using nethack from ports.
-# This file created by Jilles Tjoelker <jilles@stack.nl>.
-
-chroot_path="/home/jilles/src/3rdparty/dgamelaunch-chroot-2"
-shed_uid=1031
-shed_gid=1031
-libs="/usr/libexec/ld-elf.so.1" # /libexec/ld-elf.so.1 for FreeBSD 5
-playground_fixed="/usr/local/lib/nethack"
-playground_var="/usr/local/lib/nethack"
-nethack_bin="$playground_fixed/nethack"
-termdata="/usr/share/misc/termcap"
+++ /dev/null
-#!/bin/sh
-# Brett Carrington <brettcar@segvio.org>
-
-# NOTE: This copied from the dgl-create-chroot changes by Jilles, likely
-# incomplete.
-
-chroot_path="/var/lib/dgamelaunch"
-shed_uid=5
-shed_gid=60
-libs=""
-playground_fixed="/opt/local/share/nethackdir/"
-playground_var=""
-nethack_bin="/opt/local/bin/nethack"
-termdata="/usr/share/terminfo"
+++ /dev/null
-#!/bin/sh
-# hack it for crab test
-# This file created by Jilles Tjoelker <jilles@stack.nl>.
-
-chroot_path="/tmp/jilles/dgl-chroot"
-shed_uid=1677
-shed_gid=104
-# This allows both 32-bit and 64-bit dynamically linked binaries in the chroot:
-libs="/usr/lib/ld.so.1 /usr/lib/sparcv9/ld.so.1"
-playground_fixed=""
-playground_var=""
-nethack_bin="nethackstub"
-# For standard curses:
-termdata="/usr/share/lib/terminfo"
-#termdata="/usr/local/share/lib/terminfo"
--- /dev/null
+# This is a sample dgamelaunch configuration file. Only bash-style comments
+# are allowed, such as this. Each configuration option will be explained
+# along with its default value.
+
+# The following two options are fairly insecure. They will force us to
+# load the password/group database into memory while still having root
+# privileges. Replace them with shed_uid/shed_gid entries as soon as
+# possible if you decide to use them. dgamelaunch will inform you of
+# the uids/gids corresponding to your choices when it loads.
+#
+# Note that shed_uid and shed_gid will always take precedence over
+# shed_user and shed_group if they are specified.
+
+# shed_user: username to shed privileges to
+shed_user = "games"
+# shed_group: group name to shed privileges to
+shed_group = "games"
+
+# Preferably, you may use the respective gids/uids. This is for Debian:
+shed_uid = 5
+shed_gid = 60
+
+# Max amount of registered users to allow.
+maxusers = 64000
+
+# Path to a prepared chroot jail.
+chroot_path = "/var/lib/dgamelaunch/"
+
+# 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/"
+
+# From inside the jail, where dgamelaunch should put mail - should match up with
+# NetHack settings.
+spooldir = "/var/mail/"
+
+# From inside the jail, location of a banner file that contains no more than
+# 14 lines of 80-column width text. Any more will be truncated.
+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"
+
+# From inside the jail, the path to the savefile. %u is replaced by the
+# decimal representation of shed_uid, %n is replaced by the player's
+# user name. Before starting the game, this file is copied to its name
+# with ".bak" appended. Set to an empty string to disable this copying.
+savefilefmt = "/var/games/nethack/save/%u%n.gz"
--- /dev/null
+#!/bin/sh
+# Example configuration, for my FreeBSD 4 machine, using nethack from ports.
+# This file created by Jilles Tjoelker <jilles@stack.nl>.
+
+chroot_path="/home/jilles/src/3rdparty/dgamelaunch-chroot-2"
+shed_uid=1031
+shed_gid=1031
+libs="/usr/libexec/ld-elf.so.1" # /libexec/ld-elf.so.1 for FreeBSD 5
+playground_fixed="/usr/local/lib/nethack"
+playground_var="/usr/local/lib/nethack"
+nethack_bin="$playground_fixed/nethack"
+termdata="/usr/share/misc/termcap"
--- /dev/null
+#!/bin/sh
+# Brett Carrington <brettcar@segvio.org>
+
+# NOTE: This copied from the dgl-create-chroot changes by Jilles, likely
+# incomplete.
+
+chroot_path="/var/lib/dgamelaunch"
+shed_uid=5
+shed_gid=60
+libs=""
+playground_fixed="/opt/local/share/nethackdir/"
+playground_var=""
+nethack_bin="/opt/local/bin/nethack"
+termdata="/usr/share/terminfo"
--- /dev/null
+#!/bin/sh
+# hack it for crab test
+# This file created by Jilles Tjoelker <jilles@stack.nl>.
+
+chroot_path="/tmp/jilles/dgl-chroot"
+shed_uid=1677
+shed_gid=104
+# This allows both 32-bit and 64-bit dynamically linked binaries in the chroot:
+libs="/usr/lib/ld.so.1 /usr/lib/sparcv9/ld.so.1"
+playground_fixed=""
+playground_var=""
+nethack_bin="nethackstub"
+# For standard curses:
+termdata="/usr/share/lib/terminfo"
+#termdata="/usr/local/share/lib/terminfo"
void
doshell (char *username)
{
- char *argv1 = myconfig->nethack;
+ char *argv1 = myconfig->game_path;
char *argv2 = "-u";
char *myargv[10];
myargv[2] = username;
myargv[3] = 0;
- execvp (myconfig->nethack, myargv);
+ execvp (myconfig->game_path, myargv);
fail ();
}