wok annotate busybox/stuff/busybox-1.17.1-ris.u @ rev 6502

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