public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/tftp] rawhide: rebase to 7.2
@ 2026-10-23 10:05 
  0 siblings, 0 replies; only message in thread
From:  @ 2026-10-23 10:05 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/tftp
            Branch : rawhide
            Commit : 03a3d4b1b115466d5b81ab3b8a6b2b1c90729a9a
            Author : Lukáš Zaoral <lzaoral@redhat.com>
            Date   : 2026-10-23T08:41:52+02:00
            Stats  : +426/-1089 in 14 file(s)
            URL    : https://src.fedoraproject.org/rpms/tftp/c/03a3d4b1b115466d5b81ab3b8a6b2b1c90729a9a?branch=rawhide

            Log:
            rebase to 7.2

- sync with upstream systemd unit files
- kudos to H. Peter Anvin for the SRPM patch!
- change --blksize 1468 to --blksize mtu in tftp.service

Resolves: rhbz#2537118

---
diff --git a/.gitignore b/.gitignore
index a773a32..d7291d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,5 @@ tftp-hpa-0.49.tar.bz2
 /tftp-hpa-6.0.tar.sign
 /tftp-hpa-6.1.tar.gz
 /tftp-hpa-6.1.tar.sign
+/tftp-hpa-7.2.tar.xz
+/tftp-hpa-7.2.tar.sign

