From b5dae7e5c30905996ad240f749cfa8d54cee3ad9 Mon Sep 17 00:00:00 2001 From: Bob Beck Date: Fri, 16 Jun 2006 22:40:36 +0000 Subject: From Markus Glockner , 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@ --- libexec/tftpd/tftpd.c | 17 ++++++++++++----- 1 file 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 #include #include +#include #include #include @@ -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); } -- cgit v1.2.3