"rc_template" { return TYPE_PATH_CANNED; }
"passwd" { return TYPE_PATH_PASSWD; }
"lockfile" { return TYPE_PATH_LOCKFILE; }
-"savefilefmt" { return TYPE_PATH_SAVEFILEFMT; }
"inprogressdir" { return TYPE_PATH_INPROGRESS; }
"game_args" { return TYPE_GAME_ARGS; }
"rc_fmt" { return TYPE_RC_FMT; }
%token TYPE_ALLOW_REGISTRATION
%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_PATH_PASSWD TYPE_PATH_LOCKFILE
%token TYPE_MALSTRING TYPE_PATH_INPROGRESS TYPE_GAME_ARGS TYPE_RC_FMT
%token TYPE_CMDQUEUE
%token <s> TYPE_VALUE
myconfig[ncnf]->mkdir = strdup ($3);
break;
- case TYPE_PATH_SAVEFILEFMT:
- if (myconfig[ncnf]->savefilefmt) free(myconfig[ncnf]->savefilefmt);
- myconfig[ncnf]->savefilefmt = strdup($3);
- break;
-
case TYPE_RC_FMT:
if (myconfig[ncnf]->rc_fmt) free(myconfig[ncnf]->rc_fmt);
myconfig[ncnf]->rc_fmt = strdup($3);
| TYPE_PATH_CANNED { $$ = TYPE_PATH_CANNED; }
| TYPE_PATH_PASSWD { $$ = TYPE_PATH_PASSWD; }
| TYPE_PATH_LOCKFILE { $$ = TYPE_PATH_LOCKFILE; }
- | TYPE_PATH_SAVEFILEFMT { $$ = TYPE_PATH_SAVEFILEFMT; }
| TYPE_PATH_INPROGRESS { $$ = TYPE_PATH_INPROGRESS; }
| TYPE_GAME_ARGS { $$ = TYPE_GAME_ARGS; }
| TYPE_RC_FMT { $$ = TYPE_RC_FMT; }
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";
case TYPE_PATH_INPROGRESS: return "inprogressdir";
case TYPE_GAME_ARGS: return "game_args";
case TYPE_RC_FMT: return "rc_fmt";
/* ************************************************************* */
-/*
- * Backup the savefile, if configured.
- * Returns non-zero if successful, otherwise an error message has been
- * given already.
- */
-int
-backup_savefile (int game)
-{
- /*char buf[1024];*/
- char *f, *p, *end, *buf;
- int ispercent = 0, n;
- int in, out;
-
- f = myconfig[game]->savefilefmt;
-
- if (*f == '\0')
- return 1;
- if (me == NULL)
- graceful_exit (147);
-
- buf = dgl_format_str(game, me, f);
- p = buf;
- p += strlen(buf);
-
- /*fprintf(stderr, "***\n[SAVEFILE=%s]\n***\n", buf);
- sleep(3);*/
- in = open (buf, O_RDONLY);
- if (in == -1)
- {
- if (errno == ENOENT)
- return 1; /* Nothing to back up */
- else
- {
- fprintf (stderr, "Cannot open savefile '%s'\n", buf);
- perror ("for input");
- return 0;
- }
- }
- strcpy (p, ".bak");
- out = open (buf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
- if (out == -1)
- {
- close (in);
- fprintf (stderr, "Cannot open backup savefile '%s'\n", buf);
- perror ("for output");
- return 0;
- }
-
- while ((n = read (in, buf, sizeof(buf))) > 0)
- {
- n = write (out, buf, n);
- if (n < 0)
- break;
- }
- close (out);
- close (in);
- if (n < 0)
- perror ("I/O error while backing up savefile");
- return n >= 0;
-}
-
int
purge_stale_locks (int game)
{
/* then run the game-specific commands */
dgl_exec_cmdqueue(myconfig[userchoice]->cmdqueue, userchoice, me);
+ /*
if (!backup_savefile (userchoice))
graceful_exit (5);
+ */
/* environment */
if (myconfig[userchoice]->rcfile) {
char* mkdir;
char* rcfile;
char* spool;
- char* savefilefmt;
+ /*char* savefilefmt;*/
char* inprogressdir;
int num_args; /* # of bin_args */
char **bin_args; /* args for game binary */
/* shed_uid = *//* 5,*/
/* shed_gid = */ /*60,*/ /* games:games in Debian */
/* max = */ /*64000,*/
- /* savefilefmt = */ "", /* don't do this by default */
+ /* savefilefmt = */ /*"",*/ /* don't do this by default */
/* inprogressdir = */ "inprogress/",
/* num_args = */ 0,
/* bin_args = */ NULL,
if (!myconfig[tmp]->shortname) myconfig[tmp]->shortname = defconfig.shortname;
if (!myconfig[tmp]->rcfile) myconfig[tmp]->rcfile = defconfig.rcfile;
if (!myconfig[tmp]->spool) myconfig[tmp]->spool = defconfig.spool;
- if (!myconfig[tmp]->savefilefmt) myconfig[tmp]->savefilefmt = defconfig.savefilefmt;
+ /*if (!myconfig[tmp]->savefilefmt) myconfig[tmp]->savefilefmt = defconfig.savefilefmt;*/
if (!myconfig[tmp]->inprogressdir) myconfig[tmp]->inprogressdir = defconfig.inprogressdir;
}
# From inside the jail, the default .nethackrc that is copied for new users.
# rc_template = "/dgl-default-rcfile"
-
-# 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"
-
# make sure the inprogress dir actually exists. default is "inprogress/"
# each game you define here must have it's own.
inprogressdir = "inprogress-nethackstub/"
# %r == dglroot
# %n == user name
rc_fmt = "%rrcfiles/%n.nethackrc"
-savefilefmt = "/var/games/nethack/save/%u%n.gz"
inprogressdir = "inprogress-nethack/"
+# back up savefile
+commands = cp "/var/games/nethack/save/%u%n.gz" "/var/games/nethack/save/%u%n.gz.bak"
+
}
#