rev |
line source |
pascal@3319
|
1 --- busybox-1.12.0/networking/tftp.c
|
pascal@3319
|
2 +++ busybox-1.12.0/networking/tftp.c
|
pascal@3319
|
3 @@ -552,6 +552,63 @@
|
pascal@3319
|
4 #undef tsize
|
pascal@3319
|
5 }
|
pascal@3319
|
6
|
pascal@3319
|
7 +#if ENABLE_FEATURE_TFTPD_RIS
|
pascal@3319
|
8 +#include <dirent.h>
|
pascal@3319
|
9 +
|
pascal@3319
|
10 +int lookup_entry(const char *comp, char *dest);
|
pascal@3319
|
11 +void lookup_file(char *filename);
|
pascal@3319
|
12 +
|
pascal@3319
|
13 +int lookup_entry(const char *comp, char *dest)
|
pascal@3319
|
14 +{
|
pascal@3319
|
15 + DIR *dirp;
|
pascal@3319
|
16 + struct dirent *dptr;
|
pascal@3319
|
17 + if (!dest) return 0;
|
pascal@3319
|
18 + dirp = opendir(dest[0] ? dest : ".");
|
pascal@3319
|
19 + while ((dptr = readdir(dirp))) {
|
pascal@3319
|
20 + if (!strcasecmp(dptr->d_name, comp)) {
|
pascal@3319
|
21 + if (dest[0]) strcat(dest, "/");
|
pascal@3319
|
22 + strcat(dest, dptr->d_name);
|
pascal@3319
|
23 + closedir(dirp);
|
pascal@3319
|
24 + return 1;
|
pascal@3319
|
25 + }
|
pascal@3319
|
26 + }
|
pascal@3319
|
27 + closedir(dirp);
|
pascal@3319
|
28 + return 0;
|
pascal@3319
|
29 +}
|
pascal@3319
|
30 +
|
pascal@3319
|
31 +void lookup_file(char *filename)
|
pascal@3319
|
32 +{
|
pascal@3319
|
33 + int found = 0;
|
pascal@3319
|
34 + int len = 0;
|
pascal@3319
|
35 + char dest[1024];
|
pascal@3319
|
36 + char comp[1024];
|
pascal@3319
|
37 + char *check = filename;
|
pascal@3319
|
38 + char *seek = NULL;
|
pascal@3319
|
39 +
|
pascal@3319
|
40 + dest[0] = 0;
|
pascal@3319
|
41 + check++;
|
pascal@3319
|
42 + while (*check) {
|
pascal@3319
|
43 + seek = strchr(check, '\\');
|
pascal@3319
|
44 + if (!seek) {
|
pascal@3319
|
45 + if ((*check) && (lookup_entry(check, dest)))
|
pascal@3319
|
46 + found = 1;
|
pascal@3319
|
47 + break;
|
pascal@3319
|
48 + }
|
pascal@3319
|
49 + len = seek - check;
|
pascal@3319
|
50 + memcpy(comp, check, len);
|
pascal@3319
|
51 + comp[len]=0;
|
pascal@3319
|
52 + if (!lookup_entry(comp, dest))
|
pascal@3319
|
53 + break;
|
pascal@3319
|
54 + check += len + 1;
|
pascal@3319
|
55 + }
|
pascal@3319
|
56 +
|
pascal@3319
|
57 + if (found) {
|
pascal@3319
|
58 + filename[0] = 0;
|
pascal@3319
|
59 + strcat(filename, dest);
|
pascal@3319
|
60 + }
|
pascal@3319
|
61 +}
|
pascal@3319
|
62 +#endif
|
pascal@3319
|
63 +
|
pascal@3319
|
64 #if ENABLE_TFTP
|
pascal@3319
|
65
|
pascal@3319
|
66 int tftp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
pascal@3319
|
67 @@ -680,6 +737,11 @@
|
pascal@3319
|
68 goto err;
|
pascal@3319
|
69 }
|
pascal@3319
|
70 local_file = block_buf + 2;
|
pascal@3319
|
71 +#if ENABLE_FEATURE_TFTPD_RIS
|
pascal@3319
|
72 + if (local_file[0] == '\\') {
|
pascal@3319
|
73 + lookup_file(local_file);
|
pascal@3319
|
74 + }
|
pascal@3319
|
75 +#endif
|
pascal@3319
|
76 if (local_file[0] == '.' || strstr(local_file, "/.")) {
|
pascal@3319
|
77 error_msg = "dot in file name";
|
pascal@3319
|
78 goto err;
|
pascal@3319
|
79
|
pascal@3319
|
80 --- busybox-1.12.0/networking/Config.in
|
pascal@3319
|
81 +++ busybox-1.12.0/networking/Config.in
|
pascal@3319
|
82 @@ -794,6 +794,15 @@
|
pascal@3319
|
83 In other words: it should be run from inetd in nowait mode,
|
pascal@3319
|
84 or from udpsvd. Example: "udpsvd -E 0 69 tftpd DIR"
|
pascal@3319
|
85
|
pascal@3319
|
86 +config FEATURE_TFTPD_RIS
|
pascal@3319
|
87 + bool "Enable \"RIS\" support"
|
pascal@3319
|
88 + default y
|
pascal@3319
|
89 + depends on TFTPD
|
pascal@3319
|
90 + help
|
pascal@3319
|
91 + Add support for the Remote Installation Service. This allows
|
pascal@3319
|
92 + a client to get files starting with \ without respecting case.
|
pascal@3319
|
93 + Each \ will be replaced by a /.
|
pascal@3319
|
94 +
|
pascal@3319
|
95 config FEATURE_TFTP_GET
|
pascal@3319
|
96 bool "Enable \"get\" command"
|
pascal@3319
|
97 default y
|