Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions qubes-rpc/qfile-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdbool.h>
#include <gui-fatal.h>
#include <libqubes-rpc-filecopy.h>

Expand Down Expand Up @@ -82,10 +83,17 @@ int main(int argc, char **argv)
invocation_cwd_fd = open(".", O_PATH | O_DIRECTORY);
if (invocation_cwd_fd < 0)
gui_fatal("open \".\"");
bool ignore_options = false;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "--ignore-symlinks")==0) {
ignore_symlinks = 1;
continue;
if (!ignore_options) {
if (strcmp(argv[i], "--ignore-symlinks")==0) {
ignore_symlinks = 1;
continue;
}
if (strcmp(argv[i], "--") == 0) {
ignore_options = true;
continue;
}
}
if (!*argv[i])
gui_fatal("Invalid empty argument %i", i);
Expand Down
21 changes: 16 additions & 5 deletions qubes-rpc/qvm-copy
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

set -e -o pipefail

unset PROGRESS_TYPE OPERATION_TYPE TARGET_TYPE MIN_ARGS FILECOPY_TOTAL_BYTES service scriptdir
unset PROGRESS_TYPE OPERATION_TYPE TARGET_TYPE MIN_ARGS FILECOPY_TOTAL_BYTES service scriptdir ignore_symlinks

# Determine the operation to be performed
case ${0##*/} in
Expand All @@ -41,12 +41,20 @@ esac

usage () {
if [ "$TARGET_TYPE" = "vm" ]; then
echo "usage: $0 [--without-progress] destination_qube_name FILE [FILE ...]"
echo "usage: $0 [--without-progress] [--ignore-symlinks] destination_qube_name FILE [FILE ...]"
else
echo "usage: $0 [--without-progress] FILE [FILE ...]"
echo "usage: $0 [--without-progress] [--ignore-symlinks] FILE [FILE ...]"
fi
echo 'Options:
--no-ignore-symlinks Do not ignore symbolic links (default).
--ignore-symlinks Ignore symbolic links.
--with-progress Show a progress indicator (default).
--without-progress Do not show a progress indicator.
-h, --help Show this message and exit.
-- Stop searching for options.

echo
If there is a conflict, later options override earlier options.
'

if [ "$OPERATION_TYPE" = "move" ]; then
echo "Move FILE to ~/QubesIncoming/[THIS QUBE'S NAME]/ in the destination qube."
Expand All @@ -66,6 +74,9 @@ export PROGRESS_TYPE=console
while [ "$#" -gt 0 ]; do
case $1 in
(--without-progress) export PROGRESS_TYPE=none; shift;;
(--with-progress) export PROGRESS_TYPE=console; shift;;
(--ignore-symlinks) ignore_symlinks=true; shift;;
(--no-ignore-symlinks) unset ignore_symlinks; shift;;
(-h|--help) usage 0;;
(--) shift; break;;
(-*) usage 1;;
Expand Down Expand Up @@ -93,7 +104,7 @@ fi
if [[ "$PROGRESS_TYPE" = 'console' ]]; then export FILECOPY_TOTAL_BYTES; fi

"$scriptdir/qubes/qrexec-client-vm" --filter-escape-chars-stderr -- "$VM" \
"$service" "$scriptdir/qubes/qfile-agent" "$@"
"$service" "$scriptdir/qubes/qfile-agent" ${ignore_symlinks+--ignore-symlinks} -- "$@"

if [ "$OPERATION_TYPE" = "move" ] ; then
rm -rf -- "$@"
Expand Down