summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
fc86871)
close more than 256 files
SCCS-vsn: usr.sbin/sendmail/src/main.c 5.51
SCCS-vsn: usr.sbin/sendmail/src/readcf.c 5.40
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 5.50 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c 5.51 (Berkeley) %G%";
#endif /* not lint */
#define _DEFINE
#endif /* not lint */
#define _DEFINE
bool readconfig = TRUE;
bool queuemode = FALSE; /* process queue requests */
bool nothaw;
bool readconfig = TRUE;
bool queuemode = FALSE; /* process queue requests */
bool nothaw;
static bool reenter = FALSE;
char jbuf[60]; /* holds MyHostName */
extern bool safefile();
static bool reenter = FALSE;
char jbuf[60]; /* holds MyHostName */
extern bool safefile();
i = open("/dev/null", O_RDWR);
while (i >= 0 && i < 2)
i = dup(i);
i = open("/dev/null", O_RDWR);
while (i >= 0 && i < 2)
i = dup(i);
- for (i = getdtablesize(); i > 2; --i)
+ i = getdtablesize();
+
+ /* in 4.4BSD, the table can be huge; impose a reasonable limit */
+ if (i > 256)
+ i = 256;
+ while (--i > 2)
(void) close(i);
errno = 0;
(void) close(i);
errno = 0;
ConfFile = "sendmail.cf";
(void) setgid(getrgid());
(void) setuid(getruid());
ConfFile = "sendmail.cf";
(void) setgid(getrgid());
(void) setuid(getruid());
nothaw = TRUE;
}
else if (strncmp(p, "-bz", 3) == 0)
nothaw = TRUE;
}
else if (strncmp(p, "-bz", 3) == 0)
*/
if (OpMode == MD_FREEZE || readconfig)
*/
if (OpMode == MD_FREEZE || readconfig)
+ readcf(ConfFile, safecf);
if (ConfigLevel > MAXCONFIGLEVEL)
{
if (ConfigLevel > MAXCONFIGLEVEL)
{
-static char sccsid[] = "@(#)readcf.c 5.39 (Berkeley) %G%";
+static char sccsid[] = "@(#)readcf.c 5.40 (Berkeley) %G%";
#endif /* not lint */
# include "sendmail.h"
# include <sys/stat.h>
#endif /* not lint */
# include "sendmail.h"
# include <sys/stat.h>
/*
** READCF -- read control file.
/*
** READCF -- read control file.
**
** Parameters:
** cfname -- control file name.
**
** Parameters:
** cfname -- control file name.
+** safe -- TRUE if this is the system config file;
+** FALSE otherwise.
readcf(cfname)
char *cfname;
readcf(cfname)
char *cfname;
{
FILE *cf;
int ruleset = 0;
{
FILE *cf;
int ruleset = 0;
while (isspace(*++p))
continue;
}
while (isspace(*++p))
continue;
}
- fileclass(buf[1], &buf[2], p);
+ fileclass(buf[1], &buf[2], p, safe);
-fileclass(class, filename, fmt)
+fileclass(class, filename, fmt, safe)
int class;
char *filename;
char *fmt;
int class;
char *filename;
char *fmt;
- if (filename[0] == '|')
- f = popen(filename + 1, "r");
- else
- f = fopen(filename, "r");
+ if (stat(filename, &stbuf) < 0)
+ {
+ syserr("fileclass: cannot stat %s", filename);
+ return;
+ }
+ if (!S_ISREG(stbuf.st_mode))
+ {
+ syserr("fileclass: %s not a regular file", filename);
+ return;
+ }
+ if (!safe && access(filename, R_OK) < 0)
+ {
+ syserr("fileclass: access denied on %s", filename);
+ return;
+ }
+ f = fopen(filename, "r");
- syserr("cannot open %s", filename);
+ syserr("fileclass: cannot open %s", filename);
- if (filename[0] == '|')
- (void) pclose(f);
- else
- (void) fclose(f);
}
\f/*
** MAKEMAILER -- define a new mailer.
}
\f/*
** MAKEMAILER -- define a new mailer.