wok view busybox/stuff/busybox-1.17.0-ris.u @ rev 5773

Up busybox (1.17.0)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Jul 06 15:09:01 2010 +0200 (2010-07-06)
parents
children 1ed09465c0ae
line source
1 --- busybox-1.17.0/networking/Config.src
2 +++ busybox-1.17.0/networking/Config.src
3 @@ -841,6 +841,15 @@
4 comment "Common options for tftp/tftpd"
5 depends on TFTP || TFTPD
7 +config FEATURE_TFTPD_RIS
8 + bool "Enable \"RIS\" support"
9 + default y
10 + depends on TFTPD
11 + help
12 + Add support for the Remote Installation Service. This allows
13 + a client to get files starting with \ without respecting case.
14 + Each \ will be replaced by a /.
15 +
16 config FEATURE_TFTP_GET
17 bool "Enable 'tftp get' and/or tftpd upload code"
18 default y
20 --- busybox-1.17.0/networking/tftp.c
21 +++ busybox-1.17.0/networking/tftp.c
22 @@ -656,6 +656,63 @@
23 #undef remote_file
24 }
26 +#if ENABLE_FEATURE_TFTPD_RIS
27 +#include <dirent.h>
28 +
29 +int lookup_entry(const char *comp, char *dest);
30 +void lookup_file(char *filename);
31 +
32 +int lookup_entry(const char *comp, char *dest)
33 +{
34 + DIR *dirp;
35 + struct dirent *dptr;
36 + if (!dest) return 0;
37 + dirp = opendir(dest[0] ? dest : ".");
38 + while ((dptr = readdir(dirp))) {
39 + if (!strcasecmp(dptr->d_name, comp)) {
40 + if (dest[0]) strcat(dest, "/");
41 + strcat(dest, dptr->d_name);
42 + closedir(dirp);
43 + return 1;
44 + }
45 + }
46 + closedir(dirp);
47 + return 0;
48 +}
49 +
50 +void lookup_file(char *filename)
51 +{
52 + int found = 0;
53 + int len = 0;
54 + char dest[1024];
55 + char comp[1024];
56 + char *check = filename;
57 + char *seek = NULL;
58 +
59 + dest[0] = 0;
60 + check++;
61 + while (*check) {
62 + seek = strchr(check, '\\');
63 + if (!seek) {
64 + if ((*check) && (lookup_entry(check, dest)))
65 + found = 1;
66 + break;
67 + }
68 + len = seek - check;
69 + memcpy(comp, check, len);
70 + comp[len]=0;
71 + if (!lookup_entry(comp, dest))
72 + break;
73 + check += len + 1;
74 + }
75 +
76 + if (found) {
77 + filename[0] = 0;
78 + strcat(filename, dest);
79 + }
80 +}
81 +#endif
82 +
83 #if ENABLE_TFTP
85 int tftp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
86 @@ -785,6 +842,11 @@
87 goto err;
88 }
89 local_file = block_buf + 2;
90 +#if ENABLE_FEATURE_TFTPD_RIS
91 + if (local_file[0] == '\\') {
92 + lookup_file(local_file);
93 + }
94 +#endif
95 if (local_file[0] == '.' || strstr(local_file, "/.")) {
96 error_msg = "dot in file name";
97 goto err;