wok annotate busybox/stuff/busybox-1.21-ris.u @ rev 13964

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