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