Minor fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17798 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2003-10-08 08:41:10 +00:00
parent 9e3af86051
commit c3b3d5f095
3 changed files with 38 additions and 24 deletions

View file

@ -1,3 +1,8 @@
2003-10-08 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/gdomap.c: Added some checks that getting/setting uid/gid
worked as expected and moved getpwnam() call to where it works.
2003-10-07 Richard Frith-Macdonald <rfm@gnu.org>
* Source/Additions/GSMime.m: ([GSMimeDocument-setContentType:])

View file

@ -136,6 +136,7 @@
- (void) setContent: (id)newContent
type: (NSString*)type
name: (NSString*)name;
- (void) setContentType: (NSString*)newType;
- (void) setHeader: (GSMimeHeader*)info;
@end

View file

@ -4598,6 +4598,21 @@ printf(
}
#endif
}
{
int uid = -2;
int gid = -2;
#ifdef HAVE_PWD_H
#ifdef HAVE_GETPWNAM
struct passwd *pw = getpwnam("nobody");
if (pw != 0)
{
uid = pw->pw_uid;
gid = pw->pw_gid;
}
#endif
#endif
#if !defined(__svr4__)
/*
@ -4627,42 +4642,35 @@ printf(
/*
* Try to become a 'safe' user now that we have
* done everything that needs root priv.
*
* Try to be the user who launched us ... so they can kill us too.
* Otherwise default to user nobody.
*/
if (getuid () != 0)
{
/*
* Try to be the user who launched us ... so they can kill us too.
*/
setuid (getuid ());
setgid (getgid ());
uid = getuid();
gid = getgid();
}
else
if (setgid (gid) < 0)
{
int uid = -2;
int gid = -2;
#ifdef HAVE_PWD_H
#ifdef HAVE_GETPWNAM
struct passwd *pw = getpwnam("nobody");
if (pw != 0)
{
uid = pw->pw_uid;
gid = pw->pw_gid;
}
#endif
#endif
setuid (uid);
setgid (gid);
setgroups (0, 0); /* Empty additional groups list */
sprintf(ebuf, "Failed setgid(%d) - %s", gid, strerror(errno));
gdomap_log(LOG_CRIT);
exit(EXIT_FAILURE);
}
if (getuid() == 0)
if (setuid (uid) < 0)
{
sprintf(ebuf, "Failed setuid(%d) - %s", uid, strerror(errno));
gdomap_log(LOG_CRIT);
exit(EXIT_FAILURE);
}
if (getuid () == 0)
{
sprintf(ebuf, "Still running as root after trying to change");
gdomap_log(LOG_CRIT);
exit(EXIT_FAILURE);
}
#endif /* __MINGW__ */
}
init_probe(); /* Probe other name servers on net. */