wok-current view busybox/stuff/busybox-1.18-ris.u @ rev 12310
slim: fix bdeps
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue Apr 17 12:55:15 2012 +0200 (2012-04-17) |
parents | 0d7cf47babb3 |
children |
line source
1 Add support for the Windows Remote Installation Service
2 --- busybox-1.17.1/networking/Config.src
3 +++ busybox-1.17.1/networking/Config.src
4 @@ -863,6 +863,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
21 --- busybox-1.18.2/networking/tftp.c
22 +++ busybox-1.18.2/networking/tftp.c
23 @@ -641,6 +641,59 @@
24 #undef remote_file
25 }
27 +#if ENABLE_FEATURE_TFTPD_RIS
28 +#include <dirent.h>
29 +
30 +static int lookup_entry(const char *search, char *unixpath);
31 +static void unixfilename(char *filename);
32 +
33 +// lookup search and concat real filename to unixpath
34 +static int lookup_entry(const char *search, char *unixpath)
35 +{
36 + int status = 0;
37 + DIR *dirp = opendir(unixpath[0] ? unixpath : ".");
38 +
39 + if (dirp != NULL) {
40 + struct dirent *entry;
41 +
42 + while ((entry = readdir(dirp))) {
43 + if (!strcasecmp(entry->d_name, search)) {
44 + if (unixpath[0]) strcat(unixpath, "/");
45 + strcat(unixpath, entry->d_name);
46 + status++;
47 + break;
48 + }
49 + }
50 + closedir(dirp);
51 + }
52 + return status;
53 +}
54 +
55 +// update filename with real file path found
56 +static void unixfilename(char *filename)
57 +{
58 + char unixpath[PATH_MAX];
59 + char *s = unixpath + 1;
60 + char *check = filename + 1;
61 + int len;
62 +
63 + for (unixpath[0] = 0; *check; len++, s += len, check += len) {
64 + char *seek = strchr(check, '\\');
65 +
66 + if (!seek) { // basename of filename
67 + if (lookup_entry(check, unixpath))
68 + strcpy(filename, unixpath); // found
69 + break;
70 + }
71 + len = seek - check;
72 + memcpy(s, check, len);
73 + s[len] = '\0';
74 + if (!lookup_entry(s, unixpath))
75 + break; // path mismatch
76 + }
77 +}
78 +#endif
79 +
80 #if ENABLE_TFTP
82 int tftp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
83 @@ -770,6 +823,10 @@
84 goto err;
85 }
86 local_file = block_buf + 2;
87 +#if ENABLE_FEATURE_TFTPD_RIS
88 + if (local_file[0] == '\\')
89 + unixfilename(local_file);
90 +#endif
91 if (local_file[0] == '.' || strstr(local_file, "/.")) {
92 error_msg = "dot in file name";
93 goto err;