summaryrefslogtreecommitdiffstats
path: root/games
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1994-10-03 14:41:11 +0000
committerache <ache@FreeBSD.org>1994-10-03 14:41:11 +0000
commitf18171715f29692309264f9422251fcd27b55791 (patch)
treec1b378cf5ca1a86bb632844f8f08b089619fa993 /games
parent95ad10995be385996148339d29a5ae3f57c84b3a (diff)
downloadFreeBSD-src-f18171715f29692309264f9422251fcd27b55791.zip
FreeBSD-src-f18171715f29692309264f9422251fcd27b55791.tar.gz
Allow to save/restore files (was games user suid problem)
Diffstat (limited to 'games')
-rw-r--r--games/rogue/save.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/games/rogue/save.c b/games/rogue/save.c
index 76475bb..2ca5cc3 100644
--- a/games/rogue/save.c
+++ b/games/rogue/save.c
@@ -108,6 +108,7 @@ char *sfile;
sfile = name_buffer;
}
}
+ setuid(getuid());
if ( ((fp = fopen(sfile, "w")) == NULL) ||
((file_id = md_get_file_id(sfile)) == -1)) {
message("problem accessing the save file", 0);
@@ -161,6 +162,14 @@ char *sfile;
}
}
+static char save_name[80];
+
+static del_save_file()
+{
+ setuid(getuid());
+ md_df(save_name);
+}
+
restore(fname)
char *fname;
{
@@ -233,8 +242,9 @@ char *fname;
clear();
clean_up("sorry, file has been touched");
}
- if ((!wizard) && !md_df(fname)) {
- clean_up("cannot delete file");
+ if ((!wizard)) {
+ strcpy(save_name, fname);
+ atexit(del_save_file);
}
msg_cleared = 0;
ring_stats(0);
OpenPOWER on IntegriCloud