summaryrefslogtreecommitdiff
path: root/gnu/usr.sbin/sendmail/smrsh
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-06-03 17:25:48 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-06-03 17:25:48 +0000
commit516364eba6479ea4a301d76d0a0d0f5304ed990a (patch)
tree1223cc7516ed02f41ff733ffa28e673f664740f3 /gnu/usr.sbin/sendmail/smrsh
parent1708fb9909a4490bf6d68894d8c5862f8c78e121 (diff)
Update to sendmail-8.12.4
Diffstat (limited to 'gnu/usr.sbin/sendmail/smrsh')
-rw-r--r--gnu/usr.sbin/sendmail/smrsh/smrsh.83
-rw-r--r--gnu/usr.sbin/sendmail/smrsh/smrsh.c42
2 files changed, 29 insertions, 16 deletions
diff --git a/gnu/usr.sbin/sendmail/smrsh/smrsh.8 b/gnu/usr.sbin/sendmail/smrsh/smrsh.8
index 0abcdb07e6a..2ce06bca2b0 100644
--- a/gnu/usr.sbin/sendmail/smrsh/smrsh.8
+++ b/gnu/usr.sbin/sendmail/smrsh/smrsh.8
@@ -9,10 +9,9 @@
.\" the sendmail distribution.
.\"
.\"
-.\" $OpenBSD: smrsh.8,v 1.6 2001/09/11 19:02:50 millert Exp $
.\" $Sendmail: smrsh.8,v 8.15 2001/01/24 00:40:47 gshapiro Exp $
.\"
-.Dd January 24, 2001
+.Dd April 25, 2002
.Dt SMRSH 8
.Os
.Sh NAME
diff --git a/gnu/usr.sbin/sendmail/smrsh/smrsh.c b/gnu/usr.sbin/sendmail/smrsh/smrsh.c
index e9170206405..b5e8e6eb079 100644
--- a/gnu/usr.sbin/sendmail/smrsh/smrsh.c
+++ b/gnu/usr.sbin/sendmail/smrsh/smrsh.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
+ * Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers.
* All rights reserved.
* Copyright (c) 1993 Eric P. Allman. All rights reserved.
* Copyright (c) 1993
@@ -20,7 +20,7 @@ SM_IDSTR(copyright,
Copyright (c) 1993\n\
The Regents of the University of California. All rights reserved.\n")
-SM_IDSTR(id, "@(#)$Sendmail: smrsh.c,v 8.55 2001/09/11 04:05:22 gshapiro Exp $")
+SM_IDSTR(id, "@(#)$Sendmail: smrsh.c,v 8.58 2002/05/25 02:41:31 ca Exp $")
/*
** SMRSH -- sendmail restricted shell
@@ -54,6 +54,7 @@ SM_IDSTR(id, "@(#)$Sendmail: smrsh.c,v 8.55 2001/09/11 04:05:22 gshapiro Exp $")
#include <unistd.h>
#include <sm/io.h>
+#include <sm/limits.h>
#include <sm/string.h>
#include <sys/file.h>
#include <string.h>
@@ -126,10 +127,7 @@ addcmd(s, cmd, len)
exit(EX_UNAVAILABLE);
}
if (cmd)
- {
- (void) sm_strlcat(newcmdbuf, CMDDIR, sizeof newcmdbuf);
- (void) sm_strlcat(newcmdbuf, "/", sizeof newcmdbuf);
- }
+ (void) sm_strlcat2(newcmdbuf, CMDDIR, "/", sizeof newcmdbuf);
(void) sm_strlcat(newcmdbuf, s, sizeof newcmdbuf);
}
@@ -145,7 +143,6 @@ main(argc, argv)
int isexec;
int save_errno;
char *newenv[2];
- char cmdbuf[1000];
char pathbuf[1000];
char specialbuf[32];
@@ -157,8 +154,7 @@ main(argc, argv)
# endif /* ! LOG_MAIL */
#endif /* ! DEBUG */
- (void) sm_strlcpy(pathbuf, "PATH=", sizeof pathbuf);
- (void) sm_strlcat(pathbuf, PATH, sizeof pathbuf);
+ (void) sm_strlcpyn(pathbuf, sizeof pathbuf, 2, "PATH=", PATH);
newenv[0] = pathbuf;
newenv[1] = NULL;
@@ -217,7 +213,7 @@ main(argc, argv)
newcmdbuf[0] = '\0';
isexec = false;
- while (*q)
+ while (*q != '\0')
{
/*
** Strip off a leading pathname on the command name. For
@@ -266,6 +262,7 @@ main(argc, argv)
if (strcmp(q, "exec") == 0 && p != NULL)
{
addcmd("exec ", false, strlen("exec "));
+
/* test _next_ arg */
q = ++p;
isexec = true;
@@ -274,16 +271,33 @@ main(argc, argv)
else if (strcmp(q, "exit") == 0 || strcmp(q, "echo") == 0)
{
addcmd(cmd, false, strlen(cmd));
+
/* test following chars */
}
else
{
+ char cmdbuf[MAXPATHLEN];
+
/*
** Check to see if the command name is legal.
*/
- (void) sm_strlcpy(cmdbuf, CMDDIR, sizeof cmdbuf);
- (void) sm_strlcat(cmdbuf, "/", sizeof cmdbuf);
- (void) sm_strlcat(cmdbuf, cmd, sizeof cmdbuf);
+
+ if (sm_strlcpyn(cmdbuf, sizeof cmdbuf, 3, CMDDIR,
+ "/", cmd) >= sizeof cmdbuf)
+ {
+ /* too long */
+ (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
+ "%s: %s not available for sendmail programs (filename too long)\n",
+ prg, cmd);
+ if (p != NULL)
+ *p = ' ';
+#ifndef DEBUG
+ syslog(LOG_CRIT, "uid %d: attempt to use %s (filename too long)",
+ (int) getuid(), cmd);
+#endif /* ! DEBUG */
+ exit(EX_UNAVAILABLE);
+ }
+
#ifdef DEBUG
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT,
"Trying %s\n", cmdbuf);
@@ -345,7 +359,7 @@ main(argc, argv)
(int) getuid(), *r, par);
#endif /* ! DEBUG */
exit(EX_UNAVAILABLE);
- } /* end of while *q */
+ }
if (isexec)
{
(void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT,