From ef13533a164364203b75da29dc379edc5691208e Mon Sep 17 00:00:00 2001 From: Eric Allman Date: Wed, 21 Jun 1995 14:12:42 -0800 Subject: [PATCH] close passwd file before setuid() "just in case" SCCS-vsn: usr.sbin/sendmail/src/main.c 8.137 SCCS-vsn: usr.sbin/sendmail/src/util.c 8.78 SCCS-vsn: usr.sbin/sendmail/src/readcf.c 8.109 SCCS-vsn: usr.sbin/sendmail/src/deliver.c 8.160 --- usr/src/usr.sbin/sendmail/src/deliver.c | 4 +++- usr/src/usr.sbin/sendmail/src/main.c | 9 ++++++++- usr/src/usr.sbin/sendmail/src/readcf.c | 2 +- usr/src/usr.sbin/sendmail/src/util.c | 3 ++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/usr/src/usr.sbin/sendmail/src/deliver.c b/usr/src/usr.sbin/sendmail/src/deliver.c index 1f609c3cad..d6937be90d 100644 --- a/usr/src/usr.sbin/sendmail/src/deliver.c +++ b/usr/src/usr.sbin/sendmail/src/deliver.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)deliver.c 8.159 (Berkeley) %G%"; +static char sccsid[] = "@(#)deliver.c 8.160 (Berkeley) %G%"; #endif /* not lint */ #include "sendmail.h" @@ -1316,6 +1316,7 @@ tryhost: } /* reset user id */ + endpwent(); if (bitnset(M_SPECIFIC_UID, m->m_flags)) (void) setuid(m->m_uid); else if (bitset(S_ISUID, stb.st_mode)) @@ -2709,6 +2710,7 @@ mailfile(filename, ctladdr, sfflags, e) } /* now set the group and user ids */ + endpwent(); if (RealUserName != NULL) (void) initgroups(RealUserName, RealGid); else diff --git a/usr/src/usr.sbin/sendmail/src/main.c b/usr/src/usr.sbin/sendmail/src/main.c index 8321ac773d..d781627c9f 100644 --- a/usr/src/usr.sbin/sendmail/src/main.c +++ b/usr/src/usr.sbin/sendmail/src/main.c @@ -13,7 +13,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)main.c 8.136 (Berkeley) %G%"; +static char sccsid[] = "@(#)main.c 8.137 (Berkeley) %G%"; #endif /* not lint */ #define _DEFINE @@ -533,6 +533,7 @@ main(argc, argv, envp) if (RealUid != 0) warn_C_flag = TRUE; ConfFile = optarg; + endpwent(); (void) setgid(RealGid); (void) setuid(RealUid); safecf = FALSE; @@ -634,6 +635,7 @@ main(argc, argv, envp) break; case 'X': /* traffic log file */ + endpwent(); setgid(RealGid); setuid(RealUid); TrafficLogFile = fopen(optarg, "a"); @@ -916,6 +918,7 @@ main(argc, argv, envp) /* if we've had errors so far, exit now */ if (ExitStat != EX_OK && OpMode != MD_TEST) { + endpwent(); setuid(RealUid); exit(ExitStat); } @@ -935,6 +938,7 @@ main(argc, argv, envp) #ifdef QUEUE dropenvelope(CurEnv); printqueue(); + endpwent(); setuid(RealUid); exit(EX_OK); #else /* QUEUE */ @@ -945,6 +949,7 @@ main(argc, argv, envp) case MD_INITALIAS: /* initialize alias database */ initmaps(TRUE, CurEnv); + endpwent(); setuid(RealUid); exit(EX_OK); @@ -1233,6 +1238,7 @@ finis() ExitStat = EX_OK; /* reset uid for process accounting */ + endpwent(); setuid(RealUid); exit(ExitStat); @@ -1263,6 +1269,7 @@ intsig() #endif /* reset uid for process accounting */ + endpwent(); setuid(RealUid); exit(EX_OK); diff --git a/usr/src/usr.sbin/sendmail/src/readcf.c b/usr/src/usr.sbin/sendmail/src/readcf.c index 14e6c4d8e0..f7bb0fd9eb 100644 --- a/usr/src/usr.sbin/sendmail/src/readcf.c +++ b/usr/src/usr.sbin/sendmail/src/readcf.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)readcf.c 8.108 (Berkeley) %G%"; +static char sccsid[] = "@(#)readcf.c 8.109 (Berkeley) %G%"; #endif /* not lint */ # include "sendmail.h" diff --git a/usr/src/usr.sbin/sendmail/src/util.c b/usr/src/usr.sbin/sendmail/src/util.c index 58b1f2fe2c..5bbfed1e1d 100644 --- a/usr/src/usr.sbin/sendmail/src/util.c +++ b/usr/src/usr.sbin/sendmail/src/util.c @@ -7,7 +7,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)util.c 8.77 (Berkeley) %G%"; +static char sccsid[] = "@(#)util.c 8.78 (Berkeley) %G%"; #endif /* not lint */ # include "sendmail.h" @@ -1794,6 +1794,7 @@ prog_open(argv, pfd, e) close(fileno(e->e_lockfp)); /* run as default user */ + endpwent(); setgid(DefGid); setuid(DefUid); -- 2.20.1