diff options
author | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-02-20 00:12:07 +0000 |
---|---|---|
committer | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-02-20 00:12:07 +0000 |
commit | 0db1137dbf5008d456b9cc80a5cf1222467fed9d (patch) | |
tree | fff16b11c6aaac079c8c88878c80591f658c722a | |
parent | 1f697db9c3c22d3768175dbd70e7d5a68638e7b7 (diff) |
Change -tftp option to take a root directory, by Anthony Liguori.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2441 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r-- | qemu-doc.texi | 11 | ||||
-rw-r--r-- | slirp/tftp.c | 12 | ||||
-rw-r--r-- | vl.c | 2 |
3 files changed, 15 insertions, 10 deletions
diff --git a/qemu-doc.texi b/qemu-doc.texi index b23b03377a..fe69e80b7c 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -444,13 +444,12 @@ Indicate that no network devices should be configured. It is used to override the default configuration (@option{-net nic -net user}) which is activated if no @option{-net} options are provided. -@item -tftp prefix +@item -tftp dir When using the user mode network stack, activate a built-in TFTP -server. All filenames beginning with @var{prefix} can be downloaded -from the host to the guest using a TFTP client. The TFTP client on the -guest must be configured in binary mode (use the command @code{bin} of -the Unix TFTP client). The host IP address on the guest is as usual -10.0.2.2. +server. The files in @var{dir} will be exposed as the root of a TFTP server. +The TFTP client on the guest must be configured in binary mode (use the command +@code{bin} of the Unix TFTP client). The host IP address on the guest is as +usual 10.0.2.2. @item -bootp file When using the user mode network stack, broadcast @var{file} as the BOOTP diff --git a/slirp/tftp.c b/slirp/tftp.c index b3947eb38a..96d00e62c8 100644 --- a/slirp/tftp.c +++ b/slirp/tftp.c @@ -102,8 +102,15 @@ static int tftp_read_data(struct tftp_session *spt, u_int16_t block_nr, { int fd; int bytes_read = 0; + char buffer[1024]; + int n; - fd = open(spt->filename, O_RDONLY | O_BINARY); + n = snprintf(buffer, sizeof(buffer), "%s/%s", + tftp_prefix, spt->filename); + if (n >= sizeof(buffer)) + return -1; + + fd = open(buffer, O_RDONLY | O_BINARY); if (fd < 0) { return -1; @@ -325,8 +332,7 @@ static void tftp_handle_rrq(struct tftp_t *tp, int pktlen) /* only allow exported prefixes */ - if (!tftp_prefix - || (strncmp(spt->filename, tftp_prefix, strlen(tftp_prefix)) != 0)) { + if (!tftp_prefix) { tftp_send_error(spt, 2, "Access violation", tp); return; } @@ -6402,7 +6402,7 @@ void help(void) " is provided, the default is '-net nic -net user'\n" "\n" #ifdef CONFIG_SLIRP - "-tftp prefix allow tftp access to files starting with prefix [-net user]\n" + "-tftp dir allow tftp access to files in dir [-net user]\n" "-bootp file advertise file in BOOTP replies\n" #ifndef _WIN32 "-smb dir allow SMB access to files in 'dir' [-net user]\n" |