Apollo/POSIX changes -- leading pathname of // can legally have
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 23 Jan 1994 01:01:04 +0000 (17:01 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 23 Jan 1994 01:01:04 +0000 (17:01 -0800)
different semantics; ensure that this never happens when building pathnames

SCCS-vsn: usr.sbin/sendmail/src/recipient.c 8.40
SCCS-vsn: usr.sbin/sendmail/src/envelope.c 8.29
SCCS-vsn: usr.sbin/sendmail/src/queue.c 8.37

usr/src/usr.sbin/sendmail/src/envelope.c
usr/src/usr.sbin/sendmail/src/queue.c
usr/src/usr.sbin/sendmail/src/recipient.c

index 1981409..143d139 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)envelope.c 8.28 (Berkeley) %G%";
+static char sccsid[] = "@(#)envelope.c 8.29 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -668,9 +668,11 @@ setsender(from, e, delimptr, internal)
                        **  Process passwd file entry.
                        */
 
                        **  Process passwd file entry.
                        */
 
-
                        /* extract home directory */
                        /* extract home directory */
-                       e->e_from.q_home = newstr(pw->pw_dir);
+                       if (strcmp(pw->pw_dir, "/") == 0)
+                               e->e_from.q_home = newstr("");
+                       else
+                               e->e_from.q_home = newstr(pw->pw_dir);
                        define('z', e->e_from.q_home, e);
 
                        /* extract user and group id */
                        define('z', e->e_from.q_home, e);
 
                        /* extract user and group id */
@@ -696,7 +698,11 @@ setsender(from, e, delimptr, internal)
        else if (!internal && OpMode != MD_DAEMON)
        {
                if (e->e_from.q_home == NULL)
        else if (!internal && OpMode != MD_DAEMON)
        {
                if (e->e_from.q_home == NULL)
+               {
                        e->e_from.q_home = getenv("HOME");
                        e->e_from.q_home = getenv("HOME");
+                       if (strcmp(e->e_from.q_home, "/") == 0)
+                               e->e_from.q_home++;
+               }
                e->e_from.q_uid = RealUid;
                e->e_from.q_gid = RealGid;
                e->e_from.q_flags |= QGOODUID;
                e->e_from.q_uid = RealUid;
                e->e_from.q_gid = RealGid;
                e->e_from.q_flags |= QGOODUID;
index d07c568..e037e91 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef QUEUE
 
 #ifndef lint
 #ifdef QUEUE
-static char sccsid[] = "@(#)queue.c    8.36 (Berkeley) %G% (with queueing)";
+static char sccsid[] = "@(#)queue.c    8.37 (Berkeley) %G% (with queueing)";
 #else
 #else
-static char sccsid[] = "@(#)queue.c    8.36 (Berkeley) %G% (without queueing)";
+static char sccsid[] = "@(#)queue.c    8.37 (Berkeley) %G% (without queueing)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -1529,7 +1529,10 @@ setctluser(user)
                *p++ = '\0';
        if (*user != '\0' && (pw = getpwnam(user)) != NULL)
        {
                *p++ = '\0';
        if (*user != '\0' && (pw = getpwnam(user)) != NULL)
        {
-               a->q_home = newstr(pw->pw_dir);
+               if (strcmp(pw->pw_dir, "/") == 0)
+                       a->q_home = "";
+               else
+                       a->q_home = newstr(pw->pw_dir);
                a->q_uid = pw->pw_uid;
                a->q_gid = pw->pw_gid;
                a->q_user = newstr(user);
                a->q_uid = pw->pw_uid;
                a->q_gid = pw->pw_gid;
                a->q_user = newstr(user);
index 5155fb5..5eaf4f4 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)recipient.c        8.39 (Berkeley) %G%";
+static char sccsid[] = "@(#)recipient.c        8.40 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -496,7 +496,10 @@ recipient(a, sendq, e)
                                (void) strcpy(buf, pw->pw_name);
                                goto trylocaluser;
                        }
                                (void) strcpy(buf, pw->pw_name);
                                goto trylocaluser;
                        }
-                       a->q_home = newstr(pw->pw_dir);
+                       if (strcmp(pw->pw_dir, "/") == 0)
+                               a->q_home = "";
+                       else
+                               a->q_home = newstr(pw->pw_dir);
                        a->q_uid = pw->pw_uid;
                        a->q_gid = pw->pw_gid;
                        a->q_ruser = newstr(pw->pw_name);
                        a->q_uid = pw->pw_uid;
                        a->q_gid = pw->pw_gid;
                        a->q_ruser = newstr(pw->pw_name);