wok-4.x view busybox/stuff/busybox-1.16.1-ris.u @ rev 5684
Up busybox (1.16.1)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Jun 04 17:00:07 2010 +0200 (2010-06-04) |
parents | |
children |
line source
1 --- busybox-1.16.1/networking/Config.in
2 +++ busybox-1.16.1/networking/Config.in
3 @@ -852,6 +852,15 @@
4 In other words: it should be run from inetd in nowait mode,
5 or from udpsvd. Example: "udpsvd -E 0 69 tftpd DIR"
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 \"get\" command"
18 default y
20 --- busybox-1.16.1/networking/tftp.c
21 +++ busybox-1.16.1/networking/tftp.c
22 @@ -653,6 +653,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 @@ -782,6 +839,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;