summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/smrsh
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2002-06-11 21:12:04 +0000
committergshapiro <gshapiro@FreeBSD.org>2002-06-11 21:12:04 +0000
commitfaacdfb2c2946459651449cedf08a1bc29aee731 (patch)
tree546131e3b171104de8ab1498603b992a6971ec6a /contrib/sendmail/smrsh
parente226f8e879ed5a8d2f5cc433067b698e07dce0b6 (diff)
downloadFreeBSD-src-faacdfb2c2946459651449cedf08a1bc29aee731.zip
FreeBSD-src-faacdfb2c2946459651449cedf08a1bc29aee731.tar.gz
Import sendmail 8.12.4
Diffstat (limited to 'contrib/sendmail/smrsh')
-rw-r--r--contrib/sendmail/smrsh/Makefile2
-rw-r--r--contrib/sendmail/smrsh/README2
-rw-r--r--contrib/sendmail/smrsh/smrsh.86
-rw-r--r--contrib/sendmail/smrsh/smrsh.c42
4 files changed, 33 insertions, 19 deletions
diff --git a/contrib/sendmail/smrsh/Makefile b/contrib/sendmail/smrsh/Makefile
index 045394d..a9c4af7 100644
--- a/contrib/sendmail/smrsh/Makefile
+++ b/contrib/sendmail/smrsh/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.1.1.1 2000/08/12 21:55:31 gshapiro Exp $
+# $Id: Makefile,v 8.5 1999/09/23 22:36:43 ca Exp $
SHELL= /bin/sh
BUILD= ./Build
diff --git a/contrib/sendmail/smrsh/README b/contrib/sendmail/smrsh/README
index 989b0c8..7e22f86 100644
--- a/contrib/sendmail/smrsh/README
+++ b/contrib/sendmail/smrsh/README
@@ -153,4 +153,4 @@ a typical system follows:
host.domain# /usr/sbin/sendmail -bd -q30m
-$Revision: 1.1.1.5 $, Last updated $Date: 2002/02/17 21:56:43 $
+$Revision: 8.8 $, Last updated $Date: 2001/01/24 00:05:58 $
diff --git a/contrib/sendmail/smrsh/smrsh.8 b/contrib/sendmail/smrsh/smrsh.8
index 67fed55..1f3c0a2 100644
--- a/contrib/sendmail/smrsh/smrsh.8
+++ b/contrib/sendmail/smrsh/smrsh.8
@@ -9,9 +9,9 @@
.\" the sendmail distribution.
.\"
.\"
-.\" $Id: smrsh.8,v 1.1.1.5 2002/02/17 21:56:43 gshapiro Exp $
+.\" $Id: smrsh.8,v 8.16 2002/04/25 13:33:40 ca Exp $
.\"
-.TH SMRSH 8 "$Date: 2002/02/17 21:56:43 $"
+.TH SMRSH 8 "$Date: 2002/04/25 13:33:40 $"
.SH NAME
smrsh \- restricted shell for sendmail
.SH SYNOPSIS
@@ -79,7 +79,7 @@ Compilation should be trivial on most systems.
You may need to use \-DSMRSH_PATH=\e"\fIpath\fP\e"
to adjust the default search path
(defaults to ``/bin:/usr/bin:/usr/ucb'')
-and/or \-DSMRSH_CMDBIN=\e"\fIdir\fP\e"
+and/or \-DSMRSH_CMDDIR=\e"\fIdir\fP\e"
to change the default program directory
(defaults to ``/usr/adm/sm.bin'').
.SH FILES
diff --git a/contrib/sendmail/smrsh/smrsh.c b/contrib/sendmail/smrsh/smrsh.c
index c4119f1..843f68b 100644
--- a/contrib/sendmail/smrsh/smrsh.c
+++ b/contrib/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, "@(#)$Id: smrsh.c,v 1.1.1.8 2002/02/17 21:56:43 gshapiro Exp $")
+SM_IDSTR(id, "@(#)$Id: smrsh.c,v 8.58 2002/05/25 02:41:31 ca Exp $")
/*
** SMRSH -- sendmail restricted shell
@@ -54,6 +54,7 @@ SM_IDSTR(id, "@(#)$Id: smrsh.c,v 1.1.1.8 2002/02/17 21:56:43 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,
OpenPOWER on IntegriCloud