Mercurial > hg > early-roguelike
changeset 174:1863409c44cf
srogue: improve privilege handling.
Setgid privileges are now dropped when not required. restore() is now
less complex.
author | John "Elwin" Edwards |
---|---|
date | Sat, 01 Aug 2015 16:23:24 -0400 |
parents | 78fa1d0e5d25 |
children | 10c273a62228 |
files | srogue/main.c srogue/save.c |
diffstat | 2 files changed, 3 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/srogue/main.c Sat Aug 01 15:12:11 2015 -0400 +++ b/srogue/main.c Sat Aug 01 16:23:24 2015 -0400 @@ -121,7 +121,7 @@ #endif if (!use_savedir) - md_droppriv(); + md_normaluser(); /* get home and options from environment */
--- a/srogue/save.c Sat Aug 01 15:12:11 2015 -0400 +++ b/srogue/save.c Sat Aug 01 16:23:24 2015 -0400 @@ -131,17 +131,13 @@ /* * dosave: - * Set UID back to user and save the game + * Save the game. UID/GID no longer get reset here. */ dosave() { FILE *savef; ignore(); - if (!use_savedir) - { - md_resetpriv(); - } umask(022); if (file_name[0] != '\0') { @@ -287,50 +283,12 @@ #endif if (!wizard) { -#if defined(HAVE_WORKING_FORK) - endwin(); - if (!use_savedir) - { - while((pid = fork()) < 0) - sleep(1); - - /* set id to unlink file */ - if(pid == 0) - { - md_resetpriv(); - unlink(file); - exit(0); - } - /* wait for unlink to finish */ - else - { - while(wait(&ret_status) != pid) - continue; - if (ret_status < 0) - { - printf("Cannot unlink file\n"); - return FALSE; - } - } - } - else - { - /* Don't drop privileges, they're needed - * for the unlink. */ - if (unlink(file) < 0) - { - printf("Cannot unlink file\n"); - return FALSE; - } - } -#else if (unlink(file) < 0) { + endwin(); printf("Cannot unlink file\n"); return FALSE; } -#endif - } if (him->s_hpt <= 0) {