Make dgl-create-chroot -script work again.

Change the dgldir directory layout; all rcfiles, dumps and ttyrecs are now under dgldir/userdata/USERNAME/


git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@466 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Pasi Kallinen 2009-10-17 17:34:36 +00:00
parent 2b6b21cb51
commit 39456b7a75
7 changed files with 306 additions and 239 deletions

View File

@ -219,10 +219,10 @@ gen_inprogress_lock (int game, pid_t pid, char* ttyrec_filename)
fl.l_start = 0;
fl.l_len = 0;
len = strlen(globalconfig.dglroot) + strlen(myconfig[game]->inprogressdir) + strlen(me->username) + strlen(ttyrec_filename) + 13;
len = strlen(dgl_format_str(game, me, myconfig[game]->inprogressdir)) + strlen(me->username) + strlen(ttyrec_filename) + 13;
lockfile = calloc(len, sizeof(char));
snprintf (lockfile, len, "%s%s%s:%s", globalconfig.dglroot, myconfig[game]->inprogressdir,
snprintf (lockfile, len, "%s%s:%s", dgl_format_str(game, me, myconfig[game]->inprogressdir),
me->username, ttyrec_filename);
fd = open (lockfile, O_WRONLY | O_CREAT, 0644);
@ -374,7 +374,7 @@ inprogressmenu (int gameid)
if (sortmode == NUM_SORTMODES)
sortmode = globalconfig.sortmode;
games = populate_games (gameid, &len);
games = populate_games (gameid, &len, me);
games = sort_games (games, len, sortmode);
while (1)
@ -471,9 +471,9 @@ inprogressmenu (int gameid)
break;
/* valid choice has been made */
snprintf (ttyrecname, 130, "%sttyrec/%s", globalconfig.dglroot,
games[menuchoice - 97 + offset]->ttyrec_fn);
chosen_name = strdup (games[menuchoice - 97 + offset]->name);
snprintf (ttyrecname, 130, "%s",
games[menuchoice - 97 + offset]->ttyrec_fn);
/* reuse the char* */
replacestr = strchr (ttyrecname, ':');
@ -481,7 +481,7 @@ inprogressmenu (int gameid)
if (!replacestr)
graceful_exit (145);
replacestr[0] = '/';
/*replacestr[0] = '/';*/
clear ();
refresh ();
@ -515,7 +515,7 @@ inprogressmenu (int gameid)
}
}
games = populate_games (gameid, &len);
games = populate_games (gameid, &len, me);
games = sort_games (games, len, sortmode);
}
}
@ -708,7 +708,7 @@ wall_email(char *from, char *msg)
graceful_exit(120);
}
games = populate_games(-1, &len);
games = populate_games(-1, &len, me);
if (len == 0) {
fprintf(stderr, "Error: wall: no one's logged in!\n");
@ -1596,9 +1596,7 @@ purge_stale_locks (int game)
size_t len;
short firsttime = 1;
len = strlen(globalconfig.dglroot) + strlen(myconfig[game]->inprogressdir) + 1;
dir = malloc(len);
snprintf(dir, len, "%s%s", globalconfig.dglroot, myconfig[game]->inprogressdir);
dir = strdup(dgl_format_str(game, me, myconfig[game]->inprogressdir));
if (!(pdir = opendir (dir)))
graceful_exit (200);
@ -1627,12 +1625,10 @@ purge_stale_locks (int game)
if (strncmp (dent->d_name, me->username, colon - dent->d_name))
continue;
len = strlen (dent->d_name) + strlen(globalconfig.dglroot) + strlen(myconfig[game]->inprogressdir) + 1;
len = strlen (dent->d_name) + strlen(dgl_format_str(game, me, myconfig[game]->inprogressdir)) + 1;
fn = malloc (len);
snprintf (fn, len, "%s%s%s", globalconfig.dglroot, myconfig[game]->inprogressdir, dent->d_name);
fprintf (stderr, "ERR:'%s'\n", fn);
snprintf (fn, len, "%s%s", dgl_format_str(game, me, myconfig[game]->inprogressdir), dent->d_name);
if (!(ipfile = fopen (fn, "r")))
graceful_exit (202);
@ -1798,7 +1794,7 @@ authenticate ()
me = cpy_me(tmpme);
if (passwordgood (pw_buf))
{
games = populate_games (-1, &len);
games = populate_games (-1, &len, me);
for (i = 0; i < len; i++)
if (!strcmp (games[i]->name, user_buf))
{

View File

@ -188,7 +188,7 @@ extern struct dg_menu *dgl_find_menu(char *menuname);
extern int dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me);
extern struct dg_game **populate_games(int game, int *l);
extern struct dg_game **populate_games(int game, int *l, struct dg_user *me);
extern struct dg_game **sort_games(struct dg_game **games, int len, dg_sortmode sortmode);

View File

@ -40,7 +40,7 @@ struct dg_config defconfig = {
/* shed_gid = */ /*60,*/ /* games:games in Debian */
/* max = */ /*64000,*/
/* savefilefmt = */ /*"",*/ /* don't do this by default */
/* inprogressdir = */ "inprogress/",
/* inprogressdir = */ "%rinprogress/",
/* num_args = */ 0,
/* bin_args = */ NULL,
/* rc_fmt = */ "%rrcfiles/%n.nethackrc", /* [dglroot]rcfiles/[username].nethackrc */
@ -303,7 +303,7 @@ dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me)
}
/* launch program */
ttyrec_main (userchoice, me->username, gen_ttyrec_filename());
ttyrec_main (userchoice, me->username, dgl_format_str(userchoice, me, "%ruserdata/%n/ttyrec"), gen_ttyrec_filename());
/* lastly, run the generic "do these when a game is left" commands */
dgl_exec_cmdqueue(globalconfig.cmdqueue[DGLTIME_GAMEEND], userchoice, me);
@ -360,17 +360,16 @@ sort_games (struct dg_game **games, int len, dg_sortmode sortmode)
}
struct dg_game **
populate_games (int xgame, int *l)
populate_games (int xgame, int *l, struct dg_user *me)
{
int fd, len, n, is_nhext, pid;
DIR *pdir;
struct dirent *pdirent;
struct stat pstat;
char fullname[130], ttyrecname[130], pidws[80];
char fullname[130], ttyrecname[130], pidws[80], playername[30];
char *replacestr, *dir, *p;
struct dg_game **games = NULL;
struct flock fl = { 0 };
size_t slen;
int game;
@ -383,9 +382,7 @@ populate_games (int xgame, int *l)
for (game = ((xgame < 0) ? 0 : xgame); game < ((xgame <= 0) ? num_games : (xgame+1)); game++) {
slen = strlen(globalconfig.dglroot) + strlen(myconfig[game]->inprogressdir) + 1;
dir = malloc(slen);
snprintf(dir, slen, "%s%s", globalconfig.dglroot, myconfig[game]->inprogressdir);
dir = strdup(dgl_format_str(game, me, myconfig[game]->inprogressdir));
if (!(pdir = opendir (dir)))
graceful_exit (140);
@ -397,7 +394,7 @@ populate_games (int xgame, int *l)
is_nhext = !strcmp (pdirent->d_name + strlen (pdirent->d_name) - 6, ".nhext");
snprintf (fullname, 130, "%s%s%s", globalconfig.dglroot, myconfig[game]->inprogressdir, pdirent->d_name);
snprintf (fullname, 130, "%s%s", dgl_format_str(game, me, myconfig[game]->inprogressdir), pdirent->d_name);
fd = 0;
/* O_RDWR here should be O_RDONLY, but we need to test for
@ -409,18 +406,22 @@ populate_games (int xgame, int *l)
/* stat to check idle status */
if (!is_nhext)
{
snprintf (ttyrecname, 130, "%sttyrec/%s", globalconfig.dglroot, pdirent->d_name);
replacestr = strchr (ttyrecname, ':');
if (!replacestr)
graceful_exit (145);
replacestr[0] = '/';
strncpy(playername, pdirent->d_name, 29);
playername[29] = '\0';
if ((replacestr = strchr(playername, ':')))
*replacestr = '\0';
replacestr = strchr(pdirent->d_name, ':');
if (!replacestr) graceful_exit(145);
replacestr++;
snprintf (ttyrecname, 130, "%suserdata/%s/ttyrec/%s", globalconfig.dglroot, playername, replacestr);
}
if (is_nhext || !stat (ttyrecname, &pstat))
{
/* now it's a valid game for sure */
games = realloc (games, sizeof (struct dg_game) * (len + 1));
games[len] = malloc (sizeof (struct dg_game));
games[len]->ttyrec_fn = strdup (pdirent->d_name);
games[len]->ttyrec_fn = strdup (ttyrecname);
if (!(replacestr = strchr (pdirent->d_name, ':')))
graceful_exit (146);

View File

@ -1,151 +1,209 @@
#!/bin/sh
# Original by joshk@triplehelix.org, modifications by jilles@stack.nl
# Ideas and some parts from the original dgl-create-chroot (by joshk@triplehelix.org, modifications by jilles@stack.nl)
# This one by paxed@alt.org
# Settings
# Don't customize here, create a dgl-create-chroot.conf file instead.
# The defaults should work fine for Debian.
# path for chroot
chroot_path="/var/lib/dgamelaunch"
# uid/gid (numeric), must agree with dgamelaunch.h
shed_uid=5
shed_gid=60
# extra libraries to copy (that ldd doesn't find, such as ld-elf.so.1 on
# FreeBSD)
libs=""
# compression binary to copy (found in $PATH if unqualified)
# (leave blank to skip)
compress_bin="gzip"
# nethack binary to copy (leave blank to skip)
nethack_bin="/usr/lib/games/nethack/nethack-console"
#
# configure dgl with --with-config-file=/path_to_chroot/etc/dgamelaunch.conf, if you want the conf file inside the chroot.
#
# Same as chroot_path in dgl config file
CHROOT="/opt/nethack/nethack.alt.org/"
# the user & group from dgamelaunch config file.
USRGRP="games:games"
# COMPRESS from include/config.h; the compression binary to copy. leave blank to skip.
COMPRESSBIN="/bin/gzip"
# nethack binary to copy into chroot
NETHACKBIN="/home/paxed/hacking/coding/nethacksource/nethack-3.4.3-nao/nh343/nethack.343-nao"
# fixed data to copy (leave blank to skip)
playground_fixed="/usr/lib/games/nethack"
# variable data to create (leave blank to skip) (may be equal to previous)
playground_var="/var/games/nethack"
# termcap/terminfo (copied recursively) (leave blank to skip)
[ -f dgl-create-chroot.conf ] && . ./dgl-create-chroot.conf
NH_PLAYGROUND_FIXED="/home/paxed/hacking/coding/nethacksource/nethack-3.4.3-nao/nh343/"
# HACKDIR from include/config.h; aka nethack subdir inside chroot
NHSUBDIR="/nh343/"
# VAR_PLAYGROUND from include/unixconf.h
NH_VAR_PLAYGROUND="/nh343/var/"
if [ -z "$termdata" ]; then
for dir in /etc/terminfo /usr/share/lib/terminfo /usr/share/terminfo; do
if [ -e "$dir/x/xterm" ]; then
termdata=$dir
break
fi
done
if [ -z "$termdata" ]; then
echo "Error: couldn't find terminfo definitions. Please specify in 'termdata' variable." >&2
exit 1
fi
fi
# only define this if dgl was configured with --enable-sqlite
SQLITE_DBFILE="/dgldir/dgamelaunch.db"
# END OF CONFIG
##############################################################################
errorexit()
{
echo "Error: $@" >&2
exit 1
}
findlibs()
{
for i in "$@"; do
# () to ignore errors
( ldd "$i" 2>/dev/null | awk '{ if ($2=="=>" && $1!="linux-gate.so.1") print $3; }' )
done
}
findinpath()
{
local IFS
IFS=:
for dir in $PATH; do
if [ -f "$dir/$1" ]; then
echo "$dir/$1"
return 0
fi
done
return 1
for i in "$@"; do
echo $(ldd "$i" | awk '{ print $3 }' | egrep -v ^'\(')
echo $(ldd "$i" | grep 'ld-linux' | awk '{ print $1 }')
done
}
##############################################################################
if [ -z "$TERMDATA" ]; then
SEARCHTERMDATA="/etc/terminfo /usr/share/lib/terminfo /usr/share/terminfo /lib/terminfo"
for dir in $SEARCHTERMDATA; do
if [ -e "$dir/x/xterm" ]; then
TERMDATA="$TERMDATA $dir"
fi
done
if [ -z "$TERMDATA" ]; then
errorexit "Couldn't find terminfo definitions. Please specify in 'TERMDATA' variable."
fi
fi
# remove trailing slash, if any
CHROOT="`echo ${CHROOT%/}`"
set -e
umask 022
echo "Setting up the chroot in: $chroot_path"
mkdir -p $chroot_path/bin $chroot_path/etc $chroot_path/var/mail
# Passwd file
echo "games:*:$shed_uid:$shed_gid:games:/nonexistent:" >$chroot_path/etc/passwd
echo "games:*:$shed_gid:" >$chroot_path/etc/group
# Time zone information, NetHack uses this
[ -f /etc/localtime ] && cp /etc/localtime $chroot_path/etc
# Dungeon directory setup
mkdir -p $chroot_path/dgldir/inprogress
mkdir -p $chroot_path/dgldir/rcfiles
mkdir -p $chroot_path/dgldir/ttyrec
chown -R $shed_uid:$shed_gid $chroot_path/dgldir
chown -R $shed_uid:$shed_gid $chroot_path/var/mail
touch $chroot_path/dgl-login
touch $chroot_path/dgl-lock
# Might want to remove these two for packaging?
cp dgl-default-rcfile $chroot_path
cp dgl-banner $chroot_path
chown $shed_uid:$shed_gid $chroot_path/dgl-*
# Needs gzip to compress
if [ -n "$compress_bin" ]; then
case "$compress_bin" in
/*) : ;;
*) compress_bin=`findinpath $compress_bin` ;;
esac
# NetHack wants the compression binary in the exact directory
mkdir -p $chroot_path`dirname $compress_bin`
cp $compress_bin $chroot_path$compress_bin
libs="$libs `findlibs $compress_bin`"
if [ -e "$CHROOT" ]; then
errorexit "Chroot $CHROOT already exists."
fi
# Copy the nethack binary over
if [ -n "$nethack_bin" ]; then
cp $nethack_bin $chroot_path/bin/nethack
libs="$libs `findlibs $nethack_bin`"
CURDIR="`pwd`"
if [ ! -e "$CURDIR/dgamelaunch" ]; then
errorexit "Cannot find dgamelaunch in $CURDIR"
fi
# ...and all the data it needs
if [ -n "$playground_var" ]; then
mkdir -p $chroot_path$playground_var/save $chroot_path$playground_var/dumps
touch $chroot_path$playground_var/record
touch $chroot_path$playground_var/perm
touch $chroot_path$playground_var/logfile
chown -R $shed_uid:$shed_gid $chroot_path$playground_var
DGLFILE="dgamelaunch.`date +%Y%m%d`"
echo "Setting up chroot in $CHROOT"
LIBS="`findlibs dgamelaunch`"
sudo mkdir -p "$CHROOT"
cd "$CHROOT"
sudo mkdir dgldir etc lib mail usr
sudo chown "$USRGRP" dgldir mail
sudo cp "$CURDIR/dgamelaunch" "$DGLFILE"
sudo ln -s "$DGLFILE" dgamelaunch
sudo mkdir -p "$CHROOT/dgldir/inprogress-nh343"
sudo mkdir -p "$CHROOT/dgldir/userdata"
sudo chown "$USRGRP" "$CHROOT/dgldir/inprogress-nh343"
sudo chown "$USRGRP" "$CHROOT/dgldir/userdata"
if [ -n "$SQLITE_DBFILE" ]; then
echo "Creating SQLite database at $SQLITE_DBFILE"
SQLITE_DBFILE="`echo ${SQLITE_DBFILE%/}`"
SQLITE_DBFILE="`echo ${SQLITE_DBFILE#/}`"
sudo sqlite3 "$CHROOT/$SQLITE_DBFILE" "create table dglusers (id integer primary key, username text, email text, env text, password text, flags integer);"
sudo chown "$USRGRP" "$CHROOT/$SQLITE_DBFILE"
fi
if [ -n "$playground_fixed" ]; then
mkdir -p $chroot_path$playground_fixed
cp $playground_fixed/license $chroot_path$playground_fixed
if [ -e $playground_fixed/nhdat ]; then
cp $playground_fixed/nhdat $chroot_path$playground_fixed
else
(
cd $playground_fixed
cp *.dat cmdhelp data dungeon help hh history \
opthelp options perm recover rumors wizhelp \
$chroot_path$playground_fixed
)
fi
if [ -n "$COMPRESSBIN" -a -e "`which $COMPRESSBIN`" ]; then
COMPRESSDIR="`dirname $COMPRESSBIN`"
COMPRESSDIR="`echo ${COMPRESSDIR%/}`"
COMPRESSDIR="`echo ${COMPRESSDIR#/}`"
echo "Copying $COMPRESSBIN to $COMPRESSDIR"
sudo mkdir -p "$COMPRESSDIR"
sudo cp "`which $COMPRESSBIN`" "$COMPRESSDIR/"
LIBS="$LIBS `findlibs $COMPRESSBIN`"
fi
sudo mkdir -p dev
cd dev
sudo mknod urandom c 1 9
cd ..
cd etc
sudo cp "$CURDIR/examples/dgamelaunch.conf" .
echo "Edit $CHROOT/etc/dgamelaunch.conf to suit your needs."
[ -f /etc/localtime ] && sudo cp /etc/localtime .
cd ..
sudo cp "$CURDIR/examples/dgl_menu_main_anon.txt" .
sudo cp "$CURDIR/examples/dgl_menu_main_user.txt" .
sudo cp "$CURDIR/examples/dgl-banner" .
sudo cp "$CURDIR/dgl-default-rcfile" "dgl-default-rcfile.nh343"
sudo chmod go+r dgl_menu_main_anon.txt dgl_menu_main_user.txt dgl-banner dgl-default-rcfile.nh343
NHSUBDIR="`echo ${NHSUBDIR%/}`"
NHSUBDIR="`echo ${NHSUBDIR#/}`"
sudo mkdir "$CHROOT/$NHSUBDIR"
if [ ! -e "$NETHACKBIN" ]; then
errorexit "Cannot find NetHack binary $NETHACKBIN"
fi
if [ -n "$NETHACKBIN" -a -e "$NETHACKBIN" ]; then
echo "Copying $NETHACKBIN"
sudo cp "$NETHACKBIN" "$NHSUBDIR/"
LIBS="$LIBS `findlibs $NETHACKBIN`"
fi
NH_PLAYGROUND_FIXED="`echo ${NH_PLAYGROUND_FIXED%/}`"
if [ -n "$NH_PLAYGROUND_FIXED" -a -d "$NH_PLAYGROUND_FIXED" ]; then
echo "Copying NetHack playground stuff."
NHFILES="*.lev *.dat cmdhelp data dungeon help hh history license opthelp options oracles recover rumors wizhelp"
for fil in $NHFILES; do
sudo cp $NH_PLAYGROUND_FIXED/$fil "$CHROOT/$NHSUBDIR/"
done
fi
NH_VAR_PLAYGROUND="`echo ${NH_VAR_PLAYGROUND%/}`"
NH_VAR_PLAYGROUND="`echo ${NH_VAR_PLAYGROUND#/}`"
echo "Creating NetHack variable dir stuff."
if [ -n "$NH_VAR_PLAYGROUND" ]; then
sudo mkdir -p "$CHROOT/$NH_VAR_PLAYGROUND"
sudo chown -R "$USRGRP" "$CHROOT/$NH_VAR_PLAYGROUND"
fi
sudo mkdir -p "$CHROOT/$NH_VAR_PLAYGROUND/save"
sudo chown -R "$USRGRP" "$CHROOT/$NH_VAR_PLAYGROUND/save"
sudo touch "$CHROOT/$NH_VAR_PLAYGROUND/logfile"
sudo touch "$CHROOT/$NH_VAR_PLAYGROUND/perm"
sudo touch "$CHROOT/$NH_VAR_PLAYGROUND/record"
sudo touch "$CHROOT/$NH_VAR_PLAYGROUND/xlogfile"
sudo chown -R "$USRGRP" "$CHROOT/$NHSUBDIR"
sudo chown -R "$USRGRP" "$CHROOT/$NH_VAR_PLAYGROUND"
# Curses junk
if [ -n "$termdata" ]; then
mkdir -p $chroot_path`dirname $termdata`
if [ -d $termdata/. ]; then
cp -LR $termdata/. $chroot_path$termdata
if [ -n "$TERMDATA" ]; then
echo "Copying termdata files from $TERMDATA"
for termdat in $TERMDATA; do
sudo mkdir -p "$CHROOT`dirname $termdat`"
if [ -d $termdat/. ]; then
sudo cp -LR $termdat/. $CHROOT$termdat
else
cp $termdata $chroot_path`dirname $termdata`
sudo cp $termdat $CHROOT`dirname $termdat`
fi
done
fi
# Necessary libraries
# previously libs="/lib/libc.so.6 /lib/libncurses.so.5 /lib/ld-linux.so.2"
libs=`for lib in $libs; do echo $lib; done | sort | uniq`
echo "Copying libraries:" $libs
for lib in $libs; do
mkdir -p $chroot_path`dirname $lib`
cp $lib $chroot_path$lib
LIBS=`for lib in $LIBS; do echo $lib; done | sort | uniq`
echo "Copying libraries:" $LIBS
for lib in $LIBS; do
sudo mkdir -p "$CHROOT`dirname $lib`"
sudo cp $lib "$CHROOT$lib"
done
echo "Finished."

View File

@ -24,7 +24,7 @@ maxnicklen = 10
#sortmode = "username"
# Path to a prepared chroot jail.
chroot_path = "/var/lib/dgamelaunch/"
chroot_path = "/opt/nethack/nethack.alt.org/"
# From inside the jail, dgamelaunch's working directory for rcfiles/ttyrec/etc
dglroot = "/dgldir/"
@ -108,15 +108,24 @@ lockfile = "/dgl-lock"
# eg. commands[login] = mkdir "foo", unlink "bar", setenv "Z" "foo"
#
# create the user's ttyrec dir when they register
commands[register] = mkdir "%rttyrec/%n"
# create the user's dirs when they register
commands[register] = mkdir "%ruserdata/%n",
mkdir "%ruserdata/%n/dumplog",
mkdir "%ruserdata/%n/ttyrec"
commands[login] = mkdir "%ruserdata/%n",
mkdir "%ruserdata/%n/dumplog",
mkdir "%ruserdata/%n/ttyrec"
# define the main menus. you _must_ define "mainmenu_anon"
# and "mainmenu_user".
# Define the main menus.
# You _must_ define "mainmenu_anon" and "mainmenu_user".
# $VERSION and $SERVERID will be replaced, as per the bannerfile above.
# first, the menu shown to anonymous user:
# First, the menu shown to anonymous user:
menu["mainmenu_anon"] {
bannerfile = "dgl_menu_main_anon.txt"
cursor = (5,18)
@ -126,7 +135,7 @@ menu["mainmenu_anon"] {
commands["q"] = quit
}
# then the menu shown when the user has logged in:
# Then the menu shown when the user has logged in:
# $USERNAME in here will be replaced with the user name.
menu["mainmenu_user"] {
# contents of this file are written to screen.
@ -152,37 +161,37 @@ menu["mainmenu_user"] {
# Next, we'll define one game's data:
DEFINE {
# From inside the jail, the location of the binary to be launched.
game_path = "/bin/nethackstub"
# Full name of the game
game_name = "NetHack stub"
# Short name, used in the watching menu
short_name = "NHstb"
# arguments for when we exec the binary
game_args = "/bin/nethackstub",
"foo",
"user:%n",
"shed_uid:%u",
"bar"
# From inside the jail, where dgamelaunch should put mail.
spooldir = "/var/mail/"
# From inside the jail, the default .nethackrc that is copied for new users.
# rc_template = "/dgl-default-rcfile"
# Make sure the inprogress dir actually exists. default is "inprogress/"
# Each game you define here must have it's own.
inprogressdir = "inprogress-nethackstub/"
# We can also define per-game commands, that are executed
# when the game starts:
# commands = chdir "/dgldir", mkdir "foo_%u_%g"
}
#DEFINE {
# # From inside the jail, the location of the binary to be launched.
# game_path = "/bin/nethackstub"
#
# # Full name of the game
# game_name = "NetHack stub"
#
# # Short name, used in the watching menu
# short_name = "NHstb"
#
# # arguments for when we exec the binary
# game_args = "/bin/nethackstub",
# "foo",
# "user:%n",
# "shed_uid:%u",
# "bar"
#
# # From inside the jail, where dgamelaunch should put mail.
# spooldir = "/var/mail/"
#
# # From inside the jail, the default .nethackrc that is copied for new users.
# # rc_template = "/dgl-default-rcfile"
#
# # Make sure the inprogress dir actually exists. default is "inprogress/"
# # Each game you define here must have it's own.
# inprogressdir = "%rinprogress-nethackstub/"
#
# # We can also define per-game commands, that are executed
# # when the game starts:
# # commands = chdir "/dgldir", mkdir "foo_%u_%g"
#}
#
@ -191,28 +200,29 @@ DEFINE {
#
DEFINE {
game_path = "/bin/nethack"
game_path = "/nh343/nethack.343-nao"
game_name = "NetHack 3.4.3"
short_name = "NH343"
game_args = "/bin/nethack", "-u", "%n"
game_args = "/nh343/nethack.343-nao", "-u", "%n"
spooldir = "/var/mail/"
rc_template = "/dgl-default-rcfile"
rc_template = "/dgl-default-rcfile.nh343"
rc_fmt = "%rrcfiles/%n.nethackrc"
rc_fmt = "%ruserdata/%n/%n.nh343rc"
inprogressdir = "%rinprogress-nh343/"
inprogressdir = "inprogress-nethack/"
# back up savefile
commands = cp "/var/games/nethack/save/%u%n.gz" "/var/games/nethack/save/%u%n.gz.bak",
commands = cp "/nh343/var/save/%u%n.gz" "/nh343/var/save/%u%n.gz.bak",
# set NETHACKOPTIONS to point to the rcfile
setenv "NETHACKOPTIONS" "@%rrcfiles/%n.nethackrc",
setenv "NETHACKOPTIONS" "@%ruserdata/%n/%n.nh343rc",
# set up nethack mail stuff, assuming it's compiled with it...
setenv "MAIL" "/var/mail/%n",
setenv "SIMPLEMAIL" "1",
setenv "MAIL" "/mail/%n",
setenv "SIMPLEMAIL" "1",
# don't let the mail file grow
unlink "/var/mail/%n"
unlink "/mail/%n"
}
#
@ -220,41 +230,41 @@ DEFINE {
#
#
DEFINE {
game_path = "/bin/crawlss017"
game_name = "Crawl Stone Soup 0.1.7"
short_name = "Cr017"
game_args = "/bin/crawlss017",
"-name", "%n",
"-dir", "/crawlss017/",
"-rc", "%rrcfiles/%n.crawlrc",
"-morgue", "/crawlss017/morgues/",
"-macro", "/crawlss017/macros/%n.macro"
rc_template = "/dgl-default-rcfile.crawl"
rc_fmt = "%rrcfiles/%n.crawlrc"
inprogressdir = "inprogress-crawlss017/"
}
#DEFINE {
# game_path = "/bin/crawlss017"
# game_name = "Crawl Stone Soup 0.1.7"
# short_name = "Cr017"
#
# game_args = "/bin/crawlss017",
# "-name", "%n",
# "-dir", "/crawlss017/",
# "-rc", "%rrcfiles/%n.crawlrc",
# "-morgue", "/crawlss017/morgues/",
# "-macro", "/crawlss017/macros/%n.macro"
#
# rc_template = "/dgl-default-rcfile.crawl"
# rc_fmt = "%rrcfiles/%n.crawlrc"
# inprogressdir = "%rinprogress-crawlss017/"
#}
#
# fourth game
#
#
DEFINE {
game_path = "/bin/crawlss020"
game_name = "Crawl Stone Soup 0.2.0"
short_name = "Cr020"
game_args = "/bin/crawlss020",
"-name", "%n",
"-dir", "/crawlss020/",
"-rc", "/crawlss020/plr/%n/%n.crawlrc",
"-morgue", "/crawlss020/plr/%n/",
"-macro", "/crawlss020/plr/%n/"
rc_template = "/dgl-default-rcfile.crawl"
rc_fmt = "/crawlss020/plr/%n/%n.crawlrc"
inprogressdir = "inprogress-crawlss020/"
}
#DEFINE {
# game_path = "/bin/crawlss020"
# game_name = "Crawl Stone Soup 0.2.0"
# short_name = "Cr020"
#
# game_args = "/bin/crawlss020",
# "-name", "%n",
# "-dir", "/crawlss020/",
# "-rc", "/crawlss020/plr/%n/%n.crawlrc",
# "-morgue", "/crawlss020/plr/%n/",
# "-macro", "/crawlss020/plr/%n/"
#
# rc_template = "/dgl-default-rcfile.crawl"
# rc_fmt = "/crawlss020/plr/%n/%n.crawlrc"
# inprogressdir = "%rinprogress-crawlss020/"
#}

View File

@ -85,14 +85,16 @@ struct winsize win;
int uflg;
int
ttyrec_main (int game, char *username, char* ttyrec_filename)
ttyrec_main (int game, char *username, char *ttyrec_path, char* ttyrec_filename)
{
char dirname[100];
child = subchild = input_child = 0;
snprintf (dirname, 100, "%sttyrec/%s/%s", globalconfig.dglroot, username,
ttyrec_filename);
if (ttyrec_path[strlen(ttyrec_path)-1] == '/')
snprintf (dirname, 100, "%s%s", ttyrec_path, ttyrec_filename);
else
snprintf (dirname, 100, "%s/%s", ttyrec_path, ttyrec_filename);
atexit(&remove_ipfile);
if ((fscript = fopen (dirname, "w")) == NULL)

View File

@ -21,7 +21,7 @@ extern void doshell (int, char *);
extern void finish (int);
extern void remove_ipfile (void);
extern int ttyrec_main(int, char *username, char *ttyrec_filename);
extern int ttyrec_main (int, char *username, char *ttyrec_path, char* ttyrec_filename);
extern pid_t child; /* nethack process */
extern int master, slave;