aboutsummaryrefslogtreecommitdiff
path: root/network
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2022-08-20 11:56:04 -0400
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2022-08-27 22:50:40 +0700
commit7de070015bbb6200cb7de3994bd1ca1fd9a5652c (patch)
tree4c2ba4177bae9f8932bb4460776be7f72007bd56 /network
parentd04918508bb9fe72651140dc4d2def880733501f (diff)
network/tnfsd: Remove broken TCP support.
Signed-off-by: B. Watson <urchlay@slackware.uk> Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network')
-rw-r--r--network/tnfsd/README5
-rw-r--r--network/tnfsd/remove_broken_tcp_support.diff167
-rw-r--r--network/tnfsd/slack-desc4
-rw-r--r--network/tnfsd/tnfsd.16
-rw-r--r--network/tnfsd/tnfsd.SlackBuild45
-rw-r--r--network/tnfsd/tnfsd.rst4
6 files changed, 213 insertions, 18 deletions
diff --git a/network/tnfsd/README b/network/tnfsd/README
index f77ceb3b271a..1bbf96428333 100644
--- a/network/tnfsd/README
+++ b/network/tnfsd/README
@@ -29,9 +29,8 @@ back in, to join the new group. Once this is done, the user can
copy files to /var/tnfs (or ~tnfs) and they will be visible to TNFS
clients.
-TNFS uses port 16384, UDP (for most 8-bit clients) and TCP (for the
-Linux client), so make sure you allow incoming traffic if you have
-firewall rules.
+TNFS uses UDP port 16384, so make sure you allow incoming traffic if
+you have firewall rules.
This package includes the server and an init script for running
tnfsd as a system daemon. To start tnfsd at boot, first edit
diff --git a/network/tnfsd/remove_broken_tcp_support.diff b/network/tnfsd/remove_broken_tcp_support.diff
new file mode 100644
index 000000000000..b87483207938
--- /dev/null
+++ b/network/tnfsd/remove_broken_tcp_support.diff
@@ -0,0 +1,167 @@
+diff -Naur spectranet-TNFSD-2020-10-19/tnfs/tnfsd/config.h spectranet-TNFSD-2020-10-19.patched/tnfs/tnfsd/config.h
+--- spectranet-TNFSD-2020-10-19/tnfs/tnfsd/config.h 2020-09-23 14:06:09.000000000 -0400
++++ spectranet-TNFSD-2020-10-19.patched/tnfs/tnfsd/config.h 2022-08-18 17:20:04.008064003 -0400
+@@ -28,7 +28,6 @@
+ #define MAX_DHND_PER_CONN 8 /* max open directories per client */
+ #define MAX_CLIENTS 256 /* maximum number of UDP clients */
+ #define MAX_CLIENTS_PER_IP 8 /* maximum number of UDP clients from single IP */
+-#define MAX_TCP_CONN 256 /* Maximum number of TCP clients */
+ #define TNFS_HEADERSZ 4 /* minimum header size */
+ #define TNFS_MAX_PAYLOAD (MAXMSGSZ - TNFS_HEADERSZ - 1) /* Maximum usuable payload in a UDP datagram (-1 for status byte) */
+ #define MAX_TNFSPATH 256 /* maximum path length */
+diff -Naur spectranet-TNFSD-2020-10-19/tnfs/tnfsd/datagram.c spectranet-TNFSD-2020-10-19.patched/tnfs/tnfsd/datagram.c
+--- spectranet-TNFSD-2020-10-19/tnfs/tnfsd/datagram.c 2020-09-23 14:06:09.000000000 -0400
++++ spectranet-TNFSD-2020-10-19.patched/tnfs/tnfsd/datagram.c 2022-08-18 17:19:22.440374999 -0400
+@@ -50,7 +50,6 @@
+ #include "tnfs_file.h"
+
+ int sockfd; /* UDP global socket file descriptor */
+-int tcplistenfd; /* TCP listening socket file descriptor */
+
+ tnfs_cmdfunc dircmd[NUM_DIRCMDS] =
+ {&tnfs_opendir, &tnfs_readdir, &tnfs_closedir,
+@@ -140,24 +139,6 @@
+
+ if (bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
+ die("Unable to bind");
+-
+- /* Create the TCP socket */
+- tcplistenfd = socket(AF_INET, SOCK_STREAM, 0);
+- if (tcplistenfd < 0)
+- {
+- die("Unable to create TCP socket");
+- }
+-
+- memset(&servaddr, 0, sizeof(servaddr));
+- servaddr.sin_family = AF_INET;
+- servaddr.sin_addr.s_addr = htons(INADDR_ANY);
+- servaddr.sin_port = htons(TNFSD_PORT);
+- if (bind(tcplistenfd, (struct sockaddr *)&servaddr,
+- sizeof(servaddr)) < 0)
+- {
+- die("Unable to bind TCP socket");
+- }
+- listen(tcplistenfd, 5);
+ }
+
+ void tnfs_mainloop()
+@@ -165,25 +146,13 @@
+ int readyfds, i;
+ fd_set fdset;
+ fd_set errfdset;
+- int tcpsocks[MAX_TCP_CONN];
+-
+- memset(&tcpsocks, 0, sizeof(tcpsocks));
+
+ while (1)
+ {
+ FD_ZERO(&fdset);
+
+- /* add UDP socket and TCP listen socket to fdset */
++ /* add UDP socket socket to fdset */
+ FD_SET(sockfd, &fdset);
+- FD_SET(tcplistenfd, &fdset);
+-
+- for (i = 0; i < MAX_TCP_CONN; i++)
+- {
+- if (tcpsocks[i])
+- {
+- FD_SET(tcpsocks[i], &fdset);
+- }
+- }
+
+ FD_COPY(&fdset, &errfdset);
+ if ((readyfds = select(FD_SETSIZE, &fdset, NULL, &errfdset, NULL)) != 0)
+@@ -199,53 +168,8 @@
+ {
+ tnfs_handle_udpmsg();
+ }
+- /* Incoming TCP connection? */
+- else if (FD_ISSET(tcplistenfd, &fdset))
+- {
+- tcp_accept(&tcpsocks[0]);
+- }
+- else
+- {
+- for (i = 0; i < MAX_TCP_CONN; i++)
+- {
+- if (tcpsocks[i])
+- {
+- if (FD_ISSET(tcpsocks[i], &fdset))
+- {
+- tnfs_handle_tcpmsg(tcpsocks[i]);
+- }
+- }
+- }
+- }
+- }
+- }
+-}
+-
+-void tcp_accept(int *socklist)
+-{
+- int acc_fd, i;
+- struct sockaddr_in cli_addr;
+- socklen_t cli_len = sizeof(cli_addr);
+- int *fdptr;
+-
+- acc_fd = accept(tcplistenfd, (struct sockaddr *)&cli_addr, &cli_len);
+- if (acc_fd < 1)
+- {
+- fprintf(stderr, "WARNING: unable to accept TCP connection\n");
+- return;
+- }
+-
+- fdptr = socklist;
+- for (i = 0; i < MAX_TCP_CONN; i++)
+- {
+- if (*fdptr == 0)
+- {
+- *fdptr = acc_fd;
+- return;
+ }
+ }
+-
+- /* tell the client 'too many connections' */
+ }
+
+ void tnfs_handle_udpmsg()
+@@ -273,15 +197,6 @@
+ *(rxbuf + rxbytes) = 0;
+ }
+
+-void tnfs_handle_tcpmsg(int cli_fd)
+-{
+- char buf[255];
+- int sz;
+-
+- sz = read(cli_fd, buf, sizeof(buf));
+- printf("DEBUG: rx of tcpmsg: %d bytes: %s\n", sz, buf);
+-}
+-
+ void tnfs_decode(struct sockaddr_in *cliaddr, int rxbytes, unsigned char *rxbuf)
+ {
+ Header hdr;
+diff -Naur spectranet-TNFSD-2020-10-19/tnfs/tnfsd/datagram.h spectranet-TNFSD-2020-10-19.patched/tnfs/tnfsd/datagram.h
+--- spectranet-TNFSD-2020-10-19/tnfs/tnfsd/datagram.h 2020-09-23 14:06:09.000000000 -0400
++++ spectranet-TNFSD-2020-10-19.patched/tnfs/tnfsd/datagram.h 2022-08-18 17:20:12.070197634 -0400
+@@ -51,8 +51,6 @@
+ void tnfs_sockinit();
+ void tnfs_mainloop();
+ void tnfs_handle_udpmsg();
+-void tcp_accept(int *fdlist);
+-void tnfs_handle_tcpmsg(int cli_fd);
+ void tnfs_decode(struct sockaddr_in *cliaddr,
+ int rxbytes, unsigned char *rxbuf);
+ void tnfs_badcommand(Header *hdr, Session *sess);
+diff -Naur spectranet-TNFSD-2020-10-19/tnfs/tnfsd/tnfs.h spectranet-TNFSD-2020-10-19.patched/tnfs/tnfsd/tnfs.h
+--- spectranet-TNFSD-2020-10-19/tnfs/tnfsd/tnfs.h 2020-09-23 14:06:09.000000000 -0400
++++ spectranet-TNFSD-2020-10-19.patched/tnfs/tnfsd/tnfs.h 2022-08-18 17:20:22.625372592 -0400
+@@ -134,7 +134,6 @@
+ #endif
+ int lastmsgsz; /* last message's size inc. hdr */
+ uint8_t lastseqno; /* last sequence number */
+- uint8_t isTCP; /* uses the TCP transport */
+ } Session;
+
+ typedef struct _header
diff --git a/network/tnfsd/slack-desc b/network/tnfsd/slack-desc
index 23cd397d46fc..267872fd63b8 100644
--- a/network/tnfsd/slack-desc
+++ b/network/tnfsd/slack-desc
@@ -13,7 +13,7 @@ tnfsd: simplicity and ease of implementation on small systems, such as 8-bit
tnfsd: computers. It's simpler than NFS, SMB, or FTP. It's similar to TFTP,
tnfsd: but has features TFTP lacks.
tnfsd:
-tnfsd:
-tnfsd:
+tnfsd: TNFS uses UDP port 16384, so make sure you allow incoming traffic if
+tnfsd: you have firewall rules.
tnfsd:
tnfsd:
diff --git a/network/tnfsd/tnfsd.1 b/network/tnfsd/tnfsd.1
index fa4a355e09c1..0b05bb4a7d50 100644
--- a/network/tnfsd/tnfsd.1
+++ b/network/tnfsd/tnfsd.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "TNFSD" 1 "2022-07-22" "20201019" "SlackBuilds.org"
+.TH "TNFSD" 1 "2022-08-19" "20201019" "SlackBuilds.org"
.SH NAME
tnfsd \- trivial network filesystem daemon
.\" RST source for tnfsd(1) man page. Convert with:
@@ -47,8 +47,8 @@ computers. It\(aqs simpler than NFS, SMB, or FTP. It\(aqs similar to TFTP,
but has features TFTP lacks.
.sp
\fBtnfsd\fP is the server for the TNFS protocol. It listens for clients
-on UDP and TCP port 16384. Most 8\-bit clients use UDP, and the Linux
-client \fBtnfs\-fuse\fP uses TCP.
+on UDP port 16384. In theory, the protocol supports TCP connections,
+but this hasn\(aqt been implemented yet.
.sp
The mandatory \fBdirectory\fP option is the root of the TNFS filesystem
tree.
diff --git a/network/tnfsd/tnfsd.SlackBuild b/network/tnfsd/tnfsd.SlackBuild
index 9f54ec34accc..5b9195ea801c 100644
--- a/network/tnfsd/tnfsd.SlackBuild
+++ b/network/tnfsd/tnfsd.SlackBuild
@@ -6,11 +6,20 @@
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
+# 20220818 bkw: BUILD=2
+# - remove TCP support entirely. it's incomplete & thoroughly broken.
+# - mention UDP port 16384 in slack-desc.
+
+# Note to self: tnfs-perl/tnfsd.pl looks interesting, but it lacks
+# the ability to chroot and set a new user ID. Leave it out of
+# the package. The tnfs-fuseclient/ is empty except a README, and
+# tnfsd.test/ looks like an ancient version from 2010.
+
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=tnfsd
VERSION=${VERSION:-20201019}
-BUILD=${BUILD:-1}
+BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
@@ -43,9 +52,17 @@ EOF
exit 1
}
-getent group tnfsd &>/dev/null || uid_gid_err
-getent group tnfs-files &>/dev/null || uid_gid_err
-getent passwd tnfsd &>/dev/null || uid_gid_err
+chkgrp() {
+ getent group "$1" &>/dev/null || uid_gid_err
+}
+
+chkuser() {
+ getent passwd "$1" &>/dev/null || uid_gid_err
+}
+
+chkgrp tnfsd
+chkgrp tnfs-files
+chkuser tnfsd
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
@@ -72,14 +89,26 @@ mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $SRCNAM-$SRCVER
tar xvf $CWD/$SRCNAM-$SRCVER.tar.gz --wildcards '*/tnfs/*'
-cd $SRCNAM-$SRCVER/tnfs
+cd $SRCNAM-$SRCVER
chown -R root:root .
find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
\! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
-# this printf causes tnfsd to log something like 13GB of data in 5
-# minutes, if anyone ever connects to it with TCP. No thank you.
-sed -i '/printf.*DEBUG/d' tnfsd/datagram.c
+# 20220818 bkw: After messing with this for a while, I've discovered
+# that TCP *just doesn't work*. It'll listen and accept TCP
+# connections, but it never actually *does* anything with data
+# received via TCP (reads and discards it). Also, it never notices
+# when a TCP connection is closed, instead getting stuck in an
+# infinite loop eating 100% of one core... and logging massive
+# amounts of debug messages to stdout (like 2-3GB per minute). Since
+# it's non-functional anyway, this patch just dikes out TCP support
+# completely. So far as I know, there are no TNFS clients which use
+# TCP anyway.
+
+patch -p1 < $CWD/remove_broken_tcp_support.diff
+
+cd tnfs
+rm -f tnfsd/bin/* # guarantee we don't use prebuilt binary!
[ "${USAGELOG:-yes}" = "yes" ] && SLKCFLAGS+=" -DUSAGELOG"
sed -i "s,-Wall,& $SLKCFLAGS," tnfsd/Makefile
diff --git a/network/tnfsd/tnfsd.rst b/network/tnfsd/tnfsd.rst
index 38cc19d9dd63..5ae4610a0797 100644
--- a/network/tnfsd/tnfsd.rst
+++ b/network/tnfsd/tnfsd.rst
@@ -32,8 +32,8 @@ computers. It's simpler than NFS, SMB, or FTP. It's similar to TFTP,
but has features TFTP lacks.
**tnfsd** is the server for the TNFS protocol. It listens for clients
-on UDP and TCP port 16384. Most 8-bit clients use UDP, and the Linux
-client **tnfs-fuse** uses TCP.
+on UDP port 16384. In theory, the protocol supports TCP connections,
+but this hasn't been implemented yet.
The mandatory **directory** option is the root of the TNFS filesystem
tree.