Security fix.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14004 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2002-07-02 14:20:32 +00:00
parent b697f0fdad
commit 13f48a05f7
2 changed files with 21 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2002-07-02 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/gdomap.c: Don't write to pidfile until *after* setuid away
from root. Bug reported by James Kehl <mkehl@gil.com.au>
2002-07-01 Richard Frith-Macdonald <rfm@gnu.org> 2002-07-01 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSMime.m: Correct test for multipart content when * Source/Additions/GSMime.m: Correct test for multipart content when

View file

@ -4466,7 +4466,7 @@ printf(
} }
} }
if (pidfile) { if (pidfile)
{ {
FILE *fptr = fopen(pidfile, "at"); FILE *fptr = fopen(pidfile, "at");
@ -4479,7 +4479,6 @@ printf(
fprintf(fptr, "%d\n", (int) getpid()); fprintf(fptr, "%d\n", (int) getpid());
fclose(fptr); fclose(fptr);
} }
}
/* /*
* Ensure we don't have any open file descriptors which may refer * Ensure we don't have any open file descriptors which may refer
@ -4574,6 +4573,21 @@ printf(
setuid (uid); setuid (uid);
} }
#endif /* __MINGW__ */ #endif /* __MINGW__ */
if (pidfile)
{
FILE *fptr = fopen(pidfile, "at");
if (fptr == 0)
{
sprintf(ebuf, "Unable to open pid file - '%s'", pidfile);
gdomap_log(LOG_CRIT);
exit(1);
}
fprintf(fptr, "%d\n", (int) getpid());
fclose(fptr);
}
#if !defined(__svr4__) #if !defined(__svr4__)
/* /*
* As another level of paranoia - restrict this process to /tmp * As another level of paranoia - restrict this process to /tmp