summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-12-03 07:19:58 +0000
committercharnier <charnier@FreeBSD.org>1997-12-03 07:19:58 +0000
commit82c7f870ed2d82b91f3d99026d2c52e9ebb097d5 (patch)
treef22adbd827674979ed9ed3b4bc9eb1d1b4b5469f /libexec
parent4fb0a742b1c5240b2cad42e221aa28ac18f8afa2 (diff)
downloadFreeBSD-src-82c7f870ed2d82b91f3d99026d2c52e9ebb097d5.zip
FreeBSD-src-82c7f870ed2d82b91f3d99026d2c52e9ebb097d5.tar.gz
Use full path in synopsis. Syslog will add trailing \n.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/tftpd/tftpd.834
-rw-r--r--libexec/tftpd/tftpd.c32
2 files changed, 39 insertions, 27 deletions
diff --git a/libexec/tftpd/tftpd.8 b/libexec/tftpd/tftpd.8
index 77b447f..e981239 100644
--- a/libexec/tftpd/tftpd.8
+++ b/libexec/tftpd/tftpd.8
@@ -39,7 +39,7 @@
.Nd
Internet Trivial File Transfer Protocol server
.Sh SYNOPSIS
-.Nm tftpd
+.Nm /usr/libexec/tftpd
.Op Fl l
.Op Fl n
.Op Fl s Ar directory
@@ -65,7 +65,7 @@ The use of
.Xr tftp 1
does not require an account or password on the remote system.
Due to the lack of authentication information,
-.Nm tftpd
+.Nm
will allow only publicly readable files to be
accessed.
Files containing the string ``/\|\fB.\|.\fP\|/'' or starting with
@@ -80,7 +80,7 @@ should be considered before enabling tftp service.
The server should have the user ID with the lowest possible privilege.
.Pp
Access to files may be restricted by invoking
-.Nm tftpd
+.Nm
with a list of directories by including up to 20 pathnames
as server program arguments in
.Pa /etc/inetd.conf .
@@ -90,30 +90,40 @@ The given directories are also treated as a search path for
relative filename requests.
.Pp
The chroot option provides additional security by restricting access
-of tftpd to only a chroot'd file system. This is useful when moving
+of
+.Nm
+to only a chroot'd file system. This is useful when moving
from an OS that supported
-.Nm -s
+.Fl s
as a boot server. Because chroot is restricted to root, you must run
-tftpd as root. However, if you chroot, then
-.Nm tftpd
+.Nm
+as root. However, if you chroot, then
+.Nm
will set its user id to nobody.
.Pp
The options are:
.Bl -tag -width Ds
.It Fl l
-Logs all requests using
+Log all requests using
.Xr syslog 3 .
.It Fl n
-Suppresses negative acknowledgement of requests for nonexistent
+Suppress negative acknowledgement of requests for nonexistent
relative filenames.
.It Fl s Ar directory
-Causes tftpd to chroot to
+Cause
+.Nm
+to chroot to
.Pa directory
before accepting commands. In addition, the user id is set to
nobody.
.Pp
-If you are not running -s, no user id change will be
-attempted. You should not run tftpd as root unless you are using -s.
+If you are not running
+.Fl s ,
+no user id change will be
+attempted. You should not run
+.Nm
+as root unless you are using
+.Fl s .
.El
.Sh SEE ALSO
.Xr tftp 1 ,
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c
index 199ec2b..657d305 100644
--- a/libexec/tftpd/tftpd.c
+++ b/libexec/tftpd/tftpd.c
@@ -29,18 +29,20 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $Id: tftpd.c,v 1.8 1997/03/24 06:04:08 imp Exp $
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)tftpd.c 8.1 (Berkeley) 6/4/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
/*
@@ -64,6 +66,7 @@ static char sccsid[] = "@(#)tftpd.c 8.1 (Berkeley) 6/4/93";
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
+#include <pwd.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
@@ -71,7 +74,6 @@ static char sccsid[] = "@(#)tftpd.c 8.1 (Berkeley) 6/4/93";
#include <string.h>
#include <syslog.h>
#include <unistd.h>
-#include <pwd.h>
#include "tftpsubs.h"
@@ -156,14 +158,14 @@ main(argc, argv)
on = 1;
if (ioctl(0, FIONBIO, &on) < 0) {
- syslog(LOG_ERR, "ioctl(FIONBIO): %m\n");
+ syslog(LOG_ERR, "ioctl(FIONBIO): %m");
exit(1);
}
fromlen = sizeof (from);
n = recvfrom(0, buf, sizeof (buf), 0,
(struct sockaddr *)&from, &fromlen);
if (n < 0) {
- syslog(LOG_ERR, "recvfrom: %m\n");
+ syslog(LOG_ERR, "recvfrom: %m");
exit(1);
}
/*
@@ -210,7 +212,7 @@ main(argc, argv)
}
}
if (pid < 0) {
- syslog(LOG_ERR, "fork: %m\n");
+ syslog(LOG_ERR, "fork: %m");
exit(1);
} else if (pid != 0) {
exit(0);
@@ -242,17 +244,17 @@ main(argc, argv)
close(1);
peer = socket(AF_INET, SOCK_DGRAM, 0);
if (peer < 0) {
- syslog(LOG_ERR, "socket: %m\n");
+ syslog(LOG_ERR, "socket: %m");
exit(1);
}
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
if (bind(peer, (struct sockaddr *)&sin, sizeof (sin)) < 0) {
- syslog(LOG_ERR, "bind: %m\n");
+ syslog(LOG_ERR, "bind: %m");
exit(1);
}
if (connect(peer, (struct sockaddr *)&from, sizeof(from)) < 0) {
- syslog(LOG_ERR, "connect: %m\n");
+ syslog(LOG_ERR, "connect: %m");
exit(1);
}
tp = (struct tftphdr *)buf;
@@ -488,7 +490,7 @@ sendfile(pf)
send_data:
if (send(peer, dp, size + 4, 0) != size + 4) {
- syslog(LOG_ERR, "tftpd: write: %m\n");
+ syslog(LOG_ERR, "write: %m");
goto abort;
}
read_ahead(file, pf->f_convert);
@@ -497,7 +499,7 @@ send_data:
n = recv(peer, ackbuf, sizeof (ackbuf), 0);
alarm(0);
if (n < 0) {
- syslog(LOG_ERR, "tftpd: read: %m\n");
+ syslog(LOG_ERR, "read: %m");
goto abort;
}
ap->th_opcode = ntohs((u_short)ap->th_opcode);
@@ -553,7 +555,7 @@ recvfile(pf)
(void) setjmp(timeoutbuf);
send_ack:
if (send(peer, ackbuf, 4, 0) != 4) {
- syslog(LOG_ERR, "tftpd: write: %m\n");
+ syslog(LOG_ERR, "write: %m");
goto abort;
}
write_behind(file, pf->f_convert);
@@ -562,7 +564,7 @@ send_ack:
n = recv(peer, dp, PKTSIZE, 0);
alarm(0);
if (n < 0) { /* really? */
- syslog(LOG_ERR, "tftpd: read: %m\n");
+ syslog(LOG_ERR, "read: %m");
goto abort;
}
dp->th_opcode = ntohs((u_short)dp->th_opcode);
@@ -666,7 +668,7 @@ nak(error)
tp->th_msg[length] = '\0';
length += 5;
if (send(peer, buf, length, 0) != length)
- syslog(LOG_ERR, "nak: %m\n");
+ syslog(LOG_ERR, "nak: %m");
}
static char *
OpenPOWER on IntegriCloud