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:
parent
2b6b21cb51
commit
39456b7a75
|
@ -219,10 +219,10 @@ gen_inprogress_lock (int game, pid_t pid, char* ttyrec_filename)
|
||||||
fl.l_start = 0;
|
fl.l_start = 0;
|
||||||
fl.l_len = 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));
|
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);
|
me->username, ttyrec_filename);
|
||||||
|
|
||||||
fd = open (lockfile, O_WRONLY | O_CREAT, 0644);
|
fd = open (lockfile, O_WRONLY | O_CREAT, 0644);
|
||||||
|
@ -374,7 +374,7 @@ inprogressmenu (int gameid)
|
||||||
if (sortmode == NUM_SORTMODES)
|
if (sortmode == NUM_SORTMODES)
|
||||||
sortmode = globalconfig.sortmode;
|
sortmode = globalconfig.sortmode;
|
||||||
|
|
||||||
games = populate_games (gameid, &len);
|
games = populate_games (gameid, &len, me);
|
||||||
games = sort_games (games, len, sortmode);
|
games = sort_games (games, len, sortmode);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -471,9 +471,9 @@ inprogressmenu (int gameid)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* valid choice has been made */
|
/* 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);
|
chosen_name = strdup (games[menuchoice - 97 + offset]->name);
|
||||||
|
snprintf (ttyrecname, 130, "%s",
|
||||||
|
games[menuchoice - 97 + offset]->ttyrec_fn);
|
||||||
|
|
||||||
/* reuse the char* */
|
/* reuse the char* */
|
||||||
replacestr = strchr (ttyrecname, ':');
|
replacestr = strchr (ttyrecname, ':');
|
||||||
|
@ -481,7 +481,7 @@ inprogressmenu (int gameid)
|
||||||
if (!replacestr)
|
if (!replacestr)
|
||||||
graceful_exit (145);
|
graceful_exit (145);
|
||||||
|
|
||||||
replacestr[0] = '/';
|
/*replacestr[0] = '/';*/
|
||||||
|
|
||||||
clear ();
|
clear ();
|
||||||
refresh ();
|
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);
|
games = sort_games (games, len, sortmode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -708,7 +708,7 @@ wall_email(char *from, char *msg)
|
||||||
graceful_exit(120);
|
graceful_exit(120);
|
||||||
}
|
}
|
||||||
|
|
||||||
games = populate_games(-1, &len);
|
games = populate_games(-1, &len, me);
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
fprintf(stderr, "Error: wall: no one's logged in!\n");
|
fprintf(stderr, "Error: wall: no one's logged in!\n");
|
||||||
|
@ -1596,9 +1596,7 @@ purge_stale_locks (int game)
|
||||||
size_t len;
|
size_t len;
|
||||||
short firsttime = 1;
|
short firsttime = 1;
|
||||||
|
|
||||||
len = strlen(globalconfig.dglroot) + strlen(myconfig[game]->inprogressdir) + 1;
|
dir = strdup(dgl_format_str(game, me, myconfig[game]->inprogressdir));
|
||||||
dir = malloc(len);
|
|
||||||
snprintf(dir, len, "%s%s", globalconfig.dglroot, myconfig[game]->inprogressdir);
|
|
||||||
|
|
||||||
if (!(pdir = opendir (dir)))
|
if (!(pdir = opendir (dir)))
|
||||||
graceful_exit (200);
|
graceful_exit (200);
|
||||||
|
@ -1627,12 +1625,10 @@ purge_stale_locks (int game)
|
||||||
if (strncmp (dent->d_name, me->username, colon - dent->d_name))
|
if (strncmp (dent->d_name, me->username, colon - dent->d_name))
|
||||||
continue;
|
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);
|
fn = malloc (len);
|
||||||
|
|
||||||
snprintf (fn, len, "%s%s%s", globalconfig.dglroot, myconfig[game]->inprogressdir, dent->d_name);
|
snprintf (fn, len, "%s%s", dgl_format_str(game, me, myconfig[game]->inprogressdir), dent->d_name);
|
||||||
|
|
||||||
fprintf (stderr, "ERR:'%s'\n", fn);
|
|
||||||
|
|
||||||
if (!(ipfile = fopen (fn, "r")))
|
if (!(ipfile = fopen (fn, "r")))
|
||||||
graceful_exit (202);
|
graceful_exit (202);
|
||||||
|
@ -1798,7 +1794,7 @@ authenticate ()
|
||||||
me = cpy_me(tmpme);
|
me = cpy_me(tmpme);
|
||||||
if (passwordgood (pw_buf))
|
if (passwordgood (pw_buf))
|
||||||
{
|
{
|
||||||
games = populate_games (-1, &len);
|
games = populate_games (-1, &len, me);
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
if (!strcmp (games[i]->name, user_buf))
|
if (!strcmp (games[i]->name, user_buf))
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 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);
|
extern struct dg_game **sort_games(struct dg_game **games, int len, dg_sortmode sortmode);
|
||||||
|
|
||||||
|
|
31
dgl-common.c
31
dgl-common.c
|
@ -40,7 +40,7 @@ struct dg_config defconfig = {
|
||||||
/* shed_gid = */ /*60,*/ /* games:games in Debian */
|
/* shed_gid = */ /*60,*/ /* games:games in Debian */
|
||||||
/* max = */ /*64000,*/
|
/* max = */ /*64000,*/
|
||||||
/* savefilefmt = */ /*"",*/ /* don't do this by default */
|
/* savefilefmt = */ /*"",*/ /* don't do this by default */
|
||||||
/* inprogressdir = */ "inprogress/",
|
/* inprogressdir = */ "%rinprogress/",
|
||||||
/* num_args = */ 0,
|
/* num_args = */ 0,
|
||||||
/* bin_args = */ NULL,
|
/* bin_args = */ NULL,
|
||||||
/* rc_fmt = */ "%rrcfiles/%n.nethackrc", /* [dglroot]rcfiles/[username].nethackrc */
|
/* 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 */
|
/* 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 */
|
/* lastly, run the generic "do these when a game is left" commands */
|
||||||
dgl_exec_cmdqueue(globalconfig.cmdqueue[DGLTIME_GAMEEND], userchoice, me);
|
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 **
|
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;
|
int fd, len, n, is_nhext, pid;
|
||||||
DIR *pdir;
|
DIR *pdir;
|
||||||
struct dirent *pdirent;
|
struct dirent *pdirent;
|
||||||
struct stat pstat;
|
struct stat pstat;
|
||||||
char fullname[130], ttyrecname[130], pidws[80];
|
char fullname[130], ttyrecname[130], pidws[80], playername[30];
|
||||||
char *replacestr, *dir, *p;
|
char *replacestr, *dir, *p;
|
||||||
struct dg_game **games = NULL;
|
struct dg_game **games = NULL;
|
||||||
struct flock fl = { 0 };
|
struct flock fl = { 0 };
|
||||||
size_t slen;
|
|
||||||
|
|
||||||
int game;
|
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++) {
|
for (game = ((xgame < 0) ? 0 : xgame); game < ((xgame <= 0) ? num_games : (xgame+1)); game++) {
|
||||||
|
|
||||||
slen = strlen(globalconfig.dglroot) + strlen(myconfig[game]->inprogressdir) + 1;
|
dir = strdup(dgl_format_str(game, me, myconfig[game]->inprogressdir));
|
||||||
dir = malloc(slen);
|
|
||||||
snprintf(dir, slen, "%s%s", globalconfig.dglroot, myconfig[game]->inprogressdir);
|
|
||||||
|
|
||||||
if (!(pdir = opendir (dir)))
|
if (!(pdir = opendir (dir)))
|
||||||
graceful_exit (140);
|
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");
|
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;
|
fd = 0;
|
||||||
/* O_RDWR here should be O_RDONLY, but we need to test for
|
/* 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 */
|
/* stat to check idle status */
|
||||||
if (!is_nhext)
|
if (!is_nhext)
|
||||||
{
|
{
|
||||||
snprintf (ttyrecname, 130, "%sttyrec/%s", globalconfig.dglroot, pdirent->d_name);
|
strncpy(playername, pdirent->d_name, 29);
|
||||||
replacestr = strchr (ttyrecname, ':');
|
playername[29] = '\0';
|
||||||
if (!replacestr)
|
if ((replacestr = strchr(playername, ':')))
|
||||||
graceful_exit (145);
|
*replacestr = '\0';
|
||||||
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))
|
if (is_nhext || !stat (ttyrecname, &pstat))
|
||||||
{
|
{
|
||||||
/* now it's a valid game for sure */
|
/* now it's a valid game for sure */
|
||||||
games = realloc (games, sizeof (struct dg_game) * (len + 1));
|
games = realloc (games, sizeof (struct dg_game) * (len + 1));
|
||||||
games[len] = malloc (sizeof (struct dg_game));
|
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, ':')))
|
if (!(replacestr = strchr (pdirent->d_name, ':')))
|
||||||
graceful_exit (146);
|
graceful_exit (146);
|
||||||
|
|
|
@ -1,151 +1,209 @@
|
||||||
#!/bin/sh
|
#!/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.
|
# configure dgl with --with-config-file=/path_to_chroot/etc/dgamelaunch.conf, if you want the conf file inside the chroot.
|
||||||
# path for chroot
|
#
|
||||||
chroot_path="/var/lib/dgamelaunch"
|
|
||||||
# uid/gid (numeric), must agree with dgamelaunch.h
|
|
||||||
shed_uid=5
|
# Same as chroot_path in dgl config file
|
||||||
shed_gid=60
|
CHROOT="/opt/nethack/nethack.alt.org/"
|
||||||
# extra libraries to copy (that ldd doesn't find, such as ld-elf.so.1 on
|
# the user & group from dgamelaunch config file.
|
||||||
# FreeBSD)
|
USRGRP="games:games"
|
||||||
libs=""
|
# COMPRESS from include/config.h; the compression binary to copy. leave blank to skip.
|
||||||
# compression binary to copy (found in $PATH if unqualified)
|
COMPRESSBIN="/bin/gzip"
|
||||||
# (leave blank to skip)
|
# nethack binary to copy into chroot
|
||||||
compress_bin="gzip"
|
NETHACKBIN="/home/paxed/hacking/coding/nethacksource/nethack-3.4.3-nao/nh343/nethack.343-nao"
|
||||||
# nethack binary to copy (leave blank to skip)
|
|
||||||
nethack_bin="/usr/lib/games/nethack/nethack-console"
|
|
||||||
# fixed data to copy (leave blank to skip)
|
# fixed data to copy (leave blank to skip)
|
||||||
playground_fixed="/usr/lib/games/nethack"
|
NH_PLAYGROUND_FIXED="/home/paxed/hacking/coding/nethacksource/nethack-3.4.3-nao/nh343/"
|
||||||
# variable data to create (leave blank to skip) (may be equal to previous)
|
# HACKDIR from include/config.h; aka nethack subdir inside chroot
|
||||||
playground_var="/var/games/nethack"
|
NHSUBDIR="/nh343/"
|
||||||
# termcap/terminfo (copied recursively) (leave blank to skip)
|
# VAR_PLAYGROUND from include/unixconf.h
|
||||||
[ -f dgl-create-chroot.conf ] && . ./dgl-create-chroot.conf
|
NH_VAR_PLAYGROUND="/nh343/var/"
|
||||||
|
|
||||||
if [ -z "$termdata" ]; then
|
# only define this if dgl was configured with --enable-sqlite
|
||||||
for dir in /etc/terminfo /usr/share/lib/terminfo /usr/share/terminfo; do
|
SQLITE_DBFILE="/dgldir/dgamelaunch.db"
|
||||||
if [ -e "$dir/x/xterm" ]; then
|
|
||||||
termdata=$dir
|
# END OF CONFIG
|
||||||
break
|
##############################################################################
|
||||||
fi
|
|
||||||
done
|
errorexit()
|
||||||
if [ -z "$termdata" ]; then
|
{
|
||||||
echo "Error: couldn't find terminfo definitions. Please specify in 'termdata' variable." >&2
|
echo "Error: $@" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
}
|
||||||
fi
|
|
||||||
|
|
||||||
findlibs()
|
findlibs()
|
||||||
{
|
{
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
# () to ignore errors
|
echo $(ldd "$i" | awk '{ print $3 }' | egrep -v ^'\(')
|
||||||
( ldd "$i" 2>/dev/null | awk '{ if ($2=="=>" && $1!="linux-gate.so.1") print $3; }' )
|
echo $(ldd "$i" | grep 'ld-linux' | awk '{ print $1 }')
|
||||||
done
|
done
|
||||||
}
|
|
||||||
findinpath()
|
|
||||||
{
|
|
||||||
local IFS
|
|
||||||
IFS=:
|
|
||||||
for dir in $PATH; do
|
|
||||||
if [ -f "$dir/$1" ]; then
|
|
||||||
echo "$dir/$1"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
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
|
set -e
|
||||||
umask 022
|
umask 022
|
||||||
|
|
||||||
echo "Setting up the chroot in: $chroot_path"
|
if [ -e "$CHROOT" ]; then
|
||||||
|
errorexit "Chroot $CHROOT already exists."
|
||||||
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`"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the nethack binary over
|
CURDIR="`pwd`"
|
||||||
if [ -n "$nethack_bin" ]; then
|
|
||||||
cp $nethack_bin $chroot_path/bin/nethack
|
if [ ! -e "$CURDIR/dgamelaunch" ]; then
|
||||||
libs="$libs `findlibs $nethack_bin`"
|
errorexit "Cannot find dgamelaunch in $CURDIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ...and all the data it needs
|
DGLFILE="dgamelaunch.`date +%Y%m%d`"
|
||||||
if [ -n "$playground_var" ]; then
|
|
||||||
mkdir -p $chroot_path$playground_var/save $chroot_path$playground_var/dumps
|
echo "Setting up chroot in $CHROOT"
|
||||||
touch $chroot_path$playground_var/record
|
|
||||||
touch $chroot_path$playground_var/perm
|
LIBS="`findlibs dgamelaunch`"
|
||||||
touch $chroot_path$playground_var/logfile
|
|
||||||
chown -R $shed_uid:$shed_gid $chroot_path$playground_var
|
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
|
fi
|
||||||
|
|
||||||
if [ -n "$playground_fixed" ]; then
|
|
||||||
mkdir -p $chroot_path$playground_fixed
|
if [ -n "$COMPRESSBIN" -a -e "`which $COMPRESSBIN`" ]; then
|
||||||
cp $playground_fixed/license $chroot_path$playground_fixed
|
COMPRESSDIR="`dirname $COMPRESSBIN`"
|
||||||
if [ -e $playground_fixed/nhdat ]; then
|
COMPRESSDIR="`echo ${COMPRESSDIR%/}`"
|
||||||
cp $playground_fixed/nhdat $chroot_path$playground_fixed
|
COMPRESSDIR="`echo ${COMPRESSDIR#/}`"
|
||||||
else
|
echo "Copying $COMPRESSBIN to $COMPRESSDIR"
|
||||||
(
|
sudo mkdir -p "$COMPRESSDIR"
|
||||||
cd $playground_fixed
|
sudo cp "`which $COMPRESSBIN`" "$COMPRESSDIR/"
|
||||||
cp *.dat cmdhelp data dungeon help hh history \
|
LIBS="$LIBS `findlibs $COMPRESSBIN`"
|
||||||
opthelp options perm recover rumors wizhelp \
|
|
||||||
$chroot_path$playground_fixed
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
fi
|
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
|
# Curses junk
|
||||||
if [ -n "$termdata" ]; then
|
if [ -n "$TERMDATA" ]; then
|
||||||
mkdir -p $chroot_path`dirname $termdata`
|
echo "Copying termdata files from $TERMDATA"
|
||||||
if [ -d $termdata/. ]; then
|
for termdat in $TERMDATA; do
|
||||||
cp -LR $termdata/. $chroot_path$termdata
|
sudo mkdir -p "$CHROOT`dirname $termdat`"
|
||||||
|
if [ -d $termdat/. ]; then
|
||||||
|
sudo cp -LR $termdat/. $CHROOT$termdat
|
||||||
else
|
else
|
||||||
cp $termdata $chroot_path`dirname $termdata`
|
sudo cp $termdat $CHROOT`dirname $termdat`
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
fi
|
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`
|
||||||
libs=`for lib in $libs; do echo $lib; done | sort | uniq`
|
echo "Copying libraries:" $LIBS
|
||||||
echo "Copying libraries:" $libs
|
for lib in $LIBS; do
|
||||||
for lib in $libs; do
|
sudo mkdir -p "$CHROOT`dirname $lib`"
|
||||||
mkdir -p $chroot_path`dirname $lib`
|
sudo cp $lib "$CHROOT$lib"
|
||||||
cp $lib $chroot_path$lib
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
echo "Finished."
|
echo "Finished."
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ maxnicklen = 10
|
||||||
#sortmode = "username"
|
#sortmode = "username"
|
||||||
|
|
||||||
# Path to a prepared chroot jail.
|
# 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
|
# From inside the jail, dgamelaunch's working directory for rcfiles/ttyrec/etc
|
||||||
dglroot = "/dgldir/"
|
dglroot = "/dgldir/"
|
||||||
|
@ -108,15 +108,24 @@ lockfile = "/dgl-lock"
|
||||||
# eg. commands[login] = mkdir "foo", unlink "bar", setenv "Z" "foo"
|
# eg. commands[login] = mkdir "foo", unlink "bar", setenv "Z" "foo"
|
||||||
#
|
#
|
||||||
|
|
||||||
# create the user's ttyrec dir when they register
|
# create the user's dirs when they register
|
||||||
commands[register] = mkdir "%rttyrec/%n"
|
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.
|
# $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"] {
|
menu["mainmenu_anon"] {
|
||||||
bannerfile = "dgl_menu_main_anon.txt"
|
bannerfile = "dgl_menu_main_anon.txt"
|
||||||
cursor = (5,18)
|
cursor = (5,18)
|
||||||
|
@ -126,7 +135,7 @@ menu["mainmenu_anon"] {
|
||||||
commands["q"] = quit
|
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.
|
# $USERNAME in here will be replaced with the user name.
|
||||||
menu["mainmenu_user"] {
|
menu["mainmenu_user"] {
|
||||||
# contents of this file are written to screen.
|
# contents of this file are written to screen.
|
||||||
|
@ -152,37 +161,37 @@ menu["mainmenu_user"] {
|
||||||
|
|
||||||
# Next, we'll define one game's data:
|
# Next, we'll define one game's data:
|
||||||
|
|
||||||
DEFINE {
|
#DEFINE {
|
||||||
# From inside the jail, the location of the binary to be launched.
|
# # From inside the jail, the location of the binary to be launched.
|
||||||
game_path = "/bin/nethackstub"
|
# game_path = "/bin/nethackstub"
|
||||||
|
#
|
||||||
# Full name of the game
|
# # Full name of the game
|
||||||
game_name = "NetHack stub"
|
# game_name = "NetHack stub"
|
||||||
|
#
|
||||||
# Short name, used in the watching menu
|
# # Short name, used in the watching menu
|
||||||
short_name = "NHstb"
|
# short_name = "NHstb"
|
||||||
|
#
|
||||||
# arguments for when we exec the binary
|
# # arguments for when we exec the binary
|
||||||
game_args = "/bin/nethackstub",
|
# game_args = "/bin/nethackstub",
|
||||||
"foo",
|
# "foo",
|
||||||
"user:%n",
|
# "user:%n",
|
||||||
"shed_uid:%u",
|
# "shed_uid:%u",
|
||||||
"bar"
|
# "bar"
|
||||||
|
#
|
||||||
# From inside the jail, where dgamelaunch should put mail.
|
# # From inside the jail, where dgamelaunch should put mail.
|
||||||
spooldir = "/var/mail/"
|
# spooldir = "/var/mail/"
|
||||||
|
#
|
||||||
# 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"
|
||||||
|
#
|
||||||
# Make sure the inprogress dir actually exists. default is "inprogress/"
|
# # Make sure the inprogress dir actually exists. default is "inprogress/"
|
||||||
# Each game you define here must have it's own.
|
# # Each game you define here must have it's own.
|
||||||
inprogressdir = "inprogress-nethackstub/"
|
# inprogressdir = "%rinprogress-nethackstub/"
|
||||||
|
#
|
||||||
# We can also define per-game commands, that are executed
|
# # We can also define per-game commands, that are executed
|
||||||
# when the game starts:
|
# # when the game starts:
|
||||||
# commands = chdir "/dgldir", mkdir "foo_%u_%g"
|
# # commands = chdir "/dgldir", mkdir "foo_%u_%g"
|
||||||
}
|
#}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -191,28 +200,29 @@ DEFINE {
|
||||||
#
|
#
|
||||||
|
|
||||||
DEFINE {
|
DEFINE {
|
||||||
game_path = "/bin/nethack"
|
game_path = "/nh343/nethack.343-nao"
|
||||||
game_name = "NetHack 3.4.3"
|
game_name = "NetHack 3.4.3"
|
||||||
short_name = "NH343"
|
short_name = "NH343"
|
||||||
|
|
||||||
game_args = "/bin/nethack", "-u", "%n"
|
game_args = "/nh343/nethack.343-nao", "-u", "%n"
|
||||||
|
|
||||||
spooldir = "/var/mail/"
|
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
|
# 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
|
# 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...
|
# set up nethack mail stuff, assuming it's compiled with it...
|
||||||
setenv "MAIL" "/var/mail/%n",
|
setenv "MAIL" "/mail/%n",
|
||||||
setenv "SIMPLEMAIL" "1",
|
setenv "SIMPLEMAIL" "1",
|
||||||
# don't let the mail file grow
|
# don't let the mail file grow
|
||||||
unlink "/var/mail/%n"
|
unlink "/mail/%n"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -220,41 +230,41 @@ DEFINE {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
DEFINE {
|
#DEFINE {
|
||||||
game_path = "/bin/crawlss017"
|
# game_path = "/bin/crawlss017"
|
||||||
game_name = "Crawl Stone Soup 0.1.7"
|
# game_name = "Crawl Stone Soup 0.1.7"
|
||||||
short_name = "Cr017"
|
# short_name = "Cr017"
|
||||||
|
#
|
||||||
game_args = "/bin/crawlss017",
|
# game_args = "/bin/crawlss017",
|
||||||
"-name", "%n",
|
# "-name", "%n",
|
||||||
"-dir", "/crawlss017/",
|
# "-dir", "/crawlss017/",
|
||||||
"-rc", "%rrcfiles/%n.crawlrc",
|
# "-rc", "%rrcfiles/%n.crawlrc",
|
||||||
"-morgue", "/crawlss017/morgues/",
|
# "-morgue", "/crawlss017/morgues/",
|
||||||
"-macro", "/crawlss017/macros/%n.macro"
|
# "-macro", "/crawlss017/macros/%n.macro"
|
||||||
|
#
|
||||||
rc_template = "/dgl-default-rcfile.crawl"
|
# rc_template = "/dgl-default-rcfile.crawl"
|
||||||
rc_fmt = "%rrcfiles/%n.crawlrc"
|
# rc_fmt = "%rrcfiles/%n.crawlrc"
|
||||||
inprogressdir = "inprogress-crawlss017/"
|
# inprogressdir = "%rinprogress-crawlss017/"
|
||||||
}
|
#}
|
||||||
|
|
||||||
#
|
#
|
||||||
# fourth game
|
# fourth game
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
DEFINE {
|
#DEFINE {
|
||||||
game_path = "/bin/crawlss020"
|
# game_path = "/bin/crawlss020"
|
||||||
game_name = "Crawl Stone Soup 0.2.0"
|
# game_name = "Crawl Stone Soup 0.2.0"
|
||||||
short_name = "Cr020"
|
# short_name = "Cr020"
|
||||||
|
#
|
||||||
game_args = "/bin/crawlss020",
|
# game_args = "/bin/crawlss020",
|
||||||
"-name", "%n",
|
# "-name", "%n",
|
||||||
"-dir", "/crawlss020/",
|
# "-dir", "/crawlss020/",
|
||||||
"-rc", "/crawlss020/plr/%n/%n.crawlrc",
|
# "-rc", "/crawlss020/plr/%n/%n.crawlrc",
|
||||||
"-morgue", "/crawlss020/plr/%n/",
|
# "-morgue", "/crawlss020/plr/%n/",
|
||||||
"-macro", "/crawlss020/plr/%n/"
|
# "-macro", "/crawlss020/plr/%n/"
|
||||||
|
#
|
||||||
rc_template = "/dgl-default-rcfile.crawl"
|
# rc_template = "/dgl-default-rcfile.crawl"
|
||||||
rc_fmt = "/crawlss020/plr/%n/%n.crawlrc"
|
# rc_fmt = "/crawlss020/plr/%n/%n.crawlrc"
|
||||||
inprogressdir = "inprogress-crawlss020/"
|
# inprogressdir = "%rinprogress-crawlss020/"
|
||||||
}
|
#}
|
||||||
|
|
8
ttyrec.c
8
ttyrec.c
|
@ -85,14 +85,16 @@ struct winsize win;
|
||||||
int uflg;
|
int uflg;
|
||||||
|
|
||||||
int
|
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];
|
char dirname[100];
|
||||||
|
|
||||||
child = subchild = input_child = 0;
|
child = subchild = input_child = 0;
|
||||||
|
|
||||||
snprintf (dirname, 100, "%sttyrec/%s/%s", globalconfig.dglroot, username,
|
if (ttyrec_path[strlen(ttyrec_path)-1] == '/')
|
||||||
ttyrec_filename);
|
snprintf (dirname, 100, "%s%s", ttyrec_path, ttyrec_filename);
|
||||||
|
else
|
||||||
|
snprintf (dirname, 100, "%s/%s", ttyrec_path, ttyrec_filename);
|
||||||
|
|
||||||
atexit(&remove_ipfile);
|
atexit(&remove_ipfile);
|
||||||
if ((fscript = fopen (dirname, "w")) == NULL)
|
if ((fscript = fopen (dirname, "w")) == NULL)
|
||||||
|
|
2
ttyrec.h
2
ttyrec.h
|
@ -21,7 +21,7 @@ extern void doshell (int, char *);
|
||||||
extern void finish (int);
|
extern void finish (int);
|
||||||
extern void remove_ipfile (void);
|
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 pid_t child; /* nethack process */
|
||||||
extern int master, slave;
|
extern int master, slave;
|
||||||
|
|
Loading…
Reference in New Issue