wok annotate busybox/stuff/busybox-1.31-ris.u @ rev 23912

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