# HG changeset patch # User Mikael Berthe # Date 1126356717 -7200 # Node ID 4470868f90e50f82cf44ed87e7cf89069c8b65f9 # Parent ac85ce87f539a43a2a2fa4257e8704536df28a50 Check the tracelog file actually belongs to the user (if logging enabled) diff -r ac85ce87f539 -r 4470868f90e5 mcabber/src/utils.c --- a/mcabber/src/utils.c Tue Sep 06 21:49:27 2005 +0200 +++ b/mcabber/src/utils.c Sat Sep 10 14:51:57 2005 +0200 @@ -39,6 +39,8 @@ void ut_InitDebug(unsigned int level, const char *filename) { FILE *fp; + struct stat buf; + int err; if (level < 1) { DebugEnabled = 0; @@ -67,9 +69,23 @@ fprintf(stderr, "ERROR: Cannot open tracelog file\n"); return; } + + err = fstat(fileno(fp), &buf); + if (err || buf.st_uid != geteuid()) { + fclose(fp); + DebugEnabled = 0; + FName = NULL; + if (err) { + fprintf(stderr, "ERROR: cannot stat the tracelog file!\n"); + } else { + fprintf(stderr, "ERROR: tracelog file does not belong to you!\n"); + } + return; + } + fchmod(fileno(fp), S_IRUSR|S_IWUSR); + fprintf(fp, "New trace log started.\n" "----------------------\n"); - fchmod(fileno(fp), S_IRUSR|S_IWUSR); fclose(fp); }