Mercurial > hg > early-roguelike
diff srogue/save.c @ 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 | e6c8652473fe |
children | 85bd398cb96d |
line wrap: on
line diff
--- 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) {