rev |
line source |
pascal@15734
|
1 Add support for the Windows Remote Installation Service
|
pascal@15734
|
2 --- busybox-1.21.0/networking/Config.src
|
pascal@15734
|
3 +++ busybox-1.21.0/networking/Config.src
|
pascal@15734
|
4 @@ -820,6 +820,15 @@
|
pascal@15734
|
5 comment "Common options for tftp/tftpd"
|
pascal@15734
|
6 depends on TFTP || TFTPD
|
pascal@15734
|
7
|
pascal@15734
|
8 +config FEATURE_TFTPD_RIS
|
pascal@15734
|
9 + bool "Enable \"RIS\" support"
|
pascal@15734
|
10 + default y
|
pascal@15734
|
11 + depends on TFTPD
|
pascal@15734
|
12 + help
|
pascal@15734
|
13 + Add support for the Windows Remote Installation Service. This allows
|
pascal@15734
|
14 + a client to get files starting with \ without respecting case.
|
pascal@15734
|
15 + Each \ will be replaced by a /.
|
pascal@15734
|
16 +
|
pascal@15734
|
17 config FEATURE_TFTP_GET
|
pascal@15734
|
18 bool "Enable 'tftp get' and/or tftpd upload code"
|
pascal@15734
|
19 default y
|
pascal@15734
|
20
|
pascal@15734
|
21 --- busybox-1.20.0/networking/tftp.c
|
pascal@15734
|
22 +++ busybox-1.20.0/networking/tftp.c
|
pascal@15734
|
23 @@ -671,6 +671,59 @@
|
pascal@15734
|
24 #undef remote_file
|
pascal@15734
|
25 }
|
pascal@15734
|
26
|
pascal@15734
|
27 +#if ENABLE_FEATURE_TFTPD_RIS
|
pascal@15734
|
28 +#include <dirent.h>
|
pascal@15734
|
29 +
|
pascal@15734
|
30 +static int lookup_entry(const char *search, char *unixpath);
|
pascal@15734
|
31 +static void unixfilename(char *filename);
|
pascal@15734
|
32 +
|
pascal@15734
|
33 +// lookup search and concat real filename to unixpath
|
pascal@15734
|
34 +static int lookup_entry(const char *search, char *unixpath)
|
pascal@15734
|
35 +{
|
pascal@15734
|
36 + int status = 0;
|
pascal@15734
|
37 + DIR *dirp = opendir(unixpath[0] ? unixpath : ".");
|
pascal@15734
|
38 +
|
pascal@15734
|
39 + if (dirp != NULL) {
|
pascal@15734
|
40 + struct dirent *entry;
|
pascal@15734
|
41 +
|
pascal@15734
|
42 + while ((entry = readdir(dirp))) {
|
pascal@15734
|
43 + if (!strcasecmp(entry->d_name, search)) {
|
pascal@15734
|
44 + if (unixpath[0]) strcat(unixpath, "/");
|
pascal@15734
|
45 + strcat(unixpath, entry->d_name);
|
pascal@15734
|
46 + status++;
|
pascal@15734
|
47 + break;
|
pascal@15734
|
48 + }
|
pascal@15734
|
49 + }
|
pascal@15734
|
50 + closedir(dirp);
|
pascal@15734
|
51 + }
|
pascal@15734
|
52 + return status;
|
pascal@15734
|
53 +}
|
pascal@15734
|
54 +
|
pascal@15734
|
55 +// update filename with real file path found
|
pascal@15734
|
56 +static void unixfilename(char *filename)
|
pascal@15734
|
57 +{
|
pascal@15734
|
58 + char unixpath[PATH_MAX];
|
pascal@15734
|
59 + char *s = unixpath + 1;
|
pascal@15734
|
60 + char *check = filename + 1;
|
pascal@15734
|
61 + int len;
|
pascal@15734
|
62 +
|
pascal@15734
|
63 + for (unixpath[0] = 0; *check; len++, s += len, check += len) {
|
pascal@15734
|
64 + char *seek = strchr(check, '\\');
|
pascal@15734
|
65 +
|
pascal@15734
|
66 + if (!seek) { // basename of filename
|
pascal@15734
|
67 + if (lookup_entry(check, unixpath))
|
pascal@15734
|
68 + strcpy(filename, unixpath); // found
|
pascal@15734
|
69 + break;
|
pascal@15734
|
70 + }
|
pascal@15734
|
71 + len = seek - check;
|
pascal@15734
|
72 + memcpy(s, check, len);
|
pascal@15734
|
73 + s[len] = '\0';
|
pascal@15734
|
74 + if (!lookup_entry(s, unixpath))
|
pascal@15734
|
75 + break; // path mismatch
|
pascal@15734
|
76 + }
|
pascal@15734
|
77 +}
|
pascal@15734
|
78 +#endif
|
pascal@15734
|
79 +
|
pascal@15734
|
80 #if ENABLE_TFTP
|
pascal@15734
|
81
|
pascal@15734
|
82 int tftp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
pascal@15734
|
83 @@ -809,6 +862,10 @@
|
pascal@15734
|
84 goto err;
|
pascal@15734
|
85 }
|
pascal@15734
|
86 local_file = G.block_buf + 2;
|
pascal@15734
|
87 +#if ENABLE_FEATURE_TFTPD_RIS
|
pascal@15734
|
88 + if (local_file[0] == '\\')
|
pascal@15734
|
89 + unixfilename(local_file);
|
pascal@15734
|
90 +#endif
|
pascal@15734
|
91 if (local_file[0] == '.' || strstr(local_file, "/.")) {
|
pascal@15734
|
92 error_msg = "dot in file name";
|
pascal@15734
|
93 goto err;
|