wok annotate busybox/stuff/busybox-1.30-ris.u @ rev 23157

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