wok annotate busybox/stuff/busybox-1.28-ris.u @ rev 20550

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