83 lines
2.9 KiB
Diff
83 lines
2.9 KiB
Diff
|
diff --git a/tftpd/Makefile b/tftpd/Makefile
|
||
|
index a05335d..d4bfb15 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
|
||
|
|
||
|
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) {
|