From 3cfd7f57b415abfbb951713fbfb74c2bc8094391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 14 Aug 2013 22:12:46 +0200 Subject: [PATCH] qvm-copy-to-vm: implement --ignore-symlinks option Can be useful when copying to VM which doesn't support symlinks (or user doesn't have privilege to create it). --- qubes-rpc/qfile-agent.c | 9 ++++++++- qubes-rpc/qvm-copy-to-vm | 2 +- qubes-rpc/qvm-copy-to-vm.gnome | 2 +- qubes-rpc/qvm-copy-to-vm.kde | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/qubes-rpc/qfile-agent.c b/qubes-rpc/qfile-agent.c index 51a7337..c3c8178 100644 --- a/qubes-rpc/qfile-agent.c +++ b/qubes-rpc/qfile-agent.c @@ -18,6 +18,8 @@ enum { PROGRESS_FLAG_DONE }; +int ignore_symlinks = 0; + unsigned long crc32_sum; int write_all_with_crc(int fd, void *buf, int size) { @@ -143,7 +145,7 @@ int single_file_processor(char *filename, struct stat *st) hdr.filelen = 0; write_headers(&hdr, filename); } - if (S_ISLNK(mode)) { + if (S_ISLNK(mode) && !ignore_symlinks) { char name[st->st_size + 1]; if (readlink(filename, name, sizeof(name)) != st->st_size) gui_fatal("readlink %s", filename); @@ -227,6 +229,11 @@ int main(int argc, char **argv) crc32_sum = 0; cwd = getcwd(NULL, 0); for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "--ignore-symlinks")==0) { + ignore_symlinks = 1; + continue; + } + entry = get_abs_path(cwd, argv[i]); do { diff --git a/qubes-rpc/qvm-copy-to-vm b/qubes-rpc/qvm-copy-to-vm index be0804a..3d1716c 100755 --- a/qubes-rpc/qvm-copy-to-vm +++ b/qubes-rpc/qvm-copy-to-vm @@ -37,7 +37,7 @@ VM="$1" shift if [ $PROGRESS_TYPE = console ] ; then - export FILECOPY_TOTAL_SIZE=$(du --apparent-size -c "$@" | tail -1 | cut -f 1) + export FILECOPY_TOTAL_SIZE=$(du --apparent-size -c -- "$@" 2> /dev/null | tail -1 | cut -f 1) fi exec /usr/lib/qubes/qrexec-client-vm $VM qubes.Filecopy /usr/lib/qubes/qfile-agent "$@" diff --git a/qubes-rpc/qvm-copy-to-vm.gnome b/qubes-rpc/qvm-copy-to-vm.gnome index 4199476..4b69c06 100755 --- a/qubes-rpc/qvm-copy-to-vm.gnome +++ b/qubes-rpc/qvm-copy-to-vm.gnome @@ -23,7 +23,7 @@ VM=$(qvm-mru-entry --title="File Copy" --text="Enter the destination domain name:" --mrufile "qvm-mru-filecopy") if [ X$VM = X ] ; then exit 0 ; fi -SIZE=$(du --apparent-size -c "$@" | tail -1 | cut -f 1) +SIZE=$(du --apparent-size -c -- "$@" 2>/dev/null | tail -1 | cut -f 1) export PROGRESS_TYPE=gui diff --git a/qubes-rpc/qvm-copy-to-vm.kde b/qubes-rpc/qvm-copy-to-vm.kde index 74ebf7b..740cf8a 100755 --- a/qubes-rpc/qvm-copy-to-vm.kde +++ b/qubes-rpc/qvm-copy-to-vm.kde @@ -23,7 +23,7 @@ VM=$(kdialog -inputbox "Enter the VM name to send files to:") if [ X$VM = X ] ; then exit 0 ; fi -SIZE=$(du --apparent-size -c "$@" | tail -1 | cut -f 1) +SIZE=$(du --apparent-size -c -- "$@" 2> /dev/null | tail -1 | cut -f 1) REF=$(kdialog --progressbar "Copy progress") qdbus $REF org.freedesktop.DBus.Properties.Set "" maximum $SIZE