added my Recipes

This commit is contained in:
2024-07-11 14:16:35 +02:00
parent 38bc4f53ac
commit 09b621d929
7118 changed files with 525762 additions and 3 deletions

View File

@@ -0,0 +1,62 @@
From 941038fc05be21202cab7a7a9434097fb55ecbe0 Mon Sep 17 00:00:00 2001
From: Thorsten Glaser <tg@mirbsd.de>
Date: Thu, 31 Jul 2014 16:29:41 +0930
Subject: [PATCH] __progname[] is provided by libc
Rename local variable to tftpd_progname to avoid a clash with glibc
global symbols and work around Debian bug #519006 (Closes: #564052).
[ hpa: specifically, double-underscore symbols in C are reserved for
the implementation, i.e. compiler/libc. ]
Signed-off-by: Ron Lee <ron@debian.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
tftpd/tftpd.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
index e247b97..5fec7bf 100644
--- a/tftpd/tftpd.c
+++ b/tftpd/tftpd.c
@@ -76,7 +76,7 @@ static int ai_fam = AF_INET;
#define TRIES 6 /* Number of attempts to send each packet */
#define TIMEOUT_LIMIT ((1 << TRIES)-1)
-const char *__progname;
+const char *tftpd_progname;
static int peer;
static unsigned long timeout = TIMEOUT; /* Current timeout value */
static unsigned long rexmtval = TIMEOUT; /* Basic timeout value */
@@ -395,9 +395,9 @@ int main(int argc, char **argv)
/* basename() is way too much of a pain from a portability standpoint */
p = strrchr(argv[0], '/');
- __progname = (p && p[1]) ? p + 1 : argv[0];
+ tftpd_progname = (p && p[1]) ? p + 1 : argv[0];
- openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
+ openlog(tftpd_progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
srand(time(NULL) ^ getpid());
@@ -946,14 +946,14 @@ int main(int argc, char **argv)
syslog daemon gets restarted by the time we get here. */
if (secure && standalone) {
closelog();
- openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
+ openlog(tftpd_progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
}
#ifdef HAVE_TCPWRAPPERS
/* Verify if this was a legal request for us. This has to be
done before the chroot, while /etc is still accessible. */
request_init(&wrap_request,
- RQ_DAEMON, __progname,
+ RQ_DAEMON, tftpd_progname,
RQ_FILE, fd,
RQ_CLIENT_SIN, &from, RQ_SERVER_SIN, &myaddr, 0);
sock_methods(&wrap_request);
--
2.14.1

View File

@@ -0,0 +1,30 @@
From 2a12174a5059e84d4ff6fad8f983a4d0f2127e73 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 12 Aug 2020 12:17:31 -0700
Subject: [PATCH] tftp: Mark toplevel definition as external
Fixes
multiple definition of `toplevel'; tftp.o:/usr/src/debug/tftp-hpa/5.2-r0/tftp-hpa-5.2/tftp/tftp.c:51: first defined here
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
tftp/tftp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tftp/tftp.c b/tftp/tftp.c
index 9d15022..109848c 100644
--- a/tftp/tftp.c
+++ b/tftp/tftp.c
@@ -48,7 +48,7 @@ extern int maxtimeout;
#define PKTSIZE SEGSIZE+4
char ackbuf[PKTSIZE];
int timeout;
-sigjmp_buf toplevel;
+extern sigjmp_buf toplevel;
sigjmp_buf timeoutbuf;
static void nak(int, const char *);
--
2.28.0

View File

@@ -0,0 +1,39 @@
From e9ed48d91642d384ce07cbb9bec788f07fc6354c Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 6 Sep 2022 14:51:42 -0700
Subject: [PATCH] tftp: Remove double inclusion of signal.h
Undefine __USE_XOPEN2K8 so we can get bsd_signal definition from system
headers
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
config.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/config.h b/config.h
index 3ff2915..ae1a14b 100644
--- a/config.h
+++ b/config.h
@@ -93,7 +93,6 @@
#endif
#include <errno.h>
-#include <signal.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
@@ -296,6 +295,9 @@ char *xstrdup(const char *);
#ifndef HAVE_BSD_SIGNAL
void (*bsd_signal(int, void (*)(int))) (int);
+#else
+#undef __USE_XOPEN2K8
+#include <signal.h>
#endif
#ifndef HAVE_DUP2
int dup2(int, int);
--
2.37.3

View File

@@ -0,0 +1,81 @@
From bd5773947af5ca80ca546ad5625818fc912bdd60 Mon Sep 17 00:00:00 2001
From: "Roy.Li" <rongqing.li@windriver.com>
Date: Thu, 22 Aug 2013 08:56:09 +0800
Subject: [PATCH] tftp-hpa: add error check for disk filled up
Upstream-Status: Pending [Sent to http://www.syslinux.org/archives/2013-August/020765.html]
Add error check when the write-buffer is finally flushed to the file,
the caller can detect if the disk filled up (or had an i/o error) and
return a NOSAPCE nak to the other side.
Signed-off-by: Ming Liu <ming.liu@windriver.com>
Signed-off-by: Roy.Li <rongqing.li@windriver.com>
---
common/tftpsubs.c | 8 +++++---
tftpd/tftpd.c | 12 ++++++++++--
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/common/tftpsubs.c b/common/tftpsubs.c
index 8c999f6..b4d4ffe 100644
--- a/common/tftpsubs.c
+++ b/common/tftpsubs.c
@@ -206,20 +206,22 @@ int write_behind(FILE * file, int convert)
p = buf;
ct = count;
+ count = 0;
while (ct--) { /* loop over the buffer */
c = *p++; /* pick up a character */
if (prevchar == '\r') { /* if prev char was cr */
if (c == '\n') /* if have cr,lf then just */
- fseek(file, -1, 1); /* smash lf on top of the cr */
+ count = count - 1;
else if (c == '\0') /* if have cr,nul then */
goto skipit; /* just skip over the putc */
/* else just fall through and allow it */
}
- putc(c, file);
+ buf[count] = c;
+ count ++;
skipit:
prevchar = c;
}
- return count;
+ return write(fileno(file), buf, count);
}
/* When an error has occurred, it is possible that the two sides
diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
index 1873e70..c2adbda 100644
--- a/tftpd/tftpd.c
+++ b/tftpd/tftpd.c
@@ -1681,7 +1681,11 @@ static void tftp_recvfile(const struct formats *pf, struct tftphdr *oap, int oac
syslog(LOG_WARNING, "tftpd: write(ack): %m");
goto abort;
}
- write_behind(file, pf->f_convert);
+ if(write_behind(file, pf->f_convert) < 0) {
+ nak(ENOSPACE, NULL);
+ (void)fclose(file);
+ goto abort;
+ }
for (;;) {
n = recv_time(peer, dp, PKTSIZE, 0, &r_timeout);
if (n < 0) { /* really? */
@@ -1712,7 +1716,11 @@ static void tftp_recvfile(const struct formats *pf, struct tftphdr *oap, int oac
goto abort;
}
} while (size == segsize);
- write_behind(file, pf->f_convert);
+ if(write_behind(file, pf->f_convert) < 0) {
+ nak(ENOSPACE, NULL);
+ (void)fclose(file);
+ goto abort;
+ }
(void)fclose(file); /* close data file */
ap->th_opcode = htons((u_short) ACK); /* send the "final" ack */
--
1.7.10.4

View File

@@ -0,0 +1,3 @@
#Defaults for tftpd-hpa
RUN_DAEMON="yes"
OPTIONS="-l -s /var/lib/tftpboot"

View File

@@ -0,0 +1,39 @@
[PATCH] fix the empty file writting
Upstream-Status: Pending
With the feature that checking the disk filled up, the return
value of function write_behind was checked and used to detect
the disk status. While for empty file, without data being
written, this function will return -1 thus the disk filled up
error was miss-raised.
make write_behind to return 0 if written file is empty, to fix
the this bug.
Signed-off-by: Roy.Li <rongqing.li@windriver.com>
---
common/tftpsubs.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/common/tftpsubs.c b/common/tftpsubs.c
index b4ea3f2..9f6cafc 100644
--- a/common/tftpsubs.c
+++ b/common/tftpsubs.c
@@ -198,9 +198,12 @@ int write_behind(FILE * file, int convert)
nextone = !nextone; /* incr for next time */
buf = dp->th_data;
- if (count <= 0)
+ if (count < 0)
return -1; /* nak logic? */
+ if (count == 0)
+ return 0;
+
if (convert == 0)
return write(fileno(file), buf, count);
--
1.9.1

View File

@@ -0,0 +1,105 @@
#! /bin/sh
#
# Author: Jaakko Niemi <liiwi@iki.fi>
# Modified from skeleton file in sarge
### BEGIN INIT INFO
# Provides: tftp-hpa
# Required-Start: $local_fs $remote_fs $syslog $network
# Required-Stop: $local_fs $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: HPA's tftp client
# Description: tftp server to allow booting clients which support
# the PXE protocol.
### END INIT INFO
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="HPA's tftpd"
NAME=in.tftpd-hpa
SCRIPTNAME=/etc/init.d/tftpd-hpa
# Read config file if it is present.
if [ -r /etc/default/tftpd-hpa ]
then
. /etc/default/tftpd-hpa
fi
DAEMON=/usr/sbin/$NAME
PIDFILE=/var/run/$NAME.pid
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
if [ "$RUN_DAEMON" != "yes" ] ; then
echo "tftpd-hpa disabled in /etc/default/tftpd-hpa"
exit 0
fi
#
# Function that starts the daemon/service.
#
d_start() {
start-stop-daemon --start --quiet --exec $DAEMON -- $OPTIONS
}
#
# Function that stops the daemon/service.
#
d_stop() {
start-stop-daemon --stop --quiet --name $NAME
}
#
# Function that sends a SIGHUP to the daemon/service.
#
d_reload() {
start-stop-daemon --stop --quiet --name $NAME --signal 1
}
case "$1" in
start)
echo "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo "Stopping $DESC: $NAME"
d_stop
echo "."
;;
#reload)
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
# If the daemon responds to changes in its config file
# directly anyway, make this an "exit 0".
#
# echo -n "Reloading $DESC configuration..."
# d_reload
# echo "done."
#;;
restart|force-reload)
#
# If the "reload" option is implemented, move the "force-reload"
# option to the "reload" entry above. If not, "force-reload" is
# just the same as "restart".
#
echo "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
# echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0

View File

@@ -0,0 +1,25 @@
Patch originally from Fedora
http://pkgs.fedoraproject.org/cgit/tftp.git/
Upstream-Status: Pending
diff -up tftp-hpa-0.49/tftpd/remap.c.zero tftp-hpa-0.49/tftpd/remap.c
--- tftp-hpa-0.49/tftpd/remap.c.zero 2008-10-20 18:08:31.000000000 -0400
+++ tftp-hpa-0.49/tftpd/remap.c 2008-11-25 11:41:09.000000000 -0500
@@ -286,6 +286,7 @@ struct rule *parserulefile(FILE * f)
int lineno = 0;
int err = 0;
+ memset(this_rule, '\0', sizeof(struct rule));
while (lineno++, fgets(line, MAXLINE, f)) {
rv = parseline(line, this_rule, lineno);
if (rv < 0)
@@ -294,6 +295,7 @@ struct rule *parserulefile(FILE * f)
*last_rule = this_rule;
last_rule = &this_rule->next;
this_rule = tfmalloc(sizeof(struct rule));
+ memset(this_rule, '\0', sizeof(struct rule));
}
}

View File

@@ -0,0 +1,60 @@
Patch originally from Fedora
http://pkgs.fedoraproject.org/cgit/tftp.git/
Upstream-Status: Pending
diff -up tftp-hpa-0.48/tftp-xinetd.tftpboot tftp-hpa-0.48/tftp-xinetd
--- tftp-hpa-0.48/tftp-xinetd.tftpboot 2007-01-31 00:51:05.000000000 +0100
+++ tftp-hpa-0.48/tftp-xinetd 2008-05-20 12:05:53.000000000 +0200
@@ -10,7 +10,7 @@ service tftp
wait = yes
user = root
server = /usr/sbin/in.tftpd
- server_args = -s /tftpboot
+ server_args = -s /var/lib/tftpboot
disable = yes
per_source = 11
cps = 100 2
diff -up tftp-hpa-0.48/README.security.tftpboot tftp-hpa-0.48/README.security
--- tftp-hpa-0.48/README.security.tftpboot 2008-05-29 17:36:32.000000000 +0200
+++ tftp-hpa-0.48/README.security 2008-05-29 17:37:21.000000000 +0200
@@ -17,10 +17,10 @@ probably the following:
1. Create a separate "tftpd" user and group only used for tftpd;
2. Have all your boot files in a single directory tree (usually called
- /tftpboot).
-3. Specify "-p -u tftpd -s /tftpboot" on the tftpd command line; if
+ /var/lib/tftpboot).
+3. Specify "-p -u tftpd -s /var/lib/tftpboot" on the tftpd command line; if
you want clients to be able to create files use
- "-p -c -U 002 -u tftpd -s /tftpboot" (replace 002 with whatever
+ "-p -c -U 002 -u tftpd -s /var/lib/tftpboot" (replace 002 with whatever
umask is appropriate for your setup.)
=======================================
@@ -40,12 +40,12 @@ directly. Thus, if your /etc/inetd.conf
line):
tftp dgram udp wait root /usr/sbin/tcpd
-/usr/sbin/in.tftpd -s /tftpboot -r blksize
+/usr/sbin/in.tftpd -s /var/lib/tftpboot -r blksize
... it's better to change to ...
tftp dgram udp wait root /usr/sbin/in.tftpd
-in.tftpd -s /tftpboot -r blksize
+in.tftpd -s /var/lib/tftpboot -r blksize
You should make sure that you are using "wait" option in tftpd; you
also need to have tftpd spawned as root in order for chroot (-s) to
diff -up tftp-hpa-0.48/tftpd/sample.rules.tftpboot tftp-hpa-0.48/tftpd/sample.rules
--- tftp-hpa-0.48/tftpd/sample.rules.tftpboot 2008-05-29 17:38:46.000000000 +0200
+++ tftp-hpa-0.48/tftpd/sample.rules 2008-05-29 17:38:05.000000000 +0200
@@ -30,5 +30,5 @@ rg \\ / # Convert backslashes to slash
rg \# @ # Convert hash marks to @ signs
rg /../ /..no../ # Convert /../ to /..no../
e ^ok/ # These are always ok
-r ^[^/] /tftpboot/\0 # Convert non-absolute files
+r ^[^/] /var/lib/tftpboot/\0 # Convert non-absolute files
a \.pvt$ # Reject requests for private files

View File

@@ -0,0 +1,21 @@
Patch originally from Fedora
http://pkgs.fedoraproject.org/cgit/tftp.git/
Upstream-Status: Pending
diff -up tftp-hpa-0.49/tftpd/tftpd.c.chk_retcodes tftp-hpa-0.49/tftpd/tftpd.c
--- tftp-hpa-0.49/tftpd/tftpd.c.chk_retcodes 2009-01-15 15:28:50.000000000 +0100
+++ tftp-hpa-0.49/tftpd/tftpd.c 2009-01-15 15:31:36.000000000 +0100
@@ -932,7 +932,10 @@ int main(int argc, char **argv)
exit(EX_OSERR);
}
#ifdef __CYGWIN__
- chdir("/"); /* Cygwin chroot() bug workaround */
+ if (chdir("/") < 0) { /* Cygwin chroot() bug workaround */
+ syslog(LOG_ERR, "chroot: %m");
+ exit(EX_OSERR);
+ }
#endif
}
#ifdef HAVE_SETREGID

View File

@@ -0,0 +1,165 @@
Patch originally from Fedora
http://pkgs.fedoraproject.org/cgit/tftp.git/
Upstream-Status: Pending
diff -up tftp-hpa-0.49/config.h.cmd_arg tftp-hpa-0.49/config.h
--- tftp-hpa-0.49/config.h.cmd_arg 2010-04-19 15:29:10.567331454 +0200
+++ tftp-hpa-0.49/config.h 2010-04-20 07:33:03.133232772 +0200
@@ -291,6 +291,7 @@ typedef int socklen_t;
/* Prototypes for libxtra functions */
void *xmalloc(size_t);
+void *xrealloc(void *, size_t);
char *xstrdup(const char *);
#ifndef HAVE_BSD_SIGNAL
diff -up tftp-hpa-0.49/configure.in.cmd_arg tftp-hpa-0.49/configure.in
--- tftp-hpa-0.49/configure.in.cmd_arg 2008-10-21 00:08:31.000000000 +0200
+++ tftp-hpa-0.49/configure.in 2010-04-19 11:05:12.387340698 +0200
@@ -152,6 +152,7 @@ OBJROOT=`pwd`
XTRA=false
PA_SEARCH_LIBS_AND_ADD(xmalloc, iberty)
+PA_SEARCH_LIBS_AND_ADD(xrealloc, iberty)
PA_SEARCH_LIBS_AND_ADD(xstrdup, iberty)
PA_SEARCH_LIBS_AND_ADD(bsd_signal, bsd, bsdsignal)
PA_SEARCH_LIBS_AND_ADD(getopt_long, getopt, getopt_long)
diff -up tftp-hpa-0.49/lib/xrealloc.c.cmd_arg tftp-hpa-0.49/lib/xrealloc.c
--- tftp-hpa-0.49/lib/xrealloc.c.cmd_arg 2010-04-19 11:05:12.387340698 +0200
+++ tftp-hpa-0.49/lib/xrealloc.c 2010-04-19 11:05:12.387340698 +0200
@@ -0,0 +1,20 @@
+/*
+ * xrealloc.c
+ *
+ * Simple error-checking version of realloc()
+ *
+ */
+
+#include "config.h"
+
+void *xrealloc(void *ptr, size_t size)
+{
+ void *p = realloc(ptr, size);
+
+ if (!p) {
+ fprintf(stderr, "Out of memory!\n");
+ exit(128);
+ }
+
+ return p;
+}
diff -up tftp-hpa-0.49/tftp/main.c.cmd_arg tftp-hpa-0.49/tftp/main.c
--- tftp-hpa-0.49/tftp/main.c.cmd_arg 2008-10-21 00:08:31.000000000 +0200
+++ tftp-hpa-0.49/tftp/main.c 2010-04-19 11:05:12.389329337 +0200
@@ -89,11 +89,14 @@ int connected;
const struct modes *mode;
#ifdef WITH_READLINE
char *line = NULL;
+char *remote_pth = NULL;
#else
char line[LBUFLEN];
+char remote_pth[LBUFLEN];
#endif
int margc;
-char *margv[20];
+char **margv;
+int sizeof_margv=0;
const char *prompt = "tftp> ";
sigjmp_buf toplevel;
void intr(int);
@@ -379,6 +382,10 @@ static void getmoreargs(const char *part
free(line);
line = NULL;
}
+ if (remote_pth) {
+ free(remote_pth);
+ remote_pth = NULL;
+ }
line = xmalloc(len + elen + 1);
strcpy(line, partial);
strcpy(line + len, eline);
@@ -535,6 +542,7 @@ void put(int argc, char *argv[])
int fd;
int n, err;
char *cp, *targ;
+ long dirlen, namelen, lastlen=0;
if (argc < 2) {
getmoreargs("send ", "(file) ");
@@ -588,9 +596,22 @@ void put(int argc, char *argv[])
}
/* this assumes the target is a directory */
/* on a remote unix system. hmmmm. */
- cp = strchr(targ, '\0');
- *cp++ = '/';
+ dirlen = strlen(targ)+1;
+#ifdef WITH_READLINE
+ remote_pth = xmalloc(dirlen+1);
+#endif
+ strcpy(remote_pth, targ);
+ remote_pth[dirlen-1] = '/';
+ cp = remote_pth + dirlen;
for (n = 1; n < argc - 1; n++) {
+#ifdef WITH_READLINE
+ namelen = strlen(tail(argv[n])) + 1;
+ if (namelen > lastlen) {
+ remote_pth = xrealloc(remote_pth, dirlen + namelen + 1);
+ cp = remote_pth + dirlen;
+ lastlen = namelen;
+ }
+#endif
strcpy(cp, tail(argv[n]));
fd = open(argv[n], O_RDONLY | mode->m_openflags);
if (fd < 0) {
@@ -600,9 +621,9 @@ void put(int argc, char *argv[])
}
if (verbose)
printf("putting %s to %s:%s [%s]\n",
- argv[n], hostname, targ, mode->m_mode);
+ argv[n], hostname, remote_pth, mode->m_mode);
sa_set_port(&peeraddr, port);
- tftp_sendfile(fd, targ, mode->m_mode);
+ tftp_sendfile(fd, remote_pth, mode->m_mode);
}
}
@@ -801,6 +822,10 @@ static void command(void)
free(line);
line = NULL;
}
+ if (remote_pth) {
+ free(remote_pth);
+ remote_pth = NULL;
+ }
line = readline(prompt);
if (!line)
exit(0); /* EOF */
@@ -872,7 +897,13 @@ struct cmd *getcmd(char *name)
static void makeargv(void)
{
char *cp;
- char **argp = margv;
+ char **argp;
+
+ if (!sizeof_margv) {
+ sizeof_margv = 20;
+ margv = xmalloc(sizeof_margv * sizeof(char *));
+ }
+ argp = margv;
margc = 0;
for (cp = line; *cp;) {
@@ -882,6 +913,11 @@ static void makeargv(void)
break;
*argp++ = cp;
margc += 1;
+ if (margc == sizeof_margv) {
+ sizeof_margv += 20;
+ margv = xrealloc(margv, sizeof_margv * sizeof(char *));
+ argp = margv + margc;
+ }
while (*cp != '\0' && !isspace(*cp))
cp++;
if (*cp == '\0')

View File

@@ -0,0 +1,24 @@
Patch originally from Fedora
http://pkgs.fedoraproject.org/cgit/tftp.git/
Upstream-Status: Pending
diff -up tftp-hpa-0.49/tftpd/tftpd.c.tzfix tftp-hpa-0.49/tftpd/tftpd.c
--- tftp-hpa-0.49/tftpd/tftpd.c.tzfix 2008-10-20 18:08:31.000000000 -0400
+++ tftp-hpa-0.49/tftpd/tftpd.c 2008-11-25 11:45:27.000000000 -0500
@@ -350,6 +350,14 @@ int main(int argc, char **argv)
const char *pidfile = NULL;
u_short tp_opcode;
+ time_t my_time = 0;
+ struct tm* p_tm;
+ char envtz[10];
+ my_time = time(NULL);
+ p_tm = localtime(&my_time);
+ snprintf(envtz, sizeof(envtz) - 1, "UTC%+d", (p_tm->tm_gmtoff * -1)/3600);
+ setenv("TZ", envtz, 0);
+
/* basename() is way too much of a pain from a portability standpoint */
p = strrchr(argv[0], '/');

View File

@@ -0,0 +1,32 @@
Patch originally from Fedora
http://pkgs.fedoraproject.org/cgit/tftp.git/
Upstream-Status: Pending
diff -urN tftp-hpa-0.49.orig/tftp/tftp.c tftp-hpa-0.49/tftp/tftp.c
--- tftp-hpa-0.49.orig/tftp/tftp.c 2008-10-20 18:08:31.000000000 -0400
+++ tftp-hpa-0.49/tftp/tftp.c 2009-08-05 09:47:18.072585848 -0400
@@ -279,15 +279,16 @@
struct tftphdr *tp, const char *mode)
{
char *cp;
+ size_t len;
tp->th_opcode = htons((u_short) request);
cp = (char *)&(tp->th_stuff);
- strcpy(cp, name);
- cp += strlen(name);
- *cp++ = '\0';
- strcpy(cp, mode);
- cp += strlen(mode);
- *cp++ = '\0';
+ len = strlen(name) + 1;
+ memcpy(cp, name, len);
+ cp += len;
+ len = strlen(mode) + 1;
+ memcpy(cp, mode, len);
+ cp += len;
return (cp - (char *)tp);
}

View File

@@ -0,0 +1,20 @@
Patch originally from Fedora
http://pkgs.fedoraproject.org/cgit/tftp.git/
Upstream-Status: Pending
diff -up tftp-hpa-0.49/tftp/tftp.c.stats tftp-hpa-0.49/tftp/tftp.c
--- tftp-hpa-0.49/tftp/tftp.c.stats 2011-01-03 15:38:34.217918067 +0100
+++ tftp-hpa-0.49/tftp/tftp.c 2011-01-03 15:38:37.498917014 +0100
@@ -400,8 +400,8 @@ static void printstats(const char *direc
{
double delta;
- delta = (tstop.tv_sec + (tstop.tv_usec / 100000.0)) -
- (tstart.tv_sec + (tstart.tv_usec / 100000.0));
+ delta = (tstop.tv_sec + (tstop.tv_usec / 1000000.0)) -
+ (tstart.tv_sec + (tstart.tv_usec / 1000000.0));
if (verbose) {
printf("%s %lu bytes in %.1f seconds", direction, amount, delta);
printf(" [%.0f bit/s]", (amount * 8.) / delta);

View File

@@ -0,0 +1,29 @@
Patch originally from Fedora
http://pkgs.fedoraproject.org/cgit/tftp.git/
Upstream-Status: Pending
diff -up tftp-hpa-5.2/tftpd/recvfrom.c.test tftp-hpa-5.2/tftpd/recvfrom.c
--- tftp-hpa-5.2/tftpd/recvfrom.c.test 2011-12-11 23:13:52.000000000 +0100
+++ tftp-hpa-5.2/tftpd/recvfrom.c 2012-01-04 10:05:17.852042256 +0100
@@ -149,16 +149,16 @@ myrecvfrom(int s, void *buf, int len, un
/* Try to enable getting the return address */
#ifdef IP_RECVDSTADDR
- if (from->sa_family == AF_INET)
+ if (from->sa_family == AF_INET || !from->sa_family)
setsockopt(s, IPPROTO_IP, IP_RECVDSTADDR, &on, sizeof(on));
#endif
#ifdef IP_PKTINFO
- if (from->sa_family == AF_INET)
+ if (from->sa_family == AF_INET || !from->sa_family)
setsockopt(s, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on));
#endif
#ifdef HAVE_IPV6
#ifdef IPV6_RECVPKTINFO
- if (from->sa_family == AF_INET6)
+ if (from->sa_family == AF_INET6 || !from->sa_family)
setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on));
#endif
#endif

View File

@@ -0,0 +1,38 @@
From 6ed1eb8829dee351b54e183bc42c007cb306aaa5 Mon Sep 17 00:00:00 2001
From: Zhang Xiao <xiao.zhang@windriver.com>
Date: Wed, 11 Jun 2014 14:01:16 +0800
Subject: [PATCH] tftp-hpa: bug fix on separated CR and LF
In ascii mode, if the CR and LF was separated into different transfer
blocks, LF will be just dropped instead of replacing the previous CR.
Add a checking on the first character to fix it.
Upstream-Status: Pending
Signed-off-by: Zhang Xiao <xiao.zhang@windriver.com>
---
common/tftpsubs.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/common/tftpsubs.c b/common/tftpsubs.c
index b4d4ffe..b4ea3f2 100644
--- a/common/tftpsubs.c
+++ b/common/tftpsubs.c
@@ -207,6 +207,14 @@ int write_behind(FILE * file, int convert)
p = buf;
ct = count;
count = 0;
+
+ /* Check the first character together with prevchar */
+ c = *p;
+ if ((prevchar == '\r') && (c == '\n')) {
+ lseek(fileno(file), -1, SEEK_CUR);
+ count++;
+ }
+
while (ct--) { /* loop over the buffer */
c = *p++; /* pick up a character */
if (prevchar == '\r') { /* if prev char was cr */
--
1.8.5.2.233.g932f7e4

View File

@@ -0,0 +1,18 @@
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd-hpa
server_args = -s /var/lib/tftpboot
disable = yes
per_source = 11
cps = 100 2
flags = IPv6
}

View File

@@ -0,0 +1,10 @@
[Unit]
Description=Tftp Server
Requires=tftpd-hpa.socket
[Service]
ExecStart=@SBINDIR@/in.tftpd-hpa -s /var/lib/tftpboot
StandardInput=socket
[Install]
Also=tftpd-hpa.socket

View File

@@ -0,0 +1,8 @@
[Unit]
Description=Tftp Server Activation Socket
[Socket]
ListenDatagram=69
[Install]
WantedBy=sockets.target

View File

@@ -0,0 +1,98 @@
SUMMARY = "Client for the Trivial File Transfer Protocol"
DESCRIPTION = \
"The Trivial File Transfer Protocol (TFTP) is normally used only for \
booting diskless workstations. The tftp package provides the user \
interface for TFTP, which allows users to transfer files to and from a \
remote machine. This program and TFTP provide very little security, \
and should not be enabled unless it is expressly needed."
DEPENDS = "tcp-wrappers readline"
SECTION = "net"
HOMEPAGE = "http://freecode.com/projects/tftp-hpa"
LICENSE = "BSD-4-Clause"
LIC_FILES_CHKSUM = "file://MCONFIG.in;beginline=1;endline=9;md5=c28ba5adb43041fae4629db05c83cbdd \
file://tftp/tftp.c;beginline=1;endline=32;md5=988c1cba99d70858a26cd877209857f4"
SRC_URI = "http://kernel.org/pub/software/network/tftp/tftp-hpa/tftp-hpa-${PV}.tar.bz2 \
file://tftp-0.40-remap.patch \
file://tftp-0.42-tftpboot.patch \
file://tftp-0.49-chk_retcodes.patch \
file://tftp-0.49-cmd_arg.patch \
file://tftp-hpa-0.39-tzfix.patch \
file://tftp-hpa-0.49-fortify-strcpy-crash.patch \
file://tftp-hpa-0.49-stats.patch \
file://tftp-hpa-5.2-pktinfo.patch \
file://default \
file://init \
file://add-error-check-for-disk-filled-up.patch \
file://tftp-hpa-bug-fix-on-separated-CR-and-LF.patch \
file://fix-writing-emtpy-file.patch \
file://0001-__progname-is-provided-by-libc.patch \
file://0001-tftp-Mark-toplevel-definition-as-external.patch \
file://0001-tftp-Remove-double-inclusion-of-signal.h.patch \
file://tftpd-hpa.socket \
file://tftpd-hpa.service \
"
SRC_URI[md5sum] = "46c9bd20bbffa62f79c958c7b99aac21"
SRC_URI[sha256sum] = "0a9f88d4c1c02687b4853b02ab5dd8779d4de4ffdb9b2e5c9332841304d1a269"
inherit autotools-brokensep update-rc.d update-alternatives systemd
export AR = "${HOST_PREFIX}ar cq"
EXTRA_OECONF += "--disable-option-checking"
PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}"
PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
# configure.in has errors
do_configure() {
oe_runconf
}
do_install() {
oe_runmake install INSTALLROOT=${D}
mv ${D}${bindir}/tftp ${D}${bindir}/tftp-hpa
mv ${D}${sbindir}/in.tftpd ${D}${sbindir}/in.tftpd-hpa
install -m 755 -d ${D}${localstatedir}/lib/tftpboot/
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/tftpd-hpa
sed -i 's!/usr/sbin/!${sbindir}/!g' ${D}${sysconfdir}/init.d/tftpd-hpa
sed -i 's!/etc/!${sysconfdir}/!g' ${D}${sysconfdir}/init.d/tftpd-hpa
sed -i 's!/var/!${localstatedir}/!g' ${D}${sysconfdir}/init.d/tftpd-hpa
sed -i 's!^PATH=.*!PATH=${base_sbindir}:${base_bindir}:${sbindir}:${bindir}!' ${D}${sysconfdir}/init.d/tftpd-hpa
install -d ${D}${sysconfdir}/default
install -m 0644 ${WORKDIR}/default ${D}${sysconfdir}/default/tftpd-hpa
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/tftpd-hpa.socket ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/tftpd-hpa.service ${D}${systemd_unitdir}/system
sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/tftpd-hpa.service
}
FILES:${PN} = "${bindir}"
PACKAGES += "tftp-hpa-server"
SUMMARY:tftp-hpa-server = "Server for the Trivial File Transfer Protocol"
FILES:tftp-hpa-server = "${sbindir} ${sysconfdir} ${localstatedir}"
CONFFILES:tftp-hpa-server = "${sysconfdir}/default/tftpd-hpa"
INITSCRIPT_PACKAGES = "tftp-hpa-server"
INITSCRIPT_NAME = "tftpd-hpa"
INITSCRIPT_PARAMS = "start 20 2 3 4 5 . stop 20 1 ."
ALTERNATIVE:${PN}-doc = "tftpd.8 tftp.1"
ALTERNATIVE_LINK_NAME[tftpd.8] = "${mandir}/man8/tftpd.8"
ALTERNATIVE_LINK_NAME[tftp.1] = "${mandir}/man1/tftp.1"
ALTERNATIVE:${PN} = "tftp"
ALTERNATIVE_TARGET[tftp] = "${bindir}/tftp-hpa"
ALTERNATIVE_PRIORITY = "100"
SYSTEMD_PACKAGES = "tftp-hpa-server"
SYSTEMD_SERVICE:tftp-hpa-server = "tftpd-hpa.socket tftpd-hpa.service"
SYSTEMD_AUTO_ENABLE:tftp-hpa-server = "enable"