Advanced Rogue family: overhaul privilege handling.
Advanced Rogue 5 and 7, and XRogue, now open the scorefile and logfile at startup and then drop any set[ug]id privileges if the savedir is not being used.
This commit is contained in:
parent
1a5e14ad9b
commit
3554339257
9 changed files with 123 additions and 38 deletions
|
|
@ -36,6 +36,9 @@
|
|||
* scoreout() and scorein() to reflect the change. Also update SCORELEN.
|
||||
*/
|
||||
|
||||
extern int scorefd;
|
||||
extern FILE *logfile;
|
||||
|
||||
struct sc_ent {
|
||||
unsigned long sc_score;
|
||||
char sc_name[LINELEN];
|
||||
|
|
@ -201,7 +204,7 @@ short monst;
|
|||
* Open file and read list
|
||||
*/
|
||||
|
||||
if ((fd = open(score_file, O_RDWR | O_CREAT, 0666)) < 0)
|
||||
if ((fd = scorefd) < 0)
|
||||
{
|
||||
printf("\nCannot open score_file.\n");
|
||||
return;
|
||||
|
|
@ -576,7 +579,6 @@ short monst;
|
|||
|
||||
void writelog(unsigned long amount, int flags, short monst) {
|
||||
#ifdef LOGFILE
|
||||
FILE *logfi;
|
||||
char fate[100];
|
||||
char *class;
|
||||
struct linked_list *item;
|
||||
|
|
@ -585,6 +587,8 @@ void writelog(unsigned long amount, int flags, short monst) {
|
|||
|
||||
if (waswizard)
|
||||
return;
|
||||
if (logfile == NULL)
|
||||
return;
|
||||
switch (player.t_ctype) {
|
||||
case C_FIGHTER: class = "Fighter";
|
||||
when C_MAGICIAN: class = "Magician";
|
||||
|
|
@ -609,15 +613,10 @@ void writelog(unsigned long amount, int flags, short monst) {
|
|||
else
|
||||
return;
|
||||
|
||||
logfi = fopen(LOGFILE, "a");
|
||||
if (logfi == NULL) {
|
||||
perror(LOGFILE);
|
||||
return;
|
||||
}
|
||||
fprintf(logfi, "%d %d %s %d %s %d %d %d %c %s\n", time(NULL), amount,
|
||||
fprintf(logfile, "%d %d %s %d %s %d %d %d %c %s\n", time(NULL), amount,
|
||||
whoami, pstats.s_lvl, class, level, max_level, quest_item, had_quest,
|
||||
fate);
|
||||
fclose(logfi);
|
||||
fclose(logfile);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue