Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/gnu/dist/sendmail/smrsh more strict checking on command invo...
details: https://anonhg.NetBSD.org/src/rev/83d6c52954ff
branches: trunk
changeset: 537604:83d6c52954ff
user: itojun <itojun%NetBSD.org@localhost>
date: Thu Oct 03 03:31:46 2002 +0000
description:
more strict checking on command invocation.
http://www.sendmail.org/smrsh.adv.txt, NetBSD PR 18516
diffstat:
gnu/dist/sendmail/smrsh/smrsh.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diffs (59 lines):
diff -r b7da32c5c0b8 -r 83d6c52954ff gnu/dist/sendmail/smrsh/smrsh.c
--- a/gnu/dist/sendmail/smrsh/smrsh.c Thu Oct 03 03:02:11 2002 +0000
+++ b/gnu/dist/sendmail/smrsh/smrsh.c Thu Oct 03 03:31:46 2002 +0000
@@ -57,6 +57,8 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/file.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
@@ -154,6 +156,7 @@
char cmdbuf[1000];
char pathbuf[1000];
char specialbuf[32];
+ struct stat st;
#ifndef DEBUG
# ifndef LOG_MAIL
@@ -291,6 +294,38 @@
#ifdef DEBUG
printf("Trying %s\n", cmdbuf);
#endif /* DEBUG */
+ if (stat(cmdbuf, &st) < 0)
+ {
+ /* can't stat it */
+ fprintf(stderr,
+ "%s: %s not available for sendmail programs (stat failed)\n",
+ prg, cmd);
+ if (p != NULL)
+ *p = ' ';
+#ifndef DEBUG
+ syslog(LOG_CRIT, "uid %d: attempt to use %s (stat failed)",
+ (int) getuid(), cmd);
+#endif /* ! DEBUG */
+ exit(EX_UNAVAILABLE);
+ }
+ if (!S_ISREG(st.st_mode)
+#ifdef S_ISLNK
+ && !S_ISLNK(st.st_mode)
+#endif /* S_ISLNK */
+ )
+ {
+ /* can't stat it */
+ fprintf(stderr,
+ "%s: %s not available for sendmail programs (not a file)\n",
+ prg, cmd);
+ if (p != NULL)
+ *p = ' ';
+#ifndef DEBUG
+ syslog(LOG_CRIT, "uid %d: attempt to use %s (not a file)",
+ (int) getuid(), cmd);
+#endif /* ! DEBUG */
+ exit(EX_UNAVAILABLE);
+ }
if (access(cmdbuf, X_OK) < 0)
{
/* oops.... crack attack possiblity */
Home |
Main Index |
Thread Index |
Old Index