diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2006-06-16 22:40:36 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2006-06-16 22:40:36 +0000 |
commit | b5dae7e5c30905996ad240f749cfa8d54cee3ad9 (patch) | |
tree | 139cec4bc7a34545bae2e43728685c515ea7da7c /libexec/tftpd | |
parent | 8f0f853ccec6b7c9c8e23a6ff839e1448a5a1fcf (diff) |
From Markus Glockner <markus@nazgul.ch>, adds logging of refusals
and debug level logging of transfers to tftpd. all the work done by
markus, I only tested and nitpicked.
ok mbalmer@
Diffstat (limited to 'libexec/tftpd')
-rw-r--r-- | libexec/tftpd/tftpd.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index 4c08a3012d2..d6cd982ed33 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftpd.c,v 1.43 2006/04/25 16:14:27 deraadt Exp $ */ +/* $OpenBSD: tftpd.c,v 1.44 2006/06/16 22:40:35 beck Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -37,7 +37,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)tftpd.c 5.13 (Berkeley) 2/26/91";*/ -static char rcsid[] = "$OpenBSD: tftpd.c,v 1.43 2006/04/25 16:14:27 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: tftpd.c,v 1.44 2006/06/16 22:40:35 beck Exp $"; #endif /* not lint */ /* @@ -52,6 +52,7 @@ static char rcsid[] = "$OpenBSD: tftpd.c,v 1.43 2006/04/25 16:14:27 deraadt Exp #include <sys/uio.h> #include <unistd.h> #include <fcntl.h> +#include <vis.h> #include <sys/socket.h> #include <netinet/in.h> @@ -376,7 +377,7 @@ tftp(struct tftphdr *tp, int size) int i, first = 1, has_options = 0, ecode; struct formats *pf; char *filename, *mode = NULL, *option, *ccp; - char fnbuf[MAXPATHLEN]; + char fnbuf[MAXPATHLEN], nicebuf[MAXPATHLEN]; cp = tp->th_stuff; again: @@ -449,17 +450,23 @@ option_fail: options[OPT_TIMEOUT].o_request = NULL; } + (void) strnvis(nicebuf, filename, MAXPATHLEN, VIS_SAFE|VIS_OCTAL); ecode = (*pf->f_validate)(filename, tp->th_opcode); if (has_options) oack(); if (ecode) { + syslog(LOG_INFO, "denied %s access to '%s'", + tp->th_opcode == WRQ ? "write" : "read", nicebuf); nak(ecode); exit(1); } - if (tp->th_opcode == WRQ) + if (tp->th_opcode == WRQ) { + syslog(LOG_DEBUG, "receiving file '%s'", nicebuf); (*pf->f_recv)(pf); - else + } else { + syslog(LOG_DEBUG, "sending file '%s'", nicebuf); (*pf->f_send)(pf); + } exit(0); } |