wok annotate busybox/stuff/busybox-1.32-ris.u @ rev 24985

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