Commit Graph

22 Commits

Author SHA1 Message Date
Jakub Janků
3b1d9ab0a0 Use sprintf_s instead of sprintf to not crash
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-05-18 11:03:55 +01:00
Frediano Ziglio
241425b7da Support file transfer for existing files
Previously, if the user attempted to transfer a file that had the same
name as a file that already exists on the guest, we would just fail the
transfer. This patch tries to match the behavior of the linux vdagent
where we try to append an integer onto the name of the new file to make
it unique. For example, if you tried to transfer 'file.doc' to the guest
and that file already existed, it would try to create 'file (1).doc'
instead. If that also failed, it would attempt 'file (2).doc', etc, up
to 63.

Resolves: rhbz#1410181
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2017-05-02 14:49:36 -05:00
Jonathon Jongsma
a2b4da90a1 Don't exit vdagent when a client disconnects
Previously, when a client disconnects, the vdagent executable exited.
The agent was restarted immediately in order to be ready for the next
client to reconnect.

This is generally fine, but there are certain situations
where it causes issues. For example, if client A is connected to a guest
and client B connects to the same guest, client A will be forcibly
disconnected and causes the the vdagent to restart. This scenario is
racy because the agent can take some time to exit and restart. Client B
may think that the agent is connected at startup and may send agent
messages to the guest.  At some point the server will recieve
notification that the agent has exited and send an AGENT_DISCONNECTED
message to client B. After the agent has been fully restarted, an
AGENT_CONNECTED message will be sent to the client, but any messages
sent between client connection and the AGENT_DISCONNECTED message will
be lost. This causes problems especially with fullscreen mode in
virt-viewer.

The solution is to not exit and restart the agent when a client
disconnects. This is how the linux vdagent behaves. Instead, we simply
cancel all ongoing file transfers and reset the clipboard when a client
is disconnected.

Fixes: rhbz#1064495
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-04-05 10:30:00 -05:00
Victor Toso
8ae139f363 vdagent: remove whitespaces
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-08-12 09:41:41 +01:00
Victor Toso
d6919c6c07 file-transfer: fix typo
Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-08-11 14:34:32 +01:00
Frediano Ziglio
7fb2e2becc vdagent-win: Fix compile under MingW
Including directly shlobj.h in some MingW environment lead to some missing
definitions error. Including windows.h before fix the problem.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-04-30 14:01:01 +02:00
Frediano Ziglio
ae4a4f0035 Use wide characters in drap&drop code
This allows username to contain any extended characters (username is
embedded in the directory name).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-04-30 13:21:48 +02:00
Christophe Fergeau
5aa999320f Use new vdagent_{strncpy,strcat}_s helpers 2015-03-20 10:45:12 +01:00
Uri Lublin
d1c8d152f4 g_key_get_string: use size_t for pointer difference
The 64 bit Visual Studio build complains that:
  .\file_xfer.cpp(223) : warning C4244:
    '=' : conversion from '__int64' to 'unsigned int', possible loss of data
2014-12-30 17:42:17 +02:00
Uri Lublin
88b9b74d95 Fix building with Visual Studio (inttypes.h)
As a followup of commit 462295d9f8.

Building with Visual Studio, fails as there is no inttypes.h file:
  vdagent\file_xfer.cpp(21) : fatal error C1083: Cannot open
  include file: 'inttypes.h': No such file or directory

This commit prevents including inttypes.h when building with Visual Studio,
and defines PRIu64 that is defined in inttypes.h for mingw compiler.
2014-12-30 17:17:24 +02:00
Uri Lublin
eb276f4b45 Fix compiler warning (missing backslash in FileXfer::handle_start)
Visual Studio complains:
vdagent\file_xfer.cpp(85) : warning C4129: '%' : unrecognized character escape sequence

Replace "%s\%s" with "%s\\%s"
2014-12-30 17:16:53 +02:00
Cody Chan
6c070843cb Fix g_key_get_string() failure when string contains '['
In vd_agent/file_xfer.cpp is implemented a simple g_key_get_string,
but  when dragging a file with a name containing '[' (like te[st.txt),
it will fail.
From source code,
>next_group_pos = strstr(group_pos + strlen(group_pfx), "[");
>    if (next_group_pos && key_pos > next_group_pos) return false;
we know that it tries to find the end of current group by '[' label,
if we drag a file named te[st.txt, the key_string will be like:
[vdagent-file-xfer]
name=te[st.txt
size=10
so, it will fail when meta parsing and returns the
VD_AGENT_FILE_XFER_STATUS_ERROR message.

Here's the elegant method Christophe proposed and test ok, thanks to
him again!
2014-11-13 16:52:19 +01:00
Cody Chan
21b79679c1 Fix dragging of files with CJK characters in name
I submitted a patch several months ago about this issue,
here http://lists.freedesktop.org/archives/spice-devel/2014-February/016158.html
I check it again, and find that the value of
g_key_file_to_data(keyfile,...) is always utf-8, for the value of
g_uri_list_extract_uris() is utf8 urlencode.

So the display problem is caused by vd_agent, but how it displays
depends on the language of system, the following two screenshots show
the difference:

http://int64ago-tmp.qiniudn.com/guest-Chinese.png
http://int64ago-tmp.qiniudn.com/guest-English.png
2014-11-13 16:52:18 +01:00
Uri Lublin
4335b0d43a vdagent: file_xfer: make g_key_get_string safer
By providing the size of the destination string buffer.
2013-11-13 10:39:57 +02:00
Uri Lublin
066f614cee vdagent: file-xfer: make user desktop the target directory
Before, the target directory was a public one (for all users),
as file creation was not done with user privileges.

Now that the file is created with user privileges, it's
better to make the user desktop the target directory.
2013-11-13 10:39:47 +02:00
Uri Lublin
71193f6581 file_xfer: create file with user privileges 2013-11-13 10:39:37 +02:00
Marc-André Lureau
4b9e9b1d28 Remove usage of more _s functions
Even before this change, it should have handled error conditions. We'd
be better off allocating those strings and failing on io op later on.
2013-07-17 21:20:47 +02:00
Marc-André Lureau
492ee05a6b Replace sscanf_s by sscanf
The _s functions need a recent msvcrt version, not shipped in XP by
default.

Furthermore, it appears that their sscanf_s usage was missing the extra
buffer size argument.
2013-07-17 20:45:22 +02:00
Marc-André Lureau
b9d6baec2d Fix task could be used uninitialized 2013-07-17 20:45:21 +02:00
Marc-André Lureau
462295d9f8 Fix invalid print format for uint64_t values
format '%lu' expects argument of type 'long unsigned int', but argument
9 has type 'uint64_t
2013-07-17 20:45:21 +02:00
Marc-André Lureau
3bf46bc2b2 dos2unix 2013-07-17 20:45:21 +02:00
Arnon Gilboa
c751e8fda0 vdagent: add support for client -> guest file transfers
rhbz#956146
2013-06-27 14:23:49 +03:00