wok-undigest annotate busybox/stuff/busybox-1.22-ris.u @ rev 1138

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