wok annotate busybox/stuff/busybox-1.20-ris.u @ rev 12846

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