close passwd file before setuid() "just in case"
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 21 Jun 1995 22:12:42 +0000 (14:12 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Wed, 21 Jun 1995 22:12:42 +0000 (14:12 -0800)
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
usr/src/usr.sbin/sendmail/src/main.c
usr/src/usr.sbin/sendmail/src/readcf.c
usr/src/usr.sbin/sendmail/src/util.c

index 1f609c3..d6937be 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #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"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -1316,6 +1316,7 @@ tryhost:
                        }
 
                        /* reset user id */
                        }
 
                        /* 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))
                        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 */
                }
 
                /* now set the group and user ids */
+               endpwent();
                if (RealUserName != NULL)
                        (void) initgroups(RealUserName, RealGid);
                else
                if (RealUserName != NULL)
                        (void) initgroups(RealUserName, RealGid);
                else
index 8321ac7..d781627 100644 (file)
@@ -13,7 +13,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #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
 #endif /* not lint */
 
 #define        _DEFINE
@@ -533,6 +533,7 @@ main(argc, argv, envp)
                        if (RealUid != 0)
                                warn_C_flag = TRUE;
                        ConfFile = optarg;
                        if (RealUid != 0)
                                warn_C_flag = TRUE;
                        ConfFile = optarg;
+                       endpwent();
                        (void) setgid(RealGid);
                        (void) setuid(RealUid);
                        safecf = FALSE;
                        (void) setgid(RealGid);
                        (void) setuid(RealUid);
                        safecf = FALSE;
@@ -634,6 +635,7 @@ main(argc, argv, envp)
                        break;
 
                  case 'X':     /* traffic log file */
                        break;
 
                  case 'X':     /* traffic log file */
+                       endpwent();
                        setgid(RealGid);
                        setuid(RealUid);
                        TrafficLogFile = fopen(optarg, "a");
                        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)
        {
        /* if we've had errors so far, exit now */
        if (ExitStat != EX_OK && OpMode != MD_TEST)
        {
+               endpwent();
                setuid(RealUid);
                exit(ExitStat);
        }
                setuid(RealUid);
                exit(ExitStat);
        }
@@ -935,6 +938,7 @@ main(argc, argv, envp)
 #ifdef QUEUE
                dropenvelope(CurEnv);
                printqueue();
 #ifdef QUEUE
                dropenvelope(CurEnv);
                printqueue();
+               endpwent();
                setuid(RealUid);
                exit(EX_OK);
 #else /* QUEUE */
                setuid(RealUid);
                exit(EX_OK);
 #else /* QUEUE */
@@ -945,6 +949,7 @@ main(argc, argv, envp)
          case MD_INITALIAS:
                /* initialize alias database */
                initmaps(TRUE, CurEnv);
          case MD_INITALIAS:
                /* initialize alias database */
                initmaps(TRUE, CurEnv);
+               endpwent();
                setuid(RealUid);
                exit(EX_OK);
 
                setuid(RealUid);
                exit(EX_OK);
 
@@ -1233,6 +1238,7 @@ finis()
                ExitStat = EX_OK;
 
        /* reset uid for process accounting */
                ExitStat = EX_OK;
 
        /* reset uid for process accounting */
+       endpwent();
        setuid(RealUid);
 
        exit(ExitStat);
        setuid(RealUid);
 
        exit(ExitStat);
@@ -1263,6 +1269,7 @@ intsig()
 #endif
 
        /* reset uid for process accounting */
 #endif
 
        /* reset uid for process accounting */
+       endpwent();
        setuid(RealUid);
 
        exit(EX_OK);
        setuid(RealUid);
 
        exit(EX_OK);
index 14e6c4d..f7bb0fd 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #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"
 #endif /* not lint */
 
 # include "sendmail.h"
index 58b1f2f..5bbfed1 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #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"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -1794,6 +1794,7 @@ prog_open(argv, pfd, e)
                close(fileno(e->e_lockfp));
 
        /* run as default user */
                close(fileno(e->e_lockfp));
 
        /* run as default user */
+       endpwent();
        setgid(DefGid);
        setuid(DefUid);
 
        setgid(DefGid);
        setuid(DefUid);