wok view busybox/stuff/busybox-1.27-ris.u @ rev 22701

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