only use a .forward file if owned by the receiver
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 23 Aug 1981 10:36:41 +0000 (02:36 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 23 Aug 1981 10:36:41 +0000 (02:36 -0800)
SCCS-vsn: usr.sbin/sendmail/src/alias.c 3.18
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 3.31
SCCS-vsn: usr.sbin/sendmail/src/recipient.c 3.7

usr/src/usr.sbin/sendmail/src/alias.c
usr/src/usr.sbin/sendmail/src/recipient.c
usr/src/usr.sbin/sendmail/src/sendmail.h

index 80e8268..4063f8a 100644 (file)
@@ -1,10 +1,12 @@
 # include <pwd.h>
 # include <pwd.h>
+# include <sys/types.h>
+# include <sys/stat.h>
 # include "sendmail.h"
 
 # ifdef DBM
 # include "sendmail.h"
 
 # ifdef DBM
-static char SccsId[] = "@(#)alias.c    3.17    %G%     (with DBM)";
+static char SccsId[] = "@(#)alias.c    3.18    %G%     (with DBM)";
 # else DBM
 # else DBM
-static char SccsId[] = "@(#)alias.c    3.17    %G%     (without DBM)";
+static char SccsId[] = "@(#)alias.c    3.18    %G%     (without DBM)";
 # endif DBM
 
 /*
 # endif DBM
 
 /*
@@ -333,6 +335,7 @@ forward(user)
        char buf[60];
        register FILE *fp;
        register char *p;
        char buf[60];
        register FILE *fp;
        register char *p;
+       struct stat stbuf;
 
 # ifdef DEBUG
        if (Debug)
 
 # ifdef DEBUG
        if (Debug)
@@ -345,7 +348,8 @@ forward(user)
        /* good address -- look for .forward file in home */
        define('z', user->q_home);
        (void) expand("$z/.forward", buf, &buf[sizeof buf - 1]);
        /* good address -- look for .forward file in home */
        define('z', user->q_home);
        (void) expand("$z/.forward", buf, &buf[sizeof buf - 1]);
-       if (access(buf, 4) < 0)
+       if (stat(buf, &stbuf) < 0 || stbuf.st_uid != user->q_uid ||
+           !bitset(S_IREAD, stbuf.st_mode))
                return;
 
        /* we do have an address to forward to -- do it */
                return;
 
        /* we do have an address to forward to -- do it */
index 826fd42..7051f17 100644 (file)
@@ -1,7 +1,7 @@
 # include <pwd.h>
 # include "sendmail.h"
 
 # include <pwd.h>
 # include "sendmail.h"
 
-static char SccsId[] = "@(#)recipient.c        3.6     %G%";
+static char SccsId[] = "@(#)recipient.c        3.7     %G%";
 
 /*
 **  SENDTO -- Designate a send list.
 
 /*
 **  SENDTO -- Designate a send list.
@@ -199,6 +199,7 @@ recipient(a)
                        else
                        {
                                a->q_home = newstr(pw->pw_dir);
                        else
                        {
                                a->q_home = newstr(pw->pw_dir);
+                               a->q_uid = pw->pw_uid;
                                if (strcmp(buf, a->q_user) == 0)
                                        forward(a);
                        }
                                if (strcmp(buf, a->q_user) == 0)
                                        forward(a);
                        }
index 61d33c0..b8d55c5 100644 (file)
@@ -1,7 +1,7 @@
 /*
 **  SENDMAIL.H -- Global definitions for sendmail.
 **
 /*
 **  SENDMAIL.H -- Global definitions for sendmail.
 **
-**     @(#)sendmail.h  3.30    %G%
+**     @(#)sendmail.h  3.31    %G%
 */
 
 
 */
 
 
@@ -51,6 +51,7 @@ struct address
        short           q_mailer;       /* mailer to use */
        short           q_rmailer;      /* real mailer (before mapping) */
        u_short         q_flags;        /* status flags, see below */
        short           q_mailer;       /* mailer to use */
        short           q_rmailer;      /* real mailer (before mapping) */
        u_short         q_flags;        /* status flags, see below */
+       short           q_uid;          /* user-id of receiver (if known) */
        char            *q_home;        /* home dir (local mailer only) */
        struct address  *q_next;        /* chain */
 };
        char            *q_home;        /* home dir (local mailer only) */
        struct address  *q_next;        /* chain */
 };