wok annotate busybox/stuff/busybox-1.27-ris.u @ rev 21015

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