tftp-hpa-trq/trq/trq.patch
2025-04-25 17:04:22 +03:00

126 lines
4.5 KiB
Diff

diff --git a/Makefile b/Makefile
index 9ff12d8..3d5c537 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
# You can do "make SUB=blah" to make only a few, or edit here, or both
# You can also run make directly in the subdirs you want.
-SUB = lib common tftp tftpd
+SUB = lib common tftpd
%.build: MCONFIG aconfig.h version.h
$(MAKE) -C $(patsubst %.build, %, $@)
@@ -17,7 +17,7 @@ SUB = lib common tftp tftpd
all: MCONFIG $(patsubst %, %.build, $(SUB))
-tftp.build: lib.build common.build
+#tftp.build: lib.build common.build
tftpd.build: lib.build common.build
install: MCONFIG $(patsubst %, %.install, $(SUB))
@@ -68,7 +68,7 @@ configure: configure.in aclocal.m4
autoconf
version.h: version
- echo \#define VERSION \"tftp-hpa `cat version`\" > version.h
+ echo \#define VERSION \"tftp-hpa-trq `cat version`\" > version.h
tftp.spec: tftp.spec.in version
sed -e "s/@@VERSION@@/`cat version`/g" < $< > $@ || rm -f $@
diff --git a/tftpd/Makefile b/tftpd/Makefile
index a05335d..8e80113 100644
--- a/tftpd/Makefile
+++ b/tftpd/Makefile
@@ -4,7 +4,7 @@ VERSION = $(shell cat ../version)
-include ../MCONFIG
include ../MRULES
-OBJS = tftpd.$(O) recvfrom.$(O) misc.$(O) $(TFTPDOBJS)
+OBJS = tftpd.$(O) trq.$(O) recvfrom.$(O) misc.$(O) $(TFTPDOBJS)
all: tftpd$(X) tftpd.8
@@ -18,9 +18,9 @@ tftpd.8: tftpd.8.in ../version
install: all
mkdir -p $(INSTALLROOT)$(SBINDIR) $(INSTALLROOT)$(MANDIR)/man8
- $(INSTALL_PROGRAM) tftpd$(X) $(INSTALLROOT)$(SBINDIR)/in.tftpd
- $(INSTALL_DATA) tftpd.8 $(INSTALLROOT)$(MANDIR)/man8/in.tftpd.8
- cd $(INSTALLROOT)$(MANDIR)/man8 && $(LN_S) -f in.tftpd.8 tftpd.8
+ $(INSTALL_PROGRAM) tftpd$(X) $(INSTALLROOT)$(SBINDIR)/in.tftpd-trq
+ $(INSTALL_DATA) tftpd.8 $(INSTALLROOT)$(MANDIR)/man8/in.tftpd-trq.8
+ cd $(INSTALLROOT)$(MANDIR)/man8 && $(LN_S) -f in.tftpd-trq.8 tftpd-trq.8
clean:
rm -f *.o *.obj *.exe tftpd tftpsubs.c tftpsubs.h tftpd.8
diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
index 1873e70..c3df336 100644
--- a/tftpd/tftpd.c
+++ b/tftpd/tftpd.c
@@ -52,6 +52,7 @@
#include "common/tftpsubs.h"
#include "recvfrom.h"
#include "remap.h"
+#include "trq.h"
#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h> /* Necessary for FIONBIO on Solaris */
@@ -1038,7 +1039,7 @@ int main(int argc, char **argv)
tp = (struct tftphdr *)buf;
tp_opcode = ntohs(tp->th_opcode);
- if (tp_opcode == RRQ || tp_opcode == WRQ)
+ if (tp_opcode == RRQ || tp_opcode == WRQ || tp_opcode == TRQ)
tftp(tp, n);
exit(0);
}
@@ -1077,6 +1078,7 @@ int tftp(struct tftphdr *tp, int size)
char *filename, *mode = NULL;
const char *errmsgptr;
u_short tp_opcode = ntohs(tp->th_opcode);
+ ts_args *args = NULL;
char *val = NULL, *opt = NULL;
char *ap = ackbuf + 2;
@@ -1118,6 +1120,10 @@ int tftp(struct tftphdr *tp, int size)
nak(EACCESS, errmsgptr); /* File denied by mapping rule */
exit(0);
}
+ if (tp_opcode == TRQ) /* Thinstation request */
+ {
+ args = ts_get_arguments(filename, dirs[ndirs - 1]);
+ }
if (verbosity >= 1) {
tmp_p = (char *)inet_ntop(from.sa.sa_family, SOCKADDR_P(&from),
tmpbuf, INET6_ADDRSTRLEN);
@@ -1127,9 +1133,12 @@ int tftp(struct tftphdr *tp, int size)
}
if (filename == origfilename
|| !strcmp(filename, origfilename))
- syslog(LOG_NOTICE, "%s from %s filename %s\n",
- tp_opcode == WRQ ? "WRQ" : "RRQ",
- tmp_p, filename);
+ if (tp_opcode == TRQ) /* Thinstation request */
+ ts_syslog(args);
+ else
+ syslog(LOG_NOTICE, "%s from %s filename %s\n",
+ tp_opcode == WRQ ? "WRQ" : "RRQ",
+ tmp_p, filename);
else
syslog(LOG_NOTICE,
"%s from %s filename %s remapped to %s\n",
@@ -1137,6 +1146,12 @@ int tftp(struct tftphdr *tp, int size)
tmp_p, origfilename,
filename);
}
+ if (tp_opcode == TRQ)
+ {
+ ts_symlink(args);
+ ts_free(args);
+ exit(0);
+ }
ecode =
(*pf->f_validate) (filename, tp_opcode, pf, &errmsgptr);
if (ecode) {