diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-09-11 19:02:52 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-09-11 19:02:52 +0000 |
commit | b9658e618d8e5a4f53d0291f13222e5e19dd695f (patch) | |
tree | 347b055971d930905e6c510a18587adc19a2f124 /gnu/usr.sbin/sendmail/smrsh | |
parent | 03eaf40ad95c4f4c5613308db2dfe2f64ee709b0 (diff) |
merge in sendmail 8.12.0 with BSD Makefiles and mdoc man pages
Diffstat (limited to 'gnu/usr.sbin/sendmail/smrsh')
-rw-r--r-- | gnu/usr.sbin/sendmail/smrsh/Makefile | 6 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/smrsh/README | 4 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/smrsh/smrsh.8 | 6 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/smrsh/smrsh.c | 141 |
4 files changed, 80 insertions, 77 deletions
diff --git a/gnu/usr.sbin/sendmail/smrsh/Makefile b/gnu/usr.sbin/sendmail/smrsh/Makefile index 0a18d699c98..fa19225f9de 100644 --- a/gnu/usr.sbin/sendmail/smrsh/Makefile +++ b/gnu/usr.sbin/sendmail/smrsh/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.5 2001/09/09 16:41:33 deraadt Exp $ +# $OpenBSD: Makefile,v 1.6 2001/09/11 19:02:50 millert Exp $ PROG= smrsh MAN= smrsh.8 ENVDEF= -DNOT_SENDMAIL -DCMDDIR=\"/usr/libexec/sm.bin\" -WANT_LIBSMUTIL=1 +WANT_LIBSM=1 -BINDIR?= /usr/libexec +.include "../../../../libexec/Makefile.inc" .include <bsd.prog.mk> diff --git a/gnu/usr.sbin/sendmail/smrsh/README b/gnu/usr.sbin/sendmail/smrsh/README index 158e7f34c52..687360aad38 100644 --- a/gnu/usr.sbin/sendmail/smrsh/README +++ b/gnu/usr.sbin/sendmail/smrsh/README @@ -75,7 +75,7 @@ You should NOT include interpreter programs such as sh(1), csh(1), perl(1), uudecode(1) or the stream editor sed(1) in your list of acceptable commands. -If your platform doesn't have a default CMDDIR setting, you will +If your platform doesn't have a default SMRSH_CMDDIR setting, you will next need to create the directory /usr/adm/sm.bin and populate it with the programs that your site feels are allowable for sendmail to execute. This directory is explicitly specified in the source @@ -153,4 +153,4 @@ a typical system follows: host.domain# /usr/sbin/sendmail -bd -q30m -$Revision: 1.3 $, Last updated $Date: 2001/01/15 21:09:11 $ +$Revision: 1.4 $, Last updated $Date: 2001/09/11 19:02:50 $ diff --git a/gnu/usr.sbin/sendmail/smrsh/smrsh.8 b/gnu/usr.sbin/sendmail/smrsh/smrsh.8 index 8e51659adad..0abcdb07e6a 100644 --- a/gnu/usr.sbin/sendmail/smrsh/smrsh.8 +++ b/gnu/usr.sbin/sendmail/smrsh/smrsh.8 @@ -9,10 +9,10 @@ .\" the sendmail distribution. .\" .\" -.\" $OpenBSD: smrsh.8,v 1.5 2001/01/17 05:26:51 millert Exp $ -.\" $Sendmail: smrsh.8,v 8.11.16.2 2000/12/15 19:50:46 gshapiro Exp $ +.\" $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 December 15, 2000 +.Dd January 24, 2001 .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 fac4dfc7361..8df557a4319 100644 --- a/gnu/usr.sbin/sendmail/smrsh/smrsh.c +++ b/gnu/usr.sbin/sendmail/smrsh/smrsh.c @@ -11,18 +11,16 @@ * */ -#ifndef lint -static char copyright[] = +#include <sm/gen.h> + +SM_IDSTR(copyright, "@(#) Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.\n\ All rights reserved.\n\ Copyright (c) 1993 Eric P. Allman. All rights reserved.\n\ Copyright (c) 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* ! lint */ + The Regents of the University of California. All rights reserved.\n") -#ifndef lint -static char id[] = "@(#)$Sendmail: smrsh.c,v 8.31.4.9 2001/04/24 04:11:51 ca Exp $"; -#endif /* ! lint */ +SM_IDSTR(id, "@(#)$Sendmail: smrsh.c,v 8.53 2001/08/31 18:36:04 gshapiro Exp $") /* ** SMRSH -- sendmail restricted shell @@ -55,7 +53,8 @@ static char id[] = "@(#)$Sendmail: smrsh.c,v 8.31.4.9 2001/04/24 04:11:51 ca Exp */ #include <unistd.h> -#include <stdio.h> +#include <sm/io.h> +#include <sm/string.h> #include <sys/file.h> #include <string.h> #include <ctype.h> @@ -67,18 +66,16 @@ static char id[] = "@(#)$Sendmail: smrsh.c,v 8.31.4.9 2001/04/24 04:11:51 ca Exp #include <syslog.h> #include <stdlib.h> -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 -#endif /* ! TRUE */ +#include <sm/conf.h> +#include <sm/errstring.h> /* directory in which all commands must reside */ #ifndef CMDDIR -# if defined(HPUX10) || defined(HPUX11) || SOLARIS >= 20800 -# define CMDDIR "/var/adm/sm.bin" -# else /* HPUX10 || HPUX11 || SOLARIS >= 20800 */ +# ifdef SMRSH_CMDDIR +# define CMDDIR SMRSH_CMDDIR +# else /* SMRSH_CMDDIR */ # define CMDDIR "/usr/adm/sm.bin" -# endif /* HPUX10 || HPUX11 || SOLARIS >= 20800 */ +# endif /* SMRSH_CMDDIR */ #endif /* ! CMDDIR */ /* characters disallowed in the shell "-c" argument */ @@ -86,16 +83,13 @@ static char id[] = "@(#)$Sendmail: smrsh.c,v 8.31.4.9 2001/04/24 04:11:51 ca Exp /* default search path */ #ifndef PATH -# define PATH "/bin:/usr/bin:/usr/ucb" +# ifdef SMRSH_PATH +# define PATH SMRSH_PATH +# else /* SMRSH_PATH */ +# define PATH "/bin:/usr/bin:/usr/ucb" +# endif /* SMRSH_PATH */ #endif /* ! PATH */ -#ifndef __P -# include "sendmail/cdefs.h" -#endif /* ! __P */ - -extern size_t strlcpy __P((char *, const char *, size_t)); -extern size_t strlcat __P((char *, const char *, size_t)); - char newcmdbuf[1000]; char *prg, *par; @@ -115,8 +109,8 @@ char *prg, *par; void addcmd(s, cmd, len) char *s; - int cmd; - int len; + bool cmd; + size_t len; { if (s == NULL || *s == '\0') return; @@ -124,7 +118,8 @@ addcmd(s, cmd, len) if (sizeof newcmdbuf - strlen(newcmdbuf) <= len + (cmd ? (strlen(CMDDIR) + 1) : 0)) { - fprintf(stderr, "%s: command too long: %s\n", prg, par); + (void)sm_io_fprintf(smioerr, SM_TIME_DEFAULT, + "%s: command too long: %s\n", prg, par); #ifndef DEBUG syslog(LOG_WARNING, "command too long: %.40s", par); #endif /* ! DEBUG */ @@ -132,10 +127,10 @@ addcmd(s, cmd, len) } if (cmd) { - (void) strlcat(newcmdbuf, CMDDIR, sizeof newcmdbuf); - (void) strlcat(newcmdbuf, "/", sizeof newcmdbuf); + (void) sm_strlcat(newcmdbuf, CMDDIR, sizeof newcmdbuf); + (void) sm_strlcat(newcmdbuf, "/", sizeof newcmdbuf); } - (void) strlcat(newcmdbuf, s, sizeof newcmdbuf); + (void) sm_strlcat(newcmdbuf, s, sizeof newcmdbuf); } int @@ -147,7 +142,6 @@ main(argc, argv) register char *q; register char *r; register char *cmd; - int i; int isexec; int save_errno; char *newenv[2]; @@ -163,8 +157,8 @@ main(argc, argv) # endif /* ! LOG_MAIL */ #endif /* ! DEBUG */ - (void) strlcpy(pathbuf, "PATH=", sizeof pathbuf); - (void) strlcat(pathbuf, PATH, sizeof pathbuf); + (void) sm_strlcpy(pathbuf, "PATH=", sizeof pathbuf); + (void) sm_strlcat(pathbuf, PATH, sizeof pathbuf); newenv[0] = pathbuf; newenv[1] = NULL; @@ -176,7 +170,8 @@ main(argc, argv) if (argc != 3 || strcmp(argv[1], "-c") != 0) { - fprintf(stderr, "Usage: %s -c command\n", prg); + (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, + "Usage: %s -c command\n", prg); #ifndef DEBUG syslog(LOG_ERR, "usage"); #endif /* ! DEBUG */ @@ -199,19 +194,19 @@ main(argc, argv) #endif /* ! DEBUG */ exit(EX_UNAVAILABLE); } - (void) strlcpy(specialbuf, SPECIALS, sizeof specialbuf); + (void) sm_strlcpy(specialbuf, SPECIALS, sizeof specialbuf); for (p = specialbuf; *p != '\0'; p++) *p |= '\200'; - (void) strlcat(specialbuf, SPECIALS, sizeof specialbuf); + (void) sm_strlcat(specialbuf, SPECIALS, sizeof specialbuf); /* ** Do a quick sanity check on command line length. */ - i = strlen(par); - if (i > (sizeof newcmdbuf - sizeof CMDDIR - 2)) + if (strlen(par) > (sizeof newcmdbuf - sizeof CMDDIR - 2)) { - fprintf(stderr, "%s: command too long: %s\n", prg, par); + (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, + "%s: command too long: %s\n", prg, par); #ifndef DEBUG syslog(LOG_WARNING, "command too long: %.40s", par); #endif /* ! DEBUG */ @@ -220,7 +215,7 @@ main(argc, argv) q = par; newcmdbuf[0] = '\0'; - isexec = FALSE; + isexec = false; while (*q) { @@ -236,10 +231,11 @@ main(argc, argv) { if (isexec) { - fprintf(stderr, "%s: missing command to exec\n", - prg); + (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, + "%s: missing command to exec\n", + prg); #ifndef DEBUG - syslog(LOG_CRIT, "uid %d: missing command to exec", getuid()); + syslog(LOG_CRIT, "uid %d: missing command to exec", (int) getuid()); #endif /* ! DEBUG */ exit(EX_UNAVAILABLE); } @@ -269,15 +265,15 @@ main(argc, argv) /* allow a few shell builtins */ if (strcmp(q, "exec") == 0 && p != NULL) { - addcmd("exec ", FALSE, strlen("exec ")); + addcmd("exec ", false, strlen("exec ")); /* test _next_ arg */ q = ++p; - isexec = TRUE; + isexec = true; continue; } else if (strcmp(q, "exit") == 0 || strcmp(q, "echo") == 0) { - addcmd(cmd, FALSE, strlen(cmd)); + addcmd(cmd, false, strlen(cmd)); /* test following chars */ } else @@ -285,23 +281,24 @@ main(argc, argv) /* ** Check to see if the command name is legal. */ - (void) strlcpy(cmdbuf, CMDDIR, sizeof cmdbuf); - (void) strlcat(cmdbuf, "/", sizeof cmdbuf); - (void) strlcat(cmdbuf, cmd, sizeof cmdbuf); + (void) sm_strlcpy(cmdbuf, CMDDIR, sizeof cmdbuf); + (void) sm_strlcat(cmdbuf, "/", sizeof cmdbuf); + (void) sm_strlcat(cmdbuf, cmd, sizeof cmdbuf); #ifdef DEBUG - printf("Trying %s\n", cmdbuf); + (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, + "Trying %s\n", cmdbuf); #endif /* DEBUG */ if (access(cmdbuf, X_OK) < 0) { /* oops.... crack attack possiblity */ - fprintf(stderr, - "%s: %s not available for sendmail programs\n", - prg, cmd); + (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, + "%s: %s not available for sendmail programs\n", + prg, cmd); if (p != NULL) *p = ' '; #ifndef DEBUG syslog(LOG_CRIT, "uid %d: attempt to use %s", - getuid(), cmd); + (int) getuid(), cmd); #endif /* ! DEBUG */ exit(EX_UNAVAILABLE); } @@ -310,9 +307,9 @@ main(argc, argv) ** Create the actual shell input. */ - addcmd(cmd, TRUE, strlen(cmd)); + addcmd(cmd, true, strlen(cmd)); } - isexec = FALSE; + isexec = false; if (p != NULL) *p = ' '; @@ -320,13 +317,15 @@ main(argc, argv) break; r = strpbrk(p, specialbuf); - if (r == NULL) { - addcmd(p, FALSE, strlen(p)); + if (r == NULL) + { + addcmd(p, false, strlen(p)); break; } #if ALLOWSEMI - if (*r == ';') { - addcmd(p, FALSE, r - p + 1); + if (*r == ';') + { + addcmd(p, false, r - p + 1); q = r + 1; continue; } @@ -334,30 +333,34 @@ main(argc, argv) if ((*r == '&' && *(r + 1) == '&') || (*r == '|' && *(r + 1) == '|')) { - addcmd(p, FALSE, r - p + 2); + addcmd(p, false, r - p + 2); q = r + 2; continue; } - fprintf(stderr, "%s: cannot use %c in command\n", prg, *r); + (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, + "%s: cannot use %c in command\n", prg, *r); #ifndef DEBUG syslog(LOG_CRIT, "uid %d: attempt to use %c in command: %s", - getuid(), *r, par); + (int) getuid(), *r, par); #endif /* ! DEBUG */ exit(EX_UNAVAILABLE); } /* end of while *q */ if (isexec) { - fprintf(stderr, "%s: missing command to exec\n", prg); + (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, + "%s: missing command to exec\n", prg); #ifndef DEBUG - syslog(LOG_CRIT, "uid %d: missing command to exec", getuid()); + syslog(LOG_CRIT, "uid %d: missing command to exec", + (int) getuid()); #endif /* ! DEBUG */ exit(EX_UNAVAILABLE); } /* make sure we created something */ if (newcmdbuf[0] == '\0') { - fprintf(stderr, "Usage: %s -c command\n", prg); + (void) sm_io_fprintf(smioerr, SM_TIME_DEFAULT, + "Usage: %s -c command\n", prg); #ifndef DEBUG syslog(LOG_ERR, "usage"); #endif /* ! DEBUG */ @@ -369,15 +372,15 @@ main(argc, argv) */ #ifdef DEBUG - printf("%s\n", newcmdbuf); + (void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "%s\n", newcmdbuf); #endif /* DEBUG */ (void) execle("/bin/sh", "/bin/sh", "-c", newcmdbuf, (char *)NULL, newenv); save_errno = errno; #ifndef DEBUG - syslog(LOG_CRIT, "Cannot exec /bin/sh: %m"); + syslog(LOG_CRIT, "Cannot exec /bin/sh: %s", sm_errstring(errno)); #endif /* ! DEBUG */ errno = save_errno; - perror("/bin/sh"); + sm_perror("/bin/sh"); exit(EX_OSFILE); /* NOTREACHED */ return EX_OSFILE; |