SCCS-vsn: usr.sbin/sendmail/src/recipient.c 8.27
SCCS-vsn: usr.sbin/sendmail/src/savemail.c 8.22
SCCS-vsn: usr.sbin/sendmail/src/util.c 8.22
-static char sccsid[] = "@(#)recipient.c 8.26 (Berkeley) %G%";
+static char sccsid[] = "@(#)recipient.c 8.27 (Berkeley) %G%";
#endif /* not lint */
# include "sendmail.h"
#endif /* not lint */
# include "sendmail.h"
a->q_flags |= QBADADDR;
usrerr("550 Cannot mail directly to files");
}
a->q_flags |= QBADADDR;
usrerr("550 Cannot mail directly to files");
}
- else if (!writable(buf))
+ else if (!writable(buf, SFF_ANYFILE))
{
a->q_flags |= QBADADDR;
giveresponse(EX_CANTCREAT, m, NULL, a->q_alias, e);
{
a->q_flags |= QBADADDR;
giveresponse(EX_CANTCREAT, m, NULL, a->q_alias, e);
** not writable. This is also enforced by mailfile.
**
** Parameters:
** not writable. This is also enforced by mailfile.
**
** Parameters:
-** s -- pointer to a stat struct for the file.
+** filename -- the file name to check.
+** flags -- SFF_* flags to control the function.
**
** Returns:
** TRUE -- if we will be able to write this file.
**
** Returns:
** TRUE -- if we will be able to write this file.
+writable(filename, flags)
{
uid_t euid;
gid_t egid;
{
uid_t euid;
gid_t egid;
extern char RealUserName[];
if (tTd(29, 5))
extern char RealUserName[];
if (tTd(29, 5))
- printf("writable(%s)\n", filename);
+ printf("writable(%s, %x)\n", filename, flags);
- if (lstat(filename, &stb) < 0)
+ if ((bitset(SFF_NOSLINK, flags) ? lstat(filename, &stb)
+ : stat(filename, &stb)) < 0)
#else
if (stat(filename, &stb) < 0)
#endif
#else
if (stat(filename, &stb) < 0)
#endif
return FALSE;
*p = '\0';
if (safefile(filename, RealUid, RealGid, RealUserName,
return FALSE;
*p = '\0';
if (safefile(filename, RealUid, RealGid, RealUserName,
- SF_MUSTOWN, S_IWRITE|S_IEXEC) != 0)
+ SFF_MUSTOWN, S_IWRITE|S_IEXEC) != 0)
{
*p = '/';
return FALSE;
{
*p = '/';
return FALSE;
printf("\teu/gid=%d/%d, st_u/gid=%d/%d\n",
euid, egid, stb.st_uid, stb.st_gid);
printf("\teu/gid=%d/%d, st_u/gid=%d/%d\n",
euid, egid, stb.st_uid, stb.st_gid);
- return safefile(filename, euid, egid, uname, SF_NOSLINK, S_IWRITE) == 0;
+ return safefile(filename, euid, egid, uname, flags, S_IWRITE) == 0;
}
\f/*
** INCLUDE -- handle :include: specification.
}
\f/*
** INCLUDE -- handle :include: specification.
gid_t savedgid, gid;
char *uname;
int rval = 0;
gid_t savedgid, gid;
char *uname;
int rval = 0;
- int sfflags = forwarding ? SF_MUSTOWN : 0;
+ int sfflags = forwarding ? SFF_MUSTOWN : SFF_ANYFILE;
char buf[MAXLINE];
if (tTd(27, 2))
char buf[MAXLINE];
if (tTd(27, 2))
-static char sccsid[] = "@(#)savemail.c 8.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)savemail.c 8.22 (Berkeley) %G%";
#endif /* not lint */
# include "sendmail.h"
#endif /* not lint */
# include "sendmail.h"
}
strcpy(buf, "/usr/tmp/dead.letter");
}
strcpy(buf, "/usr/tmp/dead.letter");
+ if (!writable(buf, SFF_NOSLINK))
{
state = ESM_PANIC;
break;
{
state = ESM_PANIC;
break;
-static char sccsid[] = "@(#)util.c 8.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)util.c 8.22 (Berkeley) %G%";
#endif /* not lint */
# include "sendmail.h"
#endif /* not lint */
# include "sendmail.h"
** uname -- user name to compare against (used for group
** sets).
** flags -- modifiers:
** uname -- user name to compare against (used for group
** sets).
** flags -- modifiers:
-** SF_MUSTOWN -- "uid" must own this file.
-** SF_NOSLINK -- file cannot be a symbolic link.
+** SFF_MUSTOWN -- "uid" must own this file.
+** SFF_NOSLINK -- file cannot be a symbolic link.
** mode -- mode bits that must match.
**
** Returns:
** mode -- mode bits that must match.
**
** Returns:
- if ((bitset(SF_NOSLINK, flags) ? lstat(fn, &stbuf)
- : stat(fn, &stbuf)) < 0)
+ if ((bitset(SFF_NOSLINK, flags) ? lstat(fn, &stbuf)
+ : stat(fn, &stbuf)) < 0)
#else
if (stat(fn, &stbuf) < 0)
#endif
#else
if (stat(fn, &stbuf) < 0)
#endif
- if (bitset(SF_NOSLINK, flags) && S_ISLNK(stbuf.st_mode))
+ if (bitset(SFF_NOSLINK, flags) && S_ISLNK(stbuf.st_mode))
{
if (tTd(54, 4))
printf("\t[mode %o]\tEPERM\n");
{
if (tTd(54, 4))
printf("\t[mode %o]\tEPERM\n");
printf("\t[uid %d, stat %o, mode %o] ",
stbuf.st_uid, stbuf.st_mode, mode);
if ((stbuf.st_uid == uid || stbuf.st_uid == 0 ||
printf("\t[uid %d, stat %o, mode %o] ",
stbuf.st_uid, stbuf.st_mode, mode);
if ((stbuf.st_uid == uid || stbuf.st_uid == 0 ||
- !bitset(SF_MUSTOWN, flags)) &&
+ !bitset(SFF_MUSTOWN, flags)) &&
(stbuf.st_mode & mode) == mode)
{
if (tTd(54, 4))
(stbuf.st_mode & mode) == mode)
{
if (tTd(54, 4))