wok-6.x diff busybox/stuff/busybox-1.27-ris.u @ rev 22642

updated debootstrap (1.0.48 -> 1.0.116)
author Hans-G?nter Theisgen
date Tue Jan 14 07:46:35 2020 +0100 (2020-01-14)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/busybox/stuff/busybox-1.27-ris.u	Tue Jan 14 07:46:35 2020 +0100
     1.3 @@ -0,0 +1,90 @@
     1.4 +Add support for the Windows Remote Installation Service
     1.5 +--- busybox-1.26/networking/tftp.c
     1.6 ++++ busybox-1.26/networking/tftp.c
     1.7 +@@ -39,6 +39,15 @@
     1.8 + //config:comment "Common options for tftp/tftpd"
     1.9 + //config:	depends on TFTP || TFTPD
    1.10 + //config:
    1.11 ++//config:config FEATURE_TFTPD_RIS
    1.12 ++//config:	bool "Enable \"RIS\" support"
    1.13 ++//config:	default y
    1.14 ++//config:	depends on TFTPD
    1.15 ++//config:	help
    1.16 ++//config:	  Add support for the Windows Remote Installation Service. This allows
    1.17 ++//config:	  a client to get files starting with \ without respecting case.
    1.18 ++//config:	  Each \ will be replaced by a /.
    1.19 ++//config:
    1.20 + //config:config FEATURE_TFTP_GET
    1.21 + //config:	bool "Enable 'tftp get' and/or tftpd upload code"
    1.22 + //config:	default y
    1.23 +@@ -743,6 +752,59 @@
    1.24 + #undef remote_file
    1.25 + }
    1.26 + 
    1.27 ++#if ENABLE_FEATURE_TFTPD_RIS
    1.28 ++#include <dirent.h>
    1.29 ++
    1.30 ++static int lookup_entry(const char *search, char *unixpath);
    1.31 ++static void unixfilename(char *filename);
    1.32 ++
    1.33 ++// lookup search and concat real filename to unixpath
    1.34 ++static int lookup_entry(const char *search, char *unixpath)
    1.35 ++{
    1.36 ++ 	int status = 0;
    1.37 ++	DIR *dirp = opendir(unixpath[0] ? unixpath : ".");
    1.38 ++ 
    1.39 ++ 	if (dirp != NULL) {
    1.40 ++		struct dirent *entry;
    1.41 ++
    1.42 ++		while ((entry = readdir(dirp))) {
    1.43 ++			if (!strcasecmp(entry->d_name, search)) {
    1.44 ++				if (unixpath[0]) strcat(unixpath, "/");
    1.45 ++				strcat(unixpath, entry->d_name);
    1.46 ++				status++;
    1.47 ++				break;
    1.48 ++			}
    1.49 ++		}
    1.50 ++		closedir(dirp);
    1.51 ++ 	}
    1.52 ++	return status;
    1.53 ++}
    1.54 ++
    1.55 ++// update filename with real file path found
    1.56 ++static void unixfilename(char *filename)
    1.57 ++{
    1.58 ++	char unixpath[PATH_MAX];
    1.59 ++	char *s = unixpath + 1;
    1.60 ++	char *check = filename + 1;
    1.61 ++	int len;
    1.62 ++
    1.63 ++	for (unixpath[0] = 0; *check; len++, s += len, check += len) {
    1.64 ++		char *seek = strchr(check, '\\');
    1.65 ++
    1.66 ++		if (!seek) { // basename of filename
    1.67 ++			if (lookup_entry(check, unixpath))
    1.68 ++				strcpy(filename, unixpath); // found
    1.69 ++			break;
    1.70 ++		}
    1.71 ++		len = seek - check;
    1.72 ++		memcpy(s, check, len);
    1.73 ++		s[len] = '\0';
    1.74 ++		if (!lookup_entry(s, unixpath))
    1.75 ++			break; // path mismatch
    1.76 ++	}
    1.77 ++}
    1.78 ++#endif
    1.79 ++
    1.80 + #if ENABLE_TFTP
    1.81 + 
    1.82 + int tftp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    1.83 +@@ -891,6 +953,10 @@
    1.84 + 	G.block_buf_tail[0] = '\0';
    1.85 + 
    1.86 + 	local_file = G.block_buf + 2;
    1.87 ++#if ENABLE_FEATURE_TFTPD_RIS
    1.88 ++	if (local_file[0] == '\\')
    1.89 ++		unixfilename(local_file);
    1.90 ++#endif
    1.91 + 	if (local_file[0] == '.' || strstr(local_file, "/.")) {
    1.92 + 		error_msg = "dot in file name";
    1.93 + 		goto err;