From: Pasi Kallinen Date: Sat, 11 Apr 2015 18:07:57 +0000 (+0300) Subject: Allow disabling savefile UID checking in sysconf X-Git-Tag: NetHack-3.6.0_RC01~414^2~41^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb77c57a6c2c8891e6ac12e2bb95c38528d32cbd;p=nethack Allow disabling savefile UID checking in sysconf --- diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index 66b27f5bf..910372edd 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -3007,6 +3007,9 @@ A string explaining how to recover a game on this system (no default value). SEDUCE 0 or 1 to disable or enable, respectively, the SEDUCE option (see the source for details on this function). +.lp +CHECK_SAVE_UID +0 or 1 to disable or enable, respectively, the UID checking for savefiles. .pg The following options affect the score file: .pg diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index ae3cfa8a7..1f2bb198b 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -3597,6 +3597,9 @@ A string explaining how to recover a game on this system (no default value). \item[\ib{SEDUCE}] 0 or 1 to disable or enable, respectively, the SEDUCE option (see the source) for details on this function. +%.lp +\item[\ib{CHECK\_SAVE\_UID}] +0 or 1 to disable or enable, respectively, the UID checking for savefiles. \elist %.pg diff --git a/include/sys.h b/include/sys.h index 84d42b5b6..8b6c4b502 100644 --- a/include/sys.h +++ b/include/sys.h @@ -35,6 +35,7 @@ struct sysopt { # endif #endif int seduce; + int check_save_uid; /* restoring savefile checks UID? */ }; extern struct sysopt sysopt; diff --git a/src/files.c b/src/files.c index 2388e032d..1ed9a3c05 100644 --- a/src/files.c +++ b/src/files.c @@ -2206,6 +2206,9 @@ int src; } else if (src == SET_IN_SYS && match_varname(buf, "RECOVER", 7)) { if (sysopt.recover) free(sysopt.recover); sysopt.recover = dupstr(bufp); + } else if (src == SET_IN_SYS && match_varname(buf, "CHECK_SAVE_UID", 14)) { + n = atoi(bufp); + sysopt.check_save_uid = n; } else if (match_varname(buf, "SEDUCE", 6)) { n = !!atoi(bufp); /* XXX this could be tighter */ /* allow anyone to turn it off, but only sysconf to turn it on*/ diff --git a/src/restore.c b/src/restore.c index d46adbb31..1caab6108 100644 --- a/src/restore.c +++ b/src/restore.c @@ -502,6 +502,13 @@ register struct obj *otmp; else otmp->spe = fruitadd(oldf->fname, (struct fruit *)0); } + +#ifdef SYSCF +#define SYSOPT_CHECK_SAVE_UID sysopt.check_save_uid +#else +#define SYSOPT_CHECK_SAVE_UID TRUE +#endif + STATIC_OVL boolean restgamestate(fd, stuckid, steedid) @@ -517,7 +524,7 @@ unsigned int *stuckid, *steedid; unsigned long uid; mread(fd, (genericptr_t) &uid, sizeof uid); - if (uid != (unsigned long)getuid()) { /* strange ... */ + if (SYSOPT_CHECK_SAVE_UID && uid != (unsigned long)getuid()) { /* strange ... */ /* for wizard mode, issue a reminder; for others, treat it as an attempt to cheat and refuse to restore this file */ pline("Saved game was not yours."); diff --git a/src/sys.c b/src/sys.c index 6ca0017f7..e698627be 100644 --- a/src/sys.c +++ b/src/sys.c @@ -67,6 +67,7 @@ sys_early_init() # endif #endif + sysopt.check_save_uid = 1; sysopt.seduce = 1; /* if it's compiled in, default to on */ sysopt_seduce_set(sysopt.seduce); } diff --git a/sys/unix/sysconf b/sys/unix/sysconf index 50fa74085..aff14b8c7 100644 --- a/sys/unix/sysconf +++ b/sys/unix/sysconf @@ -35,6 +35,9 @@ MAXPLAYERS=10 # Uncomment the next line to disable the SEDUCE option. #SEDUCE=0 +# Uncomment to disable savefile UID checking. +#CHECK_SAVE_UID=0 + # Record (high score) file options. # CAUTION: changing these after people have started playing games can # lead to lost high scores!