wok annotate busybox/stuff/busybox-1.18.1-ris.u @ rev 7755

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