diff --git a/0001-tftp-add-verbosity-level-remove-mention-of-verbose-l.patch b/0001-tftp-add-verbosity-level-remove-mention-of-verbose-l.patch
new file mode 100644
index 0000000..fe3b629
--- /dev/null
+++ b/0001-tftp-add-verbosity-level-remove-mention-of-verbose-l.patch
@@ -0,0 +1,85 @@
+From c805d0f734055270c17af454f9dd0e44d609fc4e Mon Sep 17 00:00:00 2001
+From: "H. Peter Anvin" <hpa@zytor.com>
+Date: Sun, 27 Sep 2026 11:12:13 -0700
+Subject: [PATCH 1/4] tftp: add --verbosity level, remove mention of
+ --verbose=level
+
+Add --verbosity level option for consistency with tftpd.
+Remove code and mention of --verbose=level which never worked.
+
+Signed-off-by: H. Peter Anvin <hpa@zytor.com>
+---
+ tftp/main.c    | 15 ++++++++++-----
+ tftp/tftp.1.in | 12 ++++++++----
+ 2 files changed, 18 insertions(+), 9 deletions(-)
+
+diff --git a/tftp/main.c b/tftp/main.c
+index 8c3c189f9d9f..15b252581b6d 100644
+--- a/tftp/main.c
++++ b/tftp/main.c
+@@ -328,6 +328,7 @@ static void usage(int errcode)
+             "    -6. --ipv6                 only use IPv6, no IPv4\n"
+ #endif
+             "    -v, --verbose              increase logging verbosity\n"
++            "        --verbosity level      set logging verbosity level\n"
+             "    -l, --literal              disable host:path syntax\n"
+             "    -m, --mode mode            set the transfer mode (netascii, octet)\n"
+             "    -a, --ascii                alias for --mode netascii\n"
+@@ -364,10 +365,15 @@ parse_uint_range(const char *arg, uintmax_t minimum, uintmax_t maximum)
+     return parsed;
+ }
+ 
++enum long_only_options {
++    OPT_VERBOSITY	= 256
++};
++
+ static const struct option long_options[] = {
+     { "ipv4",       no_argument,       NULL, '4' },
+     { "ipv6",       no_argument,       NULL, '6' },
+     { "verbose",    no_argument,       NULL, 'v' },
++    { "verbosity",  required_argument, NULL, OPT_VERBOSITY },
+     { "version",    no_argument,       NULL, 'V' },
+     { "literal",    no_argument,       NULL, 'l' },
+     { "mode",       required_argument, NULL, 'm' },
+@@ -432,11 +438,10 @@ int main(int argc, char *argv[])
+ #endif
+             break;
+         case 'v':
+-            if (optarg && *optarg) {
+-                set_verbosity(optarg, true);
+-            } else {
+-                copt.verbose++;
+-            }
++            copt.verbose++;
++            break;
++        case OPT_VERBOSITY:
++            set_verbosity(optarg, true);
+             break;
+         case 'V':
+             /* Print version and configuration to stdout and exit */
+diff --git a/tftp/tftp.1.in b/tftp/tftp.1.in
+index 9853d1979bbc..5c75a460216d 100644
+--- a/tftp/tftp.1.in
++++ b/tftp/tftp.1.in
+@@ -122,10 +122,14 @@ hijacking, and is therefore disallowed by default.
+ Force the originating (local) port number to be in the specified range of port
+ numbers.
+ .TP
+-\fB\-v\fP, \fB\-\-verbose\fP[=\fIlevel\fP]
+-Default to verbose mode. At
+-.I level
+-2 or higher, do not round byte counts in statistics or use suffixes.
++\fB\-v\fP, \fB\-\-verbose\fP
++Default to verbose mode. If repeated, further increase the verbosity
++level. At level 2 or higher, do not round byte counts in statistics or
++use suffixes.
++.TP
++\fB\-\-verbosity\fP [\fIlevel\fP]
++Set the verbosity level to
++.IR level .
+ .TP
+ \fB\-V\fP, \fB\-\-version\fP
+ Print the version number and configuration to standard output, then
+-- 
+2.55.0
+

diff --git a/0002-tests-control-the-verbosity-of-test-tftp.sh.patch b/0002-tests-control-the-verbosity-of-test-tftp.sh.patch
new file mode 100644
index 0000000..eff6bf6
--- /dev/null
+++ b/0002-tests-control-the-verbosity-of-test-tftp.sh.patch
@@ -0,0 +1,57 @@
+From 9281b923b016d6b9e2f48e33c147604e03cd6790 Mon Sep 17 00:00:00 2001
+From: "H. Peter Anvin" <hpa@zytor.com>
+Date: Sun, 27 Sep 2026 11:18:14 -0700
+Subject: [PATCH 2/4] tests: control the verbosity of test-tftp.sh.
+
+Allow the user to control the verbosity of test-tftp.sh.
+
+Signed-off-by: H. Peter Anvin <hpa@zytor.com>
+---
+ tests/test-tftp.sh | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/tests/test-tftp.sh b/tests/test-tftp.sh
+index 89df8fe9555a..55aa0600ae2b 100755
+--- a/tests/test-tftp.sh
++++ b/tests/test-tftp.sh
+@@ -24,6 +24,7 @@ UL_DIR="$TESTROOT/upload"
+ PCAP_LOG="$SCRIPT_DIR/test-tftp.pcap.gz"
+ TFTP_TEST_WINSIZES="${TFTP_TEST_WINSIZES:-1 4 64 256}"
+ TFTP_TEST_BLKSIZES="${TFTP_TEST_BLKSIZES:-mtu mtu-16 512 1468 9001 65464 199}"
++VERBOSE="${VERBOSE:-0}"
+ 
+ trap 'exit 127' INT TERM
+ trap 'cleanup' EXIT
+@@ -110,7 +111,8 @@ start_server() {
+ 	TFTPD_CMD+=(strace -o "$STRACE_LOG" -f)
+     fi
+ 
+-    TFTPD_CMD+=("$TFTPD" --stderr -vv -L -p --port-range $PORTRANGE)
++    TFTPD_CMD+=("$TFTPD" --verbosity $VERBOSE --stderr -vv -L
++		-p --port-range $PORTRANGE)
+     if [ $ANYADDR -ne 0 ]; then
+ 	if [ $PORT -ne 69 ]; then
+ 	    TFTPD_CMD+=(-a :$PORT)
+@@ -198,7 +200,8 @@ create_test_files() {
+ # Test file download (client receives)
+ test_download() {
+     local filename="$1"
+-    local -a tftp_options=(-v -B $BLKSIZE -W $WINSIZE "${@:2}")
++    local -a tftp_options=(--verbosity $VERBOSE
++			   -B $BLKSIZE -W $WINSIZE "${@:2}")
+     local logfile="$TESTROOT/tftp.log"
+ 
+     mkdir -p "$DL_DIR"
+@@ -253,7 +256,8 @@ test_download() {
+ # Test file upload (client sends)
+ test_upload() {
+     local filename="$1"
+-    local -a tftp_options=(-v -B $BLKSIZE -W $WINSIZE "${@:2}")
++    local -a tftp_options=(--verbosity $VERBOSE
++			   -B $BLKSIZE -W $WINSIZE "${@:2}")
+     local logfile="$TESTROOT/tftp.log"
+ 
+     mkdir -p "$UL_DIR"
+-- 
+2.55.0
+

diff --git a/0003-tests-redirect-tftpd-log-output-to-a-file.patch b/0003-tests-redirect-tftpd-log-output-to-a-file.patch
new file mode 100644
index 0000000..be39470
--- /dev/null
+++ b/0003-tests-redirect-tftpd-log-output-to-a-file.patch
@@ -0,0 +1,37 @@
+From cb11a421a1fc32835a188399902afbfee11ace62 Mon Sep 17 00:00:00 2001
+From: "H. Peter Anvin" <hpa@zytor.com>
+Date: Sun, 27 Sep 2026 11:22:09 -0700
+Subject: [PATCH 3/4] tests: redirect tftpd log output to a file
+
+Output the tftpd log messages to a file instead of stderr.
+This way all the output is the tagged status output if verbosity is 0.
+
+Signed-off-by: H. Peter Anvin <hpa@zytor.com>
+---
+ tests/test-tftp.sh | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/tests/test-tftp.sh b/tests/test-tftp.sh
+index 55aa0600ae2b..e6d6b1f86001 100755
+--- a/tests/test-tftp.sh
++++ b/tests/test-tftp.sh
+@@ -22,6 +22,7 @@ FILES_DIR="$TESTROOT/files"
+ DL_DIR="$TESTROOT/download"
+ UL_DIR="$TESTROOT/upload"
+ PCAP_LOG="$SCRIPT_DIR/test-tftp.pcap.gz"
++TFTPD_LOG="$SCRIPT_DIR/tftpd.log"
+ TFTP_TEST_WINSIZES="${TFTP_TEST_WINSIZES:-1 4 64 256}"
+ TFTP_TEST_BLKSIZES="${TFTP_TEST_BLKSIZES:-mtu mtu-16 512 1468 9001 65464 199}"
+ VERBOSE="${VERBOSE:-0}"
+@@ -125,7 +126,7 @@ start_server() {
+     fi
+     TFTPD_CMD+=(-c --jail "$SERVER_DIR")
+     print_info "${TFTPD_CMD[*]}"
+-    "${TFTPD_CMD[@]}" &
++    "${TFTPD_CMD[@]}" 1>&2 2>"$TFTPD_LOG" &
+     TFTPD_PID=$!
+ 
+     # Wait for server to start
+-- 
+2.55.0
+

diff --git a/0004-tests-allow-the-user-to-set-output-verbosity-control.patch b/0004-tests-allow-the-user-to-set-output-verbosity-control.patch
new file mode 100644
index 0000000..a13caf5
--- /dev/null
+++ b/0004-tests-allow-the-user-to-set-output-verbosity-control.patch
@@ -0,0 +1,143 @@
+From c1fd01143f5208a202becc6b50499efbffd96445 Mon Sep 17 00:00:00 2001
+From: "H. Peter Anvin" <hpa@zytor.com>
+Date: Sun, 27 Sep 2026 11:47:55 -0700
+Subject: [PATCH 4/4] tests: allow the user to set output verbosity, control
+ log locations
+
+Allow the user to set the output verbosity (info+pass+fail, pass+fail,
+fail, nothing).
+
+Make each log file location configurable.
+
+Signed-off-by: H. Peter Anvin <hpa@zytor.com>
+---
+ tests/test-tftp.sh | 64 +++++++++++++++++++++++++++++-----------------
+ 1 file changed, 41 insertions(+), 23 deletions(-)
+
+diff --git a/tests/test-tftp.sh b/tests/test-tftp.sh
+index e6d6b1f86001..bc13e3e2888f 100755
+--- a/tests/test-tftp.sh
++++ b/tests/test-tftp.sh
+@@ -3,33 +3,45 @@
+ # TFTP Client-Server Test Script
+ # Tests bidirectional file transfer with an ephemeral TFTP server
+ #
+-# Usage: ./test-tftp.sh
++# Usage: ./test-tftp.sh [-q|-qq|-qqq]
+ #
+ 
+ # Configuration
+-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
++SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
+ REPO_ROOT="$(dirname "$SCRIPT_DIR")"
+-TFTPD="${TFTPD:-$REPO_ROOT/tftpd/tftpd}"
++TFTPD="${TFTPD:-${REPO_ROOT}/tftpd/tftpd}"
+ TFTP="${TFTP:-${REPO_ROOT}/tftp/tftp}"
+ PORT="${PORT:-6969}"
+ PORTRANGE="${PORTRANGE:-60969:60999}"
+ LOCALHOSTS="${LOCALHOSTS:-127.0.0.1 ::1}"
+ ANYADDR="${ANYADDR:-0}"
+-TSIZE="${TSIZE:-1}"
++TSIZE="${TSIZE-1}"
+ TESTROOT=$(mktemp -d)
+ SERVER_DIR="$TESTROOT"
+ FILES_DIR="$TESTROOT/files"
+ DL_DIR="$TESTROOT/download"
+ UL_DIR="$TESTROOT/upload"
+-PCAP_LOG="$SCRIPT_DIR/test-tftp.pcap.gz"
+-TFTPD_LOG="$SCRIPT_DIR/tftpd.log"
++PCAP="${PCAP-1}"
++PCAP_LOG="${PCAP_LOG-$SCRIPT_DIR/test-tftp.pcap.gz}"
++TFTPD_LOG="${TFTPD_LOG-$SCRIPT_DIR/tftpd.log}"
+ TFTP_TEST_WINSIZES="${TFTP_TEST_WINSIZES:-1 4 64 256}"
+ TFTP_TEST_BLKSIZES="${TFTP_TEST_BLKSIZES:-mtu mtu-16 512 1468 9001 65464 199}"
+ VERBOSE="${VERBOSE:-0}"
++QUIET="${QUIET:-0}"
+ 
+ trap 'exit 127' INT TERM
+ trap 'cleanup' EXIT
+ 
++# Output verbosity level
++for arg; do
++    case "$arg" in
++	-q) QUIET=$((QUIET+1)) ;;
++	-qq) QUIET=$((QUIET+2)) ;;
++	-qqq) QUIET=$((QUIET+3)) ;;
++	*) echo "Unknown option: $arg" 1>&2; exit 64 ;;
++    esac
++done
++
+ # Color output helpers
+ RED='\033[0;31m'
+ GREEN='\033[0;32m'
+@@ -40,15 +52,15 @@ time=$(type -P time)
+ export TIME="${YELLOW}[TIME]${NC} real %e user %U sys %s\\n"
+ 
+ print_info() {
+-    echo -e "${YELLOW}[INFO]${NC} $*"
++    [ $QUIET -lt 1 ] && echo -e "${YELLOW}[INFO]${NC} $*"
+ }
+ 
+ print_success() {
+-    echo -e "${GREEN}[PASS]${NC} $*"
++    [ $QUIET -lt 2 ] && echo -e "${GREEN}[PASS]${NC} $*"
+ }
+ 
+ print_error() {
+-    echo -e "${RED}[FAIL]${NC} $*"
++    [ $QUIET -lt 3 ] && echo -e "${RED}[FAIL]${NC} $*"
+ }
+ 
+ # Print the difference between two fractional timestamps
+@@ -126,7 +138,11 @@ start_server() {
+     fi
+     TFTPD_CMD+=(-c --jail "$SERVER_DIR")
+     print_info "${TFTPD_CMD[*]}"
+-    "${TFTPD_CMD[@]}" 1>&2 2>"$TFTPD_LOG" &
++    if [ -n "$TFTPD_LOG" ]; then
++	"${TFTPD_CMD[@]}" 1>&2 2>"$TFTPD_LOG" &
++    else
++	"${TFTPD_CMD[@]}" &
++    fi
+     TFTPD_PID=$!
+ 
+     # Wait for server to start
+@@ -142,20 +158,22 @@ start_server() {
+ 
+     me=$(whoami)
+ 
+-    # If the user has access to tshark, dump a packet trace
++    # If the user has tshark, dump a packet trace if enabled
+     rm -f "$PCAP_LOG"
+-    local dumphosts=$(echo "$LOCALHOSTS" | \
+-			  sed -E -e 's/([^[:space:]]*:[^[:space:]]*)/[\1]/g' \
+-			  -e "s/([^[:space:]]+)/or host \\1/g" \
+-			  -e 's/^or //')
+-	   tshark -q -Q -i lo -n -w "$PCAP_LOG" \
+-	   -f "udp port $PORT or portrange ${PORTRANGE/:/-}" \
+-	   1>&2 2>/dev/null &
+-    TSHARK_PID=$!
+-    if kill -0 "$TSHARK_PID" 2>/dev/null; then
+-	print_info "dumping packets to: $PCAP_LOG"
+-    else
+-	unset TSHARK_PID
++    if [ 0"$PCAP" -ne 0 ]; then
++	local dumphosts=$(echo "$LOCALHOSTS" | \
++			      sed -E -e 's/([^[:space:]]*:[^[:space:]]*)/[\1]/g' \
++				  -e "s/([^[:space:]]+)/or host \\1/g" \
++				  -e 's/^or //')
++	tshark -q -Q -i lo -n -w "$PCAP_LOG" \
++	       -f "udp port $PORT or portrange ${PORTRANGE/:/-}" \
++	       1>&2 2>/dev/null &
++	TSHARK_PID=$!
++	if kill -0 "$TSHARK_PID" 2>/dev/null; then
++	    print_info "dumping packets to: $PCAP_LOG"
++	else
++	    unset TSHARK_PID
++	fi
+     fi
+ }
+ 
+-- 
+2.55.0
+

diff --git a/0005-tftp-fix-type-of-r_timeout.patch b/0005-tftp-fix-type-of-r_timeout.patch
new file mode 100644
index 0000000..6ccada2
--- /dev/null
+++ b/0005-tftp-fix-type-of-r_timeout.patch
@@ -0,0 +1,31 @@
+From f2d2b5d88ca3f329abe32f6366eae78a2ccb0ae7 Mon Sep 17 00:00:00 2001
+From: "H. Peter Anvin" <hpa@zytor.com>
+Date: Mon, 12 Oct 2026 14:01:57 -0700
+Subject: [PATCH] tftp: fix type of r_timeout
+
+r_timeout should be uintmax_t, not unsigned long. This would break
+compiling on 32-bit platforms.
+
+Reported-by: Chris Hofstaedtler <zeha@github.com>
+Fixes: https://github.com/hpax/tftp-hpa/issues/9
+Signed-off-by: H. Peter Anvin <hpa@zytor.com>
+---
+ tftp/tftp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tftp/tftp.c b/tftp/tftp.c
+index 2fd4bdf..964bf5c 100644
+--- a/tftp/tftp.c
++++ b/tftp/tftp.c
+@@ -280,7 +280,7 @@ int tftp_sendfile(int fd, const char *name, const char *mode)
+     bool convert = !strcmp(mode, "netascii");
+     struct optreq optreq, optack;
+     uint16_t ap_opcode, ap_block;
+-    unsigned long r_timeout;
++    uintmax_t r_timeout;
+     volatile uintmax_t amount = 0;
+     struct stat st;
+ 
+-- 
+2.55.0
+

diff --git a/0006-tftp-fix-type-of-r_timeout-2.patch b/0006-tftp-fix-type-of-r_timeout-2.patch
new file mode 100644
index 0000000..08d1cdf
--- /dev/null
+++ b/0006-tftp-fix-type-of-r_timeout-2.patch
@@ -0,0 +1,25 @@
+From 34f667a99f346a4c39305742bce1917c7ddafde4 Mon Sep 17 00:00:00 2001
+From: Chris Hofstaedtler <zeha@debian.org>
+Date: Tue, 13 Oct 2026 13:14:11 +0200
+Subject: [PATCH] tftp: fix type of r_timeout
+
+Same as f2d2b5d88ca3f329abe32f6366eae78a2ccb0ae7 but in tftp_recv_file
+
+Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
+---
+ tftp/tftp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tftp/tftp.c b/tftp/tftp.c
+index 964bf5c..a28ed9c 100644
+--- a/tftp/tftp.c
++++ b/tftp/tftp.c
+@@ -448,7 +448,7 @@ int tftp_recvfile(int fd, const char *name, const char *mode)
+     bool convert = !strcmp(mode, "netascii");
+     struct optreq optreq, optack;
+     uint16_t opcode;
+-    unsigned long r_timeout;
++    uintmax_t r_timeout;
+     volatile uintmax_t amount = 0;
+ 
+     optreq_init(&optreq);

diff --git a/sources b/sources
index 6e9deca..e5f4627 100644
--- a/sources
+++ b/sources
@@ -1,2 +1,2 @@
-SHA512 (tftp-hpa-6.1.tar.gz) = e6901af35a98f21ba270cff8870fd41f4151f1521aa7e5d38b0cfd9d6f0ab1221f822c76614e8771423b114dfcefd48c802454cf3eef174a075ebd69e757a032
-SHA512 (tftp-hpa-6.1.tar.sign) = 3f1653439f28ccb948a49a3445eb1beb65a3e8fab7d22d55663b6d90d4ccf84855f97cb6d2731f664755cffaaa5e17db52a81967f40cac985f4fd44de57bc281
+SHA512 (tftp-hpa-7.2.tar.xz) = 30ce7218365c6c7ba15694ce55c75bcea99bf347dc60f882fe5570acdfd0bf3dbe866b146b9d8d73986c222ed221211f354c4d6571d911f8d1a1bee35f0bb853
+SHA512 (tftp-hpa-7.2.tar.sign) = 26275831cf2b93c5f27ae8c87034960fed167e7e3f47355390033e337cda8f23f2ae99f265a578dfd74f2b137d371f00291f37e7a8c6736e3bc202e43010d6ed

diff --git a/tftp-enhanced-logging.patch b/tftp-enhanced-logging.patch
deleted file mode 100644
index 18b4a70..0000000
--- a/tftp-enhanced-logging.patch
+++ /dev/null
@@ -1,147 +0,0 @@
-From ab93a245747ada8948f4594de54a4b2b30c4b462 Mon Sep 17 00:00:00 2001
-From: "H. Peter Anvin" <hpa@zytor.com>
-Date: Tue, 8 Sep 2026 17:33:47 -0700
-Subject: [PATCH] tftpd: log failed and completed transfers
-
-Log file-not-found requests and successful transfers with the client address.
-
-Retain the requested filename before an upload reuses the request buffer for
-DATA packets, so completion logging always reports the correct name.
-
-Based on patch from the Fedora SRPM.
-
-Signed-off-by: H. Peter Anvin <hpa@zytor.com>
----
- tftpd/tftpd.c | 42 +++++++++++++++++++++++++++++++++---------
- tftpd/tftpd.h |  6 ++++--
- 2 files changed, 37 insertions(+), 11 deletions(-)
-
-diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
-index 8287161..1109bbf 100644
---- a/tftpd/tftpd.c
-+++ b/tftpd/tftpd.c
-@@ -1081,8 +1081,10 @@ int main(int argc, char **argv)
- static char *rewrite_access(const struct formats *,
- 			    char *, int, int, const char **);
- static int validate_access(char *, int, const struct formats *, const char **);
--static void tftp_sendfile(const struct formats *, struct tftphdr *, int);
--static void tftp_recvfile(const struct formats *, struct tftphdr *, int);
-+static void tftp_sendfile(const struct formats *, struct tftphdr *, int,
-+                          const char *);
-+static void tftp_recvfile(const struct formats *, struct tftphdr *, int,
-+                          const char *);
- 
- static const struct formats formats[] = {
-     {
-@@ -1101,7 +1103,7 @@ static int tftp(struct tftphdr *tp, int size)
-     char *cp, *end;
-     int argn, ecode;
-     const struct formats *pf = NULL;
--    char *origfilename;
-+    char *origfilename, *request_filename;
-     char *filename, *mode = NULL;
-     const char *errmsgptr;
-     uint16_t tp_opcode = ntohs(tp->th_opcode);
-@@ -1174,6 +1176,9 @@ static int tftp(struct tftphdr *tp, int size)
- 	    if (!file) {
- 		ecode =
- 		    (*pf->f_validate) (filename, tp_opcode, pf, &errmsgptr);
-+		if (ecode == ENOTFOUND)
-+		    tftpd_log(LOG_NOTICE, "client %s: file not found: %s",
-+			      tmp_p, filename);
- 		if (ecode) {
- 		    nak(ecode, errmsgptr);
- 		    exit(0);
-@@ -1195,17 +1200,20 @@ static int tftp(struct tftphdr *tp, int size)
- 
-     negotiate_windowsize(&ap);
-     tftp_set_socket_buffers(peer, segsize, windowsize, tp_opcode == RRQ);
-+    request_filename = xstrdup(origfilename);
- 
-     if (ap != (ackbuf + 2)) {
-         if (tp_opcode == WRQ)
--            (*pf->f_recv) (pf, (struct tftphdr *)ackbuf, ap - ackbuf);
-+            (*pf->f_recv) (pf, (struct tftphdr *)ackbuf, ap - ackbuf,
-+                           request_filename);
-         else
--            (*pf->f_send) (pf, (struct tftphdr *)ackbuf, ap - ackbuf);
-+            (*pf->f_send) (pf, (struct tftphdr *)ackbuf, ap - ackbuf,
-+                           request_filename);
-     } else {
-         if (tp_opcode == WRQ)
--            (*pf->f_recv) (pf, NULL, 0);
-+            (*pf->f_recv) (pf, NULL, 0, request_filename);
-         else
--            (*pf->f_send) (pf, NULL, 0);
-+            (*pf->f_send) (pf, NULL, 0, request_filename);
-     }
-     exit(0);                    /* Request completed */
- }
-@@ -1743,7 +1751,8 @@ static int validate_access(char *filename, int mode,
- /*
-  * Send the requested file.
-  */
--static void tftp_sendfile(const struct formats *pf, struct tftphdr *oap, int oacklen)
-+static void tftp_sendfile(const struct formats *pf, struct tftphdr *oap,
-+                          int oacklen, const char *filename)
- {
-     struct tftphdr *ap;         /* ack packet */
-     uint16_t ap_opcode, ap_block;
-@@ -1817,6 +1826,13 @@ static void tftp_sendfile(const struct formats *pf, struct tftphdr *oap, int oac
-         errno = result.error;
-         tftpd_log(LOG_WARNING, "tftpd: read(ack): %m");
-         break;
-+    case TFTP_XFER_OK:
-+        tmp_p = inet_ntop(from.sa.sa_family, SOCKADDR_P(&from), tmpbuf,
-+                          INET6_ADDRSTRLEN);
-+        if (!tmp_p)
-+            tmp_p = "???";
-+        tftpd_log(LOG_NOTICE, "client %s: finished %s", tmp_p, filename);
-+        break;
-     default:
-         break;
-     }
-@@ -1832,7 +1848,8 @@ static void tftp_sendfile(const struct formats *pf, struct tftphdr *oap, int oac
-  * Receive a file.
-  */
- static void tftp_recvfile(const struct formats *pf,
--			  struct tftphdr *oack, int oacklen)
-+			  struct tftphdr *oack, int oacklen,
-+                          const char *filename)
- {
-     struct daemon_xfer_context context;
-     struct tftp_xfer xfer;
-@@ -1889,6 +1906,13 @@ static void tftp_recvfile(const struct formats *pf,
-         errno = result.error;
-         tftpd_log(LOG_WARNING, "tftpd: read: %m");
-         break;
-+    case TFTP_XFER_OK:
-+        tmp_p = inet_ntop(from.sa.sa_family, SOCKADDR_P(&from), tmpbuf,
-+                          INET6_ADDRSTRLEN);
-+        if (!tmp_p)
-+            tmp_p = "???";
-+        tftpd_log(LOG_NOTICE, "client %s: finished %s", tmp_p, filename);
-+        break;
-     default:
-         break;
-     }
-diff --git a/tftpd/tftpd.h b/tftpd/tftpd.h
-index 3727ba4..129fdfb 100644
---- a/tftpd/tftpd.h
-+++ b/tftpd/tftpd.h
-@@ -34,8 +34,10 @@ struct formats {
-     const char *f_mode;
-     char *(*f_rewrite) (const struct formats *, char *, int, int, const char **);
-     int (*f_validate) (char *, int, const struct formats *, const char **);
--    void (*f_send) (const struct formats *, struct tftphdr *, int);
--    void (*f_recv) (const struct formats *, struct tftphdr *, int);
-+    void (*f_send) (const struct formats *, struct tftphdr *, int,
-+                    const char *);
-+    void (*f_recv) (const struct formats *, struct tftphdr *, int,
-+                    const char *);
-     bool f_convert;
- };
- 
--- 
-2.55.0
-

diff --git a/tftp-hpa-5.2-osh.patch b/tftp-hpa-5.2-osh.patch
deleted file mode 100644
index b74eb4f..0000000
--- a/tftp-hpa-5.2-osh.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From 43a86cbcbfd38e992d6f5d5009eea60f436711e4 Mon Sep 17 00:00:00 2001
-From: "H. Peter Anvin" <hpa@zytor.com>
-Date: Tue, 8 Sep 2026 17:33:47 -0700
-Subject: [PATCH] tftpd: close descriptors on access validation errors
-
-Close the file descriptor before returning access errors after a file has
-been opened.  This avoids leaking a descriptor for rejected read and write
-requests, including failed post-open truncation.
-
-Patch from Fedora SRPM.
-
-Signed-off-by: H. Peter Anvin <hpa@zytor.com>
----
- tftpd/tftpd.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
-index 32e4150..8287161 100644
---- a/tftpd/tftpd.c
-+++ b/tftpd/tftpd.c
-@@ -1701,6 +1701,7 @@ static int validate_access(char *filename, int mode,
- 
-     if (mode == RRQ) {
-         if (!unixperms && (stbuf.st_mode & (S_IREAD >> 6)) == 0) {
-+            close(fd);
-             *errmsg = "File must have global read permissions";
-             return (EACCESS);
-         }
-@@ -1710,6 +1711,7 @@ static int validate_access(char *filename, int mode,
-     } else {
-         if (!unixperms) {
-             if ((stbuf.st_mode & (S_IWRITE >> 6)) == 0) {
-+                close(fd);
-                 *errmsg = "File must have global write permissions";
-                 return (EACCESS);
-             }
-@@ -1718,6 +1720,7 @@ static int validate_access(char *filename, int mode,
- #ifdef HAVE_FTRUNCATE
- 	/* We didn't get to truncate the file at open() time */
- 	if (ftruncate(fd, (off_t) 0)) {
-+	  close(fd);
- 	  *errmsg = "Cannot reset file size";
- 	  return (EACCESS);
- 	}
--- 
-2.55.0
-

diff --git a/tftp-hpa-5.3-tftp-exit-code-cmdmode.patch b/tftp-hpa-5.3-tftp-exit-code-cmdmode.patch
deleted file mode 100644
index d884021..0000000
--- a/tftp-hpa-5.3-tftp-exit-code-cmdmode.patch
+++ /dev/null
@@ -1,880 +0,0 @@
-From 85b246c2bb3887ec19367841b342312f89090aaf Mon Sep 17 00:00:00 2001
-From: "H. Peter Anvin" <hpa@zytor.com>
-Date: Tue, 8 Sep 2026 17:33:47 -0700
-Subject: [PATCH] tftp: return failures from command mode
-
-Make command handlers and transfer routines return sysexits-compatible
-status codes so -c reports command, local I/O, and protocol failures.
-
-Commands that would otherwise prompt for missing arguments now return usage
-errors in command mode while retaining the interactive prompt behavior.
-
-Based on patch from the Fedora SRPM.
-
-Signed-off-by: H. Peter Anvin <hpa@zytor.com>
----
- tftp/extern.h |   4 +-
- tftp/main.c   | 209 ++++++++++++++++++++++++++++++--------------------
- tftp/tftp.c   |  43 +++++++++--
- 3 files changed, 164 insertions(+), 92 deletions(-)
-
-diff --git a/tftp/extern.h b/tftp/extern.h
-index 7740cb7..295b8e9 100644
---- a/tftp/extern.h
-+++ b/tftp/extern.h
-@@ -10,8 +10,8 @@
- 
- #include "config.h"
- 
--void tftp_recvfile(int, const char *, const char *, unsigned int);
--void tftp_sendfile(int, const char *, const char *, unsigned int);
-+int tftp_recvfile(int, const char *, const char *, unsigned int);
-+int tftp_sendfile(int, const char *, const char *, unsigned int);
- extern sigjmp_buf toplevel;
- 
- #endif
-diff --git a/tftp/main.c b/tftp/main.c
-index 1b618b1..86d9c78 100644
---- a/tftp/main.c
-+++ b/tftp/main.c
-@@ -3,6 +3,7 @@
-  *
-  * Copyright (c) 1983, 1993
-  *	The Regents of the University of California.  All rights reserved.
-+ * Copyright (C) 2026 H. Peter Anvin <hpa@zytor.com>
-  */
- 
- #include "common/tftpsubs.h"
-@@ -65,6 +66,7 @@ bool trace;
- int verbose;
- static bool literal;
- static bool connected;
-+static bool iscmd;
- static const struct modes *mode;
- #ifdef WITH_READLINE
- static char *line = NULL;
-@@ -84,23 +86,23 @@ static unsigned int portrange_to = 0;
- unsigned int blocksize = SEGSIZE;
- unsigned int windowsize;
- 
--static void get(int, char **);
--static void help(int, char **);
--static void modecmd(int, char **);
--static void put(int, char **);
--static void quit(int, char **);
--static void setascii(int, char **);
--static void setbinary(int, char **);
--static void setblocksize(int, char **);
--static void setpeer(int, char **);
--static void setrexmt(int, char **);
--static void settimeout(int, char **);
--static void settrace(int, char **);
--static void set_verbosity(const char *, bool);
--static void setverbose(int, char **);
--static void status(int, char **);
--static void setliteral(int, char **);
--static void setwindowsize(int, char **);
-+static int get(int, char **);
-+static int help(int, char **);
-+static int modecmd(int, char **);
-+static int put(int, char **);
-+static int quit(int, char **);
-+static int setascii(int, char **);
-+static int setbinary(int, char **);
-+static int setblocksize(int, char **);
-+static int setpeer(int, char **);
-+static int setrexmt(int, char **);
-+static int settimeout(int, char **);
-+static int settrace(int, char **);
-+static int set_verbosity(const char *, bool);
-+static int setverbose(int, char **);
-+static int status(int, char **);
-+static int setliteral(int, char **);
-+static int setwindowsize(int, char **);
- 
- static void command(void);
- 
-@@ -116,7 +118,7 @@ static void settftpmode(const struct modes *);
- struct cmd {
-     const char *name;
-     const char *help;
--    void (*handler) (int, char **);
-+    int (*handler) (int, char **);
- };
- 
- static const struct cmd cmdtab[] = {
-@@ -246,9 +248,8 @@ static const char short_options[] = "+46vVlm:cR:B:W:w:abh";
- int main(int argc, char *argv[])
- {
-     union sock_addr sa;
--    int optc;
-+    int optc, ret;
-     static int pargc, peerargc;
--    static bool iscmd;
-     static char **pargv;
-     char *peerargv[3];
- 
-@@ -383,7 +384,7 @@ int main(int argc, char *argv[])
-         /* Set peer */
-         if (sigsetjmp(toplevel, 1) != 0)
-             exit(EX_NOHOST);
--        setpeer(peerargc, peerargv);
-+        (void)setpeer(peerargc, peerargv);
-     }
- 
-     if (ai_fam_sock == AF_UNSPEC)
-@@ -428,9 +429,9 @@ int main(int argc, char *argv[])
-         if (sigsetjmp(toplevel, 1) != 0)
-             exit(EX_UNAVAILABLE);
- 
--        (*c->handler) (pargc, pargv);
-+        ret = (*c->handler) (pargc, pargv);
-         xfree(splitbuf);
--        exit(0);
-+        exit(ret);
-     }
- #ifdef WITH_READLINE
- #ifdef HAVE_READLINE_HISTORY_H
-@@ -449,8 +450,11 @@ static char *hostname;
- 
- /* Called when a command is incomplete; modifies
-    the global variable "line" */
--static void getmoreargs(const char *partial, const char *mprompt)
-+static bool getmoreargs(const char *partial, const char *mprompt)
- {
-+    if (iscmd)
-+        return false;
-+
- #ifdef WITH_READLINE
-     char *eline;
-     int len, elen;
-@@ -483,21 +487,23 @@ static void getmoreargs(const char *partial, const char *mprompt)
-         if (feof(stdin))
-             exit(0);            /* EOF */
- #endif
-+    return true;
- }
- 
--static void setpeer(int argc, char *argv[])
-+static int setpeer(int argc, char *argv[])
- {
-     int err;
- 
-     if (argc < 2) {
--        getmoreargs("connect ", "(to) ");
-+        if (!getmoreargs("connect ", "(to) "))
-+            return EX_USAGE;
-         margc = makeargv(line, margv);
-         argc = margc;
-         argv = margv;
-     }
-     if ((argc < 2) || (argc > 3)) {
-         printf("usage: %s host-name [port]\n", argv[0]);
--        return;
-+        return EX_USAGE;
-     }
- 
-     peeraddr.sa.sa_family = ai_fam;
-@@ -506,7 +512,7 @@ static void setpeer(int argc, char *argv[])
-         printf("Error: %s\n", gai_strerror(err));
-         printf("%s: unknown host\n", argv[1]);
-         connected = false;
--        return;
-+        return EX_NOHOST;
-     }
-     ai_fam = peeraddr.sa.sa_family;
-     if (f == -1) { /* socket not open */
-@@ -543,7 +549,7 @@ static void setpeer(int argc, char *argv[])
-             if (*ep || myport > 65535UL) {
-                 printf("%s: bad port number\n", argv[2]);
-                 connected = false;
--                return;
-+                return EX_USAGE;
-             }
-             port = htons((uint16_t) myport);
-         }
-@@ -560,16 +566,17 @@ static void setpeer(int argc, char *argv[])
-                hostname, tp, (unsigned int)ntohs(port));
-     }
-     connected = true;
-+    return 0;
- }
- 
--static void modecmd(int argc, char *argv[])
-+static int modecmd(int argc, char *argv[])
- {
-     const struct modes *p;
-     const char *sep;
- 
-     if (argc < 2) {
-         printf("Using %s mode to transfer files.\n", mode->m_mode);
--        return;
-+        return 0;
-     }
-     if (argc == 2) {
-         for (p = modes; p->m_name; p++)
-@@ -577,7 +584,7 @@ static void modecmd(int argc, char *argv[])
-                 break;
-         if (p->m_name) {
-             settftpmode(p);
--            return;
-+            return 0;
-         }
-         printf("%s: unknown mode\n", argv[1]);
-         /* drop through and print usage message */
-@@ -591,21 +598,23 @@ static void modecmd(int argc, char *argv[])
-             sep = " | ";
-     }
-     printf(" ]\n");
--    return;
-+    return EX_USAGE;
- }
- 
--static void setbinary(int argc, char *argv[])
-+static int setbinary(int argc, char *argv[])
- {
-     (void)argc;
-     (void)argv;                 /* Quiet unused warning */
-     settftpmode(MODE_OCTET);
-+    return 0;
- }
- 
--static void setascii(int argc, char *argv[])
-+static int setascii(int argc, char *argv[])
- {
-     (void)argc;
-     (void)argv;                 /* Quiet unused warning */
-     settftpmode(MODE_NETASCII);
-+    return 0;
- }
- 
- static void settftpmode(const struct modes *newmode)
-@@ -618,7 +627,7 @@ static void settftpmode(const struct modes *newmode)
- /*
-  * Send file(s).
-  */
--static void put(int argc, char *argv[])
-+static int put(int argc, char *argv[])
- {
-     int fd;
-     int n, err;
-@@ -626,21 +635,22 @@ static void put(int argc, char *argv[])
-     char *targ;
- 
-     if (argc < 2) {
--        getmoreargs("send ", "(file) ");
-+        if (!getmoreargs("send ", "(file) "))
-+            return EX_USAGE;
-         margc = makeargv(line, margv);
-         argc = margc;
-         argv = margv;
-     }
-     if (argc < 2) {
-         putusage(argv[0]);
--        return;
-+        return EX_USAGE;
-     }
-     targ = argv[argc - 1];
-     if (!literal && strchr(argv[argc - 1], ':')) {
-         for (n = 1; n < argc - 1; n++)
-             if (strchr(argv[n], ':')) {
-                 putusage(argv[0]);
--                return;
-+                return EX_USAGE;
-             }
-         cp = argv[argc - 1];
-         targ = strchr(cp, ':');
-@@ -651,14 +661,14 @@ static void put(int argc, char *argv[])
-             printf("Error: %s\n", gai_strerror(err));
-             printf("%s: unknown host\n", argv[1]);
-             connected = false;
--            return;
-+            return EX_NOHOST;
-         }
-         ai_fam = peeraddr.sa.sa_family;
-         connected = true;
-     }
-     if (!connected) {
-         printf("No target machine specified.\n");
--        return;
-+        return EX_USAGE;
-     }
-     if (argc < 4) {
-         cp = argc == 2 ? tail(targ) : argv[1];
-@@ -666,17 +676,17 @@ static void put(int argc, char *argv[])
-         if (fd < 0) {
-             fprintf(stderr, "tftp: ");
-             perror(cp);
--            return;
-+            return EX_OSERR;
-         }
-         if (verbose)
-             printf("putting %s to %s:%s [%s]\n",
-                    cp, hostname, targ, mode->m_mode);
-         sa_set_port(&peeraddr, port);
--        tftp_sendfile(fd, targ, mode->m_mode, windowsize);
--        return;
-+        return tftp_sendfile(fd, targ, mode->m_mode, windowsize);
-     }
-     /* this assumes the target is a directory */
-     /* on a remote unix system.  hmmmm.  */
-+    err = 0;
-     for (n = 1; n < argc - 1; n++) {
-         const char *base = tail(argv[n]);
-         char *remotepath = xmalloc(strlen(targ) + 1 + strlen(base) + 1);
-@@ -687,15 +697,20 @@ static void put(int argc, char *argv[])
-             fprintf(stderr, "tftp: ");
-             perror(argv[n]);
-             free(remotepath);
-+            if (!err)
-+                err = EX_OSERR;
-             continue;
-         }
-         if (verbose)
-             printf("putting %s to %s:%s [%s]\n",
-                    argv[n], hostname, remotepath, mode->m_mode);
-         sa_set_port(&peeraddr, port);
--        tftp_sendfile(fd, remotepath, mode->m_mode, windowsize);
-+        n = tftp_sendfile(fd, remotepath, mode->m_mode, windowsize);
-+        if (!err)
-+            err = n;
-         free(remotepath);
-     }
-+    return err;
- }
- 
- static void putusage(const char *s)
-@@ -707,43 +722,47 @@ static void putusage(const char *s)
- /*
-  * Receive file(s).
-  */
--static void get(int argc, char *argv[])
-+static int get(int argc, char *argv[])
- {
-     int fd;
--    int n;
-+    int n, err;
-     char *cp;
-     char *src;
- 
-     if (argc < 2) {
--        getmoreargs("get ", "(files) ");
-+        if (!getmoreargs("get ", "(files) "))
-+            return EX_USAGE;
-         margc = makeargv(line, margv);
-         argc = margc;
-         argv = margv;
-     }
-     if (argc < 2) {
-         getusage(argv[0]);
--        return;
-+        return EX_USAGE;
-     }
-     if (!connected) {
-         for (n = 1; n < argc; n++)
-             if (literal || strchr(argv[n], ':') == 0) {
-                 getusage(argv[0]);
--                return;
-+                return EX_USAGE;
-             }
-     }
-+    err = 0;
-     for (n = 1; n < argc; n++) {
-         src = strchr(argv[n], ':');
-         if (literal || src == NULL)
-             src = argv[n];
-         else {
--            int err;
-+            int resolve_error;
- 
-             *src++ = 0;
-             peeraddr.sa.sa_family = ai_fam;
--            err = set_sock_addr(argv[n], &peeraddr, &hostname, false);
--            if (err) {
--                printf("Warning: %s\n", gai_strerror(err));
-+            resolve_error = set_sock_addr(argv[n], &peeraddr, &hostname, false);
-+            if (resolve_error) {
-+                printf("Warning: %s\n", gai_strerror(resolve_error));
-                 printf("%s: unknown host\n", argv[1]);
-+                if (!err)
-+                    err = EX_NOHOST;
-                 continue;
-             }
-             ai_fam = peeraddr.sa.sa_family;
-@@ -756,13 +775,13 @@ static void get(int argc, char *argv[])
-             if (fd < 0) {
-                 fprintf(stderr, "tftp: ");
-                 perror(cp);
--                return;
-+                return EX_OSERR;
-             }
-             if (verbose)
-                 printf("getting from %s:%s to %s [%s]\n",
-                        hostname, src, cp, mode->m_mode);
-             sa_set_port(&peeraddr, port);
--            tftp_recvfile(fd, src, mode->m_mode, windowsize);
-+            err = tftp_recvfile(fd, src, mode->m_mode, windowsize);
-             break;
-         }
-         cp = tail(src);         /* new .. jdg */
-@@ -771,14 +790,19 @@ static void get(int argc, char *argv[])
-         if (fd < 0) {
-             fprintf(stderr, "tftp: ");
-             perror(cp);
-+            if (!err)
-+                err = EX_OSERR;
-             continue;
-         }
-         if (verbose)
-             printf("getting from %s:%s to %s [%s]\n",
-                    hostname, src, cp, mode->m_mode);
-         sa_set_port(&peeraddr, port);
--        tftp_recvfile(fd, src, mode->m_mode, windowsize);
-+        n = tftp_recvfile(fd, src, mode->m_mode, windowsize);
-+        if (!err)
-+            err = n;
-     }
-+    return err;
- }
- 
- static void getusage(const char *s)
-@@ -790,91 +814,104 @@ static void getusage(const char *s)
- int rexmtval = TIMEOUT;
- int maxtimeout = TIMEOUT_LIMIT * TIMEOUT;
- 
--static void setrexmt(int argc, char *argv[])
-+static int setrexmt(int argc, char *argv[])
- {
-     int t;
- 
-     if (argc < 2) {
--        getmoreargs("rexmt-timeout ", "(value) ");
-+        if (!getmoreargs("rexmt-timeout ", "(value) "))
-+            return EX_USAGE;
-         argc = margc = makeargv(line, margv);
-         argv = margv;
-     }
-     if (argc != 2) {
-         printf("usage: %s value\n", argv[0]);
--        return;
-+        return EX_USAGE;
-     }
-     t = atoi(argv[1]);
--    if (t < 1)
-+    if (t < 1) {
-         printf("%s: bad value\n", argv[1]);
--    else {
-+        return EX_USAGE;
-+    } else {
-         rexmtval = t;
-         maxtimeout = rexmtval * TIMEOUT_LIMIT;
-     }
-+    return 0;
- }
- 
--static void settimeout(int argc, char *argv[])
-+static int settimeout(int argc, char *argv[])
- {
-     int t;
- 
-     if (argc < 2) {
--        getmoreargs("maximum-timeout ", "(value) ");
-+        if (!getmoreargs("maximum-timeout ", "(value) "))
-+            return EX_USAGE;
-         argc = margc = makeargv(line, margv);
-         argv = margv;
-     }
-     if (argc != 2) {
-         printf("usage: %s value\n", argv[0]);
--        return;
-+        return EX_USAGE;
-     }
-     t = atoi(argv[1]);
--    if (t < 1)
-+    if (t < 1) {
-         printf("%s: bad value\n", argv[1]);
--    else
-+        return EX_USAGE;
-+    } else
-         maxtimeout = t;
-+    return 0;
- }
- 
--static void setblocksize(int argc, char *argv[])
-+static int setblocksize(int argc, char *argv[])
- {
-     if (argc < 2) {
--        getmoreargs("blocksize ", "(size) ");
-+        if (!getmoreargs("blocksize ", "(size) "))
-+            return EX_USAGE;
-         argc = margc = makeargv(line, margv);
-         argv = margv;
-     }
-     if (argc != 2) {
-         printf("usage: %s size\n", argv[0]);
--        return;
-+        return EX_USAGE;
-     }
-     if (!parse_uint_range(argv[1], 8, MAX_SEGSIZE, &blocksize)) {
-         printf("%s: bad block size (valid range is 8-%d)\n",
-                argv[1], MAX_SEGSIZE);
-+        return EX_USAGE;
-     }
-+    return 0;
- }
- 
--static void setwindowsize(int argc, char *argv[])
-+static int setwindowsize(int argc, char *argv[])
- {
-     if (argc < 2) {
--        getmoreargs("windowsize ", "(size) ");
-+        if (!getmoreargs("windowsize ", "(size) "))
-+            return EX_USAGE;
-         argc = margc = makeargv(line, margv);
-         argv = margv;
-     }
-     if (argc != 2) {
-         printf("usage: %s size\n", argv[0]);
--        return;
-+        return EX_USAGE;
-     }
-     if (!parse_uint_range(argv[1], 1, TFTP_MAX_WINDOWSIZE, &windowsize)) {
-         printf("%s: bad window size (valid range is 1-%u)\n",
-                argv[1], TFTP_MAX_WINDOWSIZE);
-+        return EX_USAGE;
-     }
-+    return 0;
- }
- 
--static void setliteral(int argc, char *argv[])
-+static int setliteral(int argc, char *argv[])
- {
-     (void)argc;
-     (void)argv;                 /* Quiet unused warning */
-     literal = !literal;
-     printf("Literal mode %s.\n", literal ? "on" : "off");
-+    return 0;
- }
- 
--static void status(int argc, char *argv[])
-+static int status(int argc, char *argv[])
- {
-     (void)argc;
-     (void)argv;                 /* Quiet unused warning */
-@@ -889,6 +926,7 @@ static void status(int argc, char *argv[])
-            rexmtval, maxtimeout);
-     printf("Blocksize: %u, windowsize: %u\n", blocksize,
-            windowsize ? windowsize : 1);
-+    return 0;
- }
- 
- static void intr(int sig)
-@@ -958,7 +996,7 @@ static void command(void)
-             printf("Error: %s command: %s\n", errtype, margv[0]);
-             continue;
-         }
--        (*c->handler) (margc, margv);
-+        (void)(*c->handler) (margc, margv);
-     }
- }
- 
-@@ -1031,7 +1069,7 @@ static int makeargv(char *str, char **argp)
-     return argc;
- }
- 
--static void quit(int argc, char *argv[])
-+static int quit(int argc, char *argv[])
- {
-     (void)argc;
-     (void)argv;                 /* Quiet unused warning */
-@@ -1041,7 +1079,7 @@ static void quit(int argc, char *argv[])
- /*
-  * Help command.
-  */
--static void help(int argc, char *argv[])
-+static int help(int argc, char *argv[])
- {
-     const struct cmd *c;
- 
-@@ -1051,7 +1089,7 @@ static void help(int argc, char *argv[])
-         printf("Commands may be abbreviated.  Commands are:\n\n");
-         for (c = cmdtab; c->name; c++)
-             printf("%-*s\t%s\n", (int)HELPINDENT, c->name, c->help);
--        return;
-+        return 0;
-     }
-     while (--argc > 0) {
-         const char *errtype;
-@@ -1063,18 +1101,20 @@ static void help(int argc, char *argv[])
-         else
-             printf("%s\n", c->help);
-     }
-+    return 0;
- }
- 
--static void settrace(int argc, char *argv[])
-+static int settrace(int argc, char *argv[])
- {
-     (void)argc;
-     (void)argv;                 /* Quiet unused warning */
- 
-     trace = !trace;
-     printf("Packet tracing %s.\n", trace ? "on" : "off");
-+    return 0;
- }
- 
--static void set_verbosity(const char *to, bool startup)
-+static int set_verbosity(const char *to, bool startup)
- {
-     const char *name;
- 
-@@ -1090,7 +1130,7 @@ static void set_verbosity(const char *to, bool startup)
-                 exit(EX_USAGE);
-             } else {
-                 printf("Invalid verbosity level: %s\n", to);
--                return;
-+                return EX_USAGE;
-             }
-         }
-     } else {
-@@ -1111,10 +1151,11 @@ static void set_verbosity(const char *to, bool startup)
- 
-     if (!startup)
-         printf("Verbosity set to level %d (%s).\n", verbose, name);
-+    return 0;
- }
- 
--static void setverbose(int argc, char *argv[])
-+static int setverbose(int argc, char *argv[])
- {
-     (void)argc;
--    set_verbosity(argv[1], false);
-+    return set_verbosity(argv[1], false);
- }
-diff --git a/tftp/tftp.c b/tftp/tftp.c
-index 992d7a6..03967cc 100644
---- a/tftp/tftp.c
-+++ b/tftp/tftp.c
-@@ -120,8 +120,8 @@ static const struct tftp_xfer_ops client_xfer_ops = {
- /*
-  * Send the requested file.
-  */
--void tftp_sendfile(int fd, const char *name, const char *mode,
--                   unsigned int requested_window)
-+int tftp_sendfile(int fd, const char *name, const char *mode,
-+                  unsigned int requested_window)
- {
-     struct tftphdr *ap;
-     char response[REQBUFSIZE];
-@@ -133,6 +133,7 @@ void tftp_sendfile(int fd, const char *name, const char *mode,
-     struct tftp_xfer xfer;
-     struct tftp_xfer_result result;
-     int n, size;
-+    volatile int err = 0;
-     bool convert = !strcmp(mode, "netascii");
-     unsigned int window;
-     unsigned int negotiated_block, negotiated_window;
-@@ -147,8 +148,11 @@ void tftp_sendfile(int fd, const char *name, const char *mode,
- 
-     startclock();
-     file = fdopen(fd, convert ? "rt" : "rb");
--    if (!file)
-+    if (!file) {
-+        close(fd);
-+        err = EX_OSERR;
-         goto abort;
-+    }
-     ap = (struct tftphdr *)ackbuf;
- 
-     tftp_signal(SIGALRM, timer, 0);
-@@ -156,6 +160,7 @@ void tftp_sendfile(int fd, const char *name, const char *mode,
-                        sizeof(ackbuf));
-     if (size < 0) {
-         fprintf(stderr, "tftp: %s: %s\n", name, strerror(errno));
-+        err = EX_OSERR;
-         goto abort;
-     }
- 
-@@ -167,6 +172,7 @@ void tftp_sendfile(int fd, const char *name, const char *mode,
-             tpacket("sent", ap, size);
-         if (sendto(f, ap, size, 0, &peeraddr.sa, SOCKLEN(&peeraddr)) != size) {
-             perror("tftp: sendto");
-+            err = EX_OSERR;
-             goto abort;
-         }
-         r_timeout = timeout;
-@@ -175,6 +181,7 @@ void tftp_sendfile(int fd, const char *name, const char *mode,
-         n = client_recv_time(response, sizeof(response), &from, &r_timeout);
-         if (n < 0) {
-             perror("tftp: recvfrom");
-+            err = EX_OSERR;
-             goto abort;
-         }
-         if (n < 2)
-@@ -185,12 +192,14 @@ void tftp_sendfile(int fd, const char *name, const char *mode,
-         ap_block = ntohs(rp->th_block);
-         if (ap_opcode == ERROR) {
-             printf("Error code %d: %s\n", ap_block, rp->th_msg);
-+            err = EX_PROTOCOL;
-             goto abort;
-         }
-         if (requested_options && ap_opcode == OACK) {
-             if (!parse_oack(rp, n, blocksize, requested_window,
-                             &negotiated_block, &negotiated_window)) {
-                 nak(EOPTNEG, "Invalid option response");
-+                err = EX_PROTOCOL;
-                 goto abort;
-             }
-             segsize = (int)negotiated_block;
-@@ -210,6 +219,7 @@ void tftp_sendfile(int fd, const char *name, const char *mode,
-     io = tftp_io_reader_start(file, convert, window, window, segsize, false);
-     if (!io) {
-         nak(errno + 100, NULL);
-+        err = EX_OSERR;
-         goto abort;
-     }
- 
-@@ -231,17 +241,21 @@ void tftp_sendfile(int fd, const char *name, const char *mode,
-     switch (result.status) {
-     case TFTP_XFER_READ_ERROR:
-         nak(result.error + 100, NULL);
-+        err = EX_OSERR;
-         break;
-     case TFTP_XFER_SEND_ERROR:
-         errno = result.error;
-         perror("tftp: sendto");
-+        err = EX_OSERR;
-         break;
-     case TFTP_XFER_RECV_ERROR:
-         errno = result.error;
-         perror("tftp: recvfrom");
-+        err = EX_OSERR;
-         break;
-     case TFTP_XFER_PEER_ERROR:
-         printf("Error code %d: %s\n", ntohs(ap->th_code), ap->th_msg);
-+        err = EX_PROTOCOL;
-         break;
-     default:
-         break;
-@@ -256,13 +270,14 @@ void tftp_sendfile(int fd, const char *name, const char *mode,
-     stopclock();
-     if (amount > 0)
-         printstats("Sent", amount);
-+    return err;
- }
- 
- /*
-  * Receive a file.
-  */
--void tftp_recvfile(int fd, const char *name, const char *mode,
--                   unsigned int requested_window)
-+int tftp_recvfile(int fd, const char *name, const char *mode,
-+                  unsigned int requested_window)
- {
-     struct tftphdr *ap;
-     union sock_addr from;
-@@ -276,6 +291,7 @@ void tftp_recvfile(int fd, const char *name, const char *mode,
-     volatile int initial_reply_len = 0;
-     volatile int initial_packet_len = -1;
-     int n, size;
-+    volatile int err = 0;
-     bool convert = !strcmp(mode, "netascii");
-     unsigned int window;
-     unsigned int negotiated_block, negotiated_window;
-@@ -288,14 +304,18 @@ void tftp_recvfile(int fd, const char *name, const char *mode,
- 
-     startclock();
-     file = fdopen(fd, convert ? "wt" : "wb");
--    if (!file)
-+    if (!file) {
-+        close(fd);
-+        err = EX_OSERR;
-         goto abort;
-+    }
-     initial_packet = xmalloc(TFTP_XFER_MAX_PACKET_SIZE);
-     ap = (struct tftphdr *)ackbuf;
-     size = makerequest(RRQ, name, ap, mode, blocksize, requested_window,
-                        sizeof(ackbuf));
-     if (size < 0) {
-         fprintf(stderr, "tftp: %s: %s\n", name, strerror(errno));
-+        err = EX_OSERR;
-         goto abort;
-     }
-     tftp_signal(SIGALRM, timer, 0);
-@@ -308,6 +328,7 @@ void tftp_recvfile(int fd, const char *name, const char *mode,
-             tpacket("sent", ap, size);
-         if (sendto(f, ap, size, 0, &peeraddr.sa, SOCKLEN(&peeraddr)) != size) {
-             perror("tftp: sendto");
-+            err = EX_OSERR;
-             goto abort;
-         }
-         r_timeout = timeout;
-@@ -316,6 +337,7 @@ void tftp_recvfile(int fd, const char *name, const char *mode,
-                              &from, &r_timeout);
-         if (n < 0) {
-             perror("tftp: recvfrom");
-+            err = EX_OSERR;
-             goto abort;
-         }
-         if (n < 2)
-@@ -326,12 +348,14 @@ void tftp_recvfile(int fd, const char *name, const char *mode,
-         if (opcode == ERROR) {
-             printf("Error code %d: %s\n",
-                    ntohs(initial_packet->th_code), initial_packet->th_msg);
-+            err = EX_PROTOCOL;
-             goto abort;
-         }
-         if (requested_options && opcode == OACK) {
-             if (!parse_oack(initial_packet, n, blocksize, requested_window,
-                             &negotiated_block, &negotiated_window)) {
-                 nak(EOPTNEG, "Invalid option response");
-+                err = EX_PROTOCOL;
-                 goto abort;
-             }
-             segsize = (int)negotiated_block;
-@@ -357,6 +381,7 @@ void tftp_recvfile(int fd, const char *name, const char *mode,
-     io = tftp_io_writer_start(file, convert, window, segsize, false);
-     if (!io) {
-         nak(errno + 100, NULL);
-+        err = EX_OSERR;
-         goto abort;
-     }
- 
-@@ -383,21 +408,26 @@ void tftp_recvfile(int fd, const char *name, const char *mode,
-     switch (result.status) {
-     case TFTP_XFER_BAD_DATA:
-         nak(EBADOP, "Data packet too large");
-+        err = EX_PROTOCOL;
-         break;
-     case TFTP_XFER_WRITE_ERROR:
-         nak(result.error + 100, NULL);
-+        err = EX_OSERR;
-         break;
-     case TFTP_XFER_SEND_ERROR:
-         errno = result.error;
-         perror("tftp: sendto");
-+        err = EX_OSERR;
-         break;
-     case TFTP_XFER_RECV_ERROR:
-         errno = result.error;
-         perror("tftp: recvfrom");
-+        err = EX_OSERR;
-         break;
-     case TFTP_XFER_PEER_ERROR:
-         printf("Error code %d: %s\n", ntohs(result.packet->th_code),
-                result.packet->th_msg);
-+        err = EX_PROTOCOL;
-         break;
-     default:
-         break;
-@@ -416,6 +446,7 @@ void tftp_recvfile(int fd, const char *name, const char *mode,
-     stopclock();
-     if (amount > 0)
-         printstats("Received", amount);
-+    return err;
- }
- 
- static int
--- 
-2.55.0
-

diff --git a/tftp.service b/tftp.service
index d3e080b..67a6f28 100644
--- a/tftp.service
+++ b/tftp.service
@@ -2,9 +2,31 @@
 Description=Tftp Server
 Requires=tftp.socket
 Documentation=man:in.tftpd
+After=network-online.target
 
 [Service]
-ExecStart=/usr/sbin/in.tftpd -v --user tftpd --systemd -s /var/lib/tftpboot --blocksize 1468 --windowsize 64 --map-file /etc/tftp/map-file
+# Network tweakables
+Environment=TFTPD_NET_OPTS="--blocksize mtu --windowsize 64"
+Environment=TFTPD_ACCESS_OPTS="--permissive --read-only"
+# For a read/write server enable/tweak this
+# Environment=TFTPD_ACCESS_OPTS="--permissive --create --umask 022 --max-upload 1048576"
+# ReadWritePaths=%S/tftpboot
+
+User=tftpd
+ExecStart=/usr/sbin/in.tftpd -v --map-file %E/tftp/map-file $TFTPD_NET_OPTS $TFTPD_ACCESS_OPTS --systemd --jail %S/tftpboot
+ProtectHome=yes
+ProtectSystem=strict
+ProtectHostname=yes
+ProtectClock=yes
+ProtectKernelTunables=yes
+ProtectKernelModules=yes
+ProtectKernelLogs=yes
+ProtectControlGroups=yes
+PrivateDevices=yes
+PrivateTmp=yes
+NoNewPrivileges=yes
+RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
+SystemCallArchitectures=native
 
 [Install]
 Also=tftp.socket

diff --git a/tftp.socket b/tftp.socket
index 3bb6622..465caaf 100644
--- a/tftp.socket
+++ b/tftp.socket
@@ -3,6 +3,7 @@ Description=Tftp Server Activation Socket
 PartOf=tftp.service
 
 [Socket]
+FreeBind=yes
 ListenDatagram=69
 
 [Install]

diff --git a/tftp.spec b/tftp.spec
index 0dfe0df..d18e12e 100644
--- a/tftp.spec
+++ b/tftp.spec
@@ -1,10 +1,11 @@
 Summary: The client for the Trivial File Transfer Protocol (TFTP)
 Name: tftp
-Version: 6.1
-Release: 4%{?dist}
+Version: 7.2
+Release: 1%{?dist}
 License: BSD-4-Clause-UC
 URL: http://www.kernel.org/pub/software/network/tftp/
-Source0: https://www.kernel.org/pub/software/network/tftp/tftp-hpa-%{version}.tar.gz
+
+Source0: https://www.kernel.org/pub/software/network/tftp/tftp-hpa-%{version}.tar.xz
 Source1: https://www.kernel.org/pub/software/network/tftp/tftp-hpa-%{version}.tar.sign
 # gpg --keyserver pgp.mit.edu --recv-key 6D0107BC69EE5A274FD9B60C2DB3C3321B6DDF86
 # gpg --output hpa.gpg --armor --export hpa@zytor.com
@@ -14,15 +15,16 @@ Source4: tftp.service
 Source5: tftp-server-sysusers.conf
 Source6: tftp-server-tmpfiles.conf
 
-# Upstreamed patches
-# https://github.com/hpax/tftp-hpa/commit/ab93a245747ada8948f4594de54a4b2b30c4b462
-Patch: tftp-enhanced-logging.patch
-# https://github.com/hpax/tftp-hpa/commit/43a86cbcbfd38e992d6f5d5009eea60f436711e4
-Patch: tftp-hpa-5.2-osh.patch
-# https://github.com/hpax/tftp-hpa/commit/85b246c2bb3887ec19367841b342312f89090aaf
-Patch: tftp-hpa-5.3-tftp-exit-code-cmdmode.patch
+# Post-release patches from upstream (mainly affects the test script only)
+Patch: 0001-tftp-add-verbosity-level-remove-mention-of-verbose-l.patch
+Patch: 0002-tests-control-the-verbosity-of-test-tftp.sh.patch
+Patch: 0003-tests-redirect-tftpd-log-output-to-a-file.patch
+Patch: 0004-tests-allow-the-user-to-set-output-verbosity-control.patch
+Patch: 0005-tftp-fix-type-of-r_timeout.patch
 
 # Downstream-only patches
+# https://github.com/hpax/tftp-hpa/pull/11
+Patch: 0006-tftp-fix-type-of-r_timeout-2.patch
 Patch: tftp-fedora-tftpboot.patch
 
 BuildRequires: bc
@@ -54,7 +56,7 @@ enabled unless it is expressly needed.  The TFTP server is run by using
 systemd socket activation, and is disabled by default.
 
 %prep
-gzip -cd '%{SOURCE0}' > 'tftp-hpa-%{version}.tar'
+xz -cd '%{SOURCE0}' > 'tftp-hpa-%{version}.tar'
 %{openpgpverify} --keyring='%{SOURCE2}' --signature='%{SOURCE1}' --data='tftp-hpa-%{version}.tar'
 %autosetup -p1 -n tftp-hpa-%{version}
 
@@ -75,7 +77,7 @@ mkdir -p %{buildroot}%{_sysconfdir}/tftp
 echo '# See tftpd(8) for the definition of remap rules' > %{buildroot}%{_sysconfdir}/%{name}/map-file
 
 %check
-tests/test-tftp.sh
+PCAP=0 tests/test-tftp.sh -q
 
 %post server
 %systemd_post tftp.socket
@@ -106,6 +108,12 @@ tests/test-tftp.sh
 %{_unitdir}/tftp.socket
 
 %changelog
+* Fri Oct 23 2026 Lukáš Zaoral <lzaoral@redhat.com> - 7.2-1
+- rebase to 7.2 (rhbz#2537118)
+- sync with upstream systemd unit files
+- kudos to H. Peter Anvin for the SRPM patch!
+- change --blksize 1468 to --blksize mtu in tftp.service
+
 * Tue Oct 06 2026 Andrew Naessens <anaessen@redhat.com> - 6.1-4
 - Use openpgpverify
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-23 10:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-23 10:05 [rpms/tftp] rawhide: rebase to 7.2 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox