From: Arvin Schnell Date: Tue, 11 Feb 2025 15:47:13 +0000 (+0100) Subject: - protect paths with two dashes X-Git-Tag: v0.12.2~21^2 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=4837202d07cffd65202ec5a5faaf0c8abfc5425e;p=thirdparty%2Fsnapper.git - protect paths with two dashes --- diff --git a/client/snbk/CmdBtrfs.cc b/client/snbk/CmdBtrfs.cc index 3548d291..88a3aba3 100644 --- a/client/snbk/CmdBtrfs.cc +++ b/client/snbk/CmdBtrfs.cc @@ -41,7 +41,7 @@ namespace snapper CmdBtrfsSubvolumeList::CmdBtrfsSubvolumeList(const string& btrfs_bin, const Shell& shell, const string& mount_point) { - SystemCmd::Args cmd_args = { btrfs_bin, "subvolume", "list", "-a", "-puqR", mount_point }; + SystemCmd::Args cmd_args = { btrfs_bin, "subvolume", "list", "-a", "-puqR", "--", mount_point }; SystemCmd cmd(shellify(shell, cmd_args)); if (cmd.retcode() != 0) @@ -159,7 +159,7 @@ namespace snapper CmdBtrfsSubvolumeShow::CmdBtrfsSubvolumeShow(const string& btrfs_bin, const Shell& shell, const string& mount_point) { - SystemCmd::Args cmd_args = { btrfs_bin, "subvolume", "show", mount_point }; + SystemCmd::Args cmd_args = { btrfs_bin, "subvolume", "show", "--", mount_point }; SystemCmd cmd(shellify(shell, cmd_args)); if (cmd.retcode() != 0) diff --git a/client/snbk/CmdRealpath.cc b/client/snbk/CmdRealpath.cc index 0eb417ab..eebb1040 100644 --- a/client/snbk/CmdRealpath.cc +++ b/client/snbk/CmdRealpath.cc @@ -34,7 +34,7 @@ namespace snapper CmdRealpath::CmdRealpath(const string& realpath_bin, const Shell& shell, const string& path) : path(path) { - SystemCmd::Args cmd_args = { realpath_bin, path }; + SystemCmd::Args cmd_args = { realpath_bin, "--", path }; SystemCmd cmd(shellify(shell, cmd_args)); if (cmd.retcode() != 0) diff --git a/client/snbk/TheBigThing.cc b/client/snbk/TheBigThing.cc index 3c22cc08..c3a6b2c2 100644 --- a/client/snbk/TheBigThing.cc +++ b/client/snbk/TheBigThing.cc @@ -73,7 +73,7 @@ namespace snapper // Create directory on target. - SystemCmd::Args cmd1_args = { MKDIR_BIN, backup_config.target_path + "/" + to_string(num) }; + SystemCmd::Args cmd1_args = { MKDIR_BIN, "--", backup_config.target_path + "/" + num_string }; SystemCmd cmd1(shellify(backup_config.get_target_shell(), cmd1_args)); if (cmd1.retcode() != 0) { @@ -92,8 +92,8 @@ namespace snapper { case BackupConfig::TargetMode::LOCAL: { - SystemCmd::Args cmd2_args = { CP_BIN, backup_config.source_path + "/" SNAPSHOTS_NAME "/" + - to_string(num) + "/info.xml", backup_config.target_path + "/" + to_string(num) + "/" }; + SystemCmd::Args cmd2_args = { CP_BIN, "--", backup_config.source_path + "/" SNAPSHOTS_NAME "/" + + num_string + "/info.xml", backup_config.target_path + "/" + num_string + "/" }; SystemCmd cmd2(shellify(backup_config.get_target_shell(), cmd2_args)); if (cmd2.retcode() != 0) { @@ -142,9 +142,9 @@ namespace snapper if (it1 != the_big_things.end()) cmd3a_args << "-p" << backup_config.source_path + "/" SNAPSHOTS_NAME "/" + to_string(it1->num) + "/" SNAPSHOT_NAME; - cmd3a_args << backup_config.source_path + "/" SNAPSHOTS_NAME "/" + to_string(num) + "/" SNAPSHOT_NAME; + cmd3a_args << "--" << backup_config.source_path + "/" SNAPSHOTS_NAME "/" + num_string + "/" SNAPSHOT_NAME; - SystemCmd::Args cmd3b_args = { BTRFS_BIN, "receive", backup_config.target_path + "/" + to_string(num) }; + SystemCmd::Args cmd3b_args = { BTRFS_BIN, "receive", "--", backup_config.target_path + "/" + num_string }; y2deb("source: " << cmd3a_args.get_values()); y2deb("target: " << cmd3b_args.get_values()); @@ -174,10 +174,12 @@ namespace snapper if (target_state == TargetState::MISSING) SN_THROW(Exception(_("Snapshot not on target."))); + const string num_string = to_string(num); + // Delete snapshot on target. - SystemCmd::Args cmd1_args = { BTRFS_BIN, "subvolume", "delete", backup_config.target_path + "/" + - to_string(num) + "/" SNAPSHOT_NAME }; + SystemCmd::Args cmd1_args = { BTRFS_BIN, "subvolume", "delete", "--", backup_config.target_path + "/" + + num_string + "/" SNAPSHOT_NAME }; SystemCmd cmd1(shellify(backup_config.get_target_shell(), cmd1_args)); if (cmd1.retcode() != 0) { @@ -192,7 +194,7 @@ namespace snapper // Remove info.xml on target. - SystemCmd::Args cmd2_args = { RM_BIN, backup_config.target_path + "/" + to_string(num) + "/info.xml" }; + SystemCmd::Args cmd2_args = { RM_BIN, "--", backup_config.target_path + "/" + num_string + "/info.xml" }; SystemCmd cmd2(shellify(backup_config.get_target_shell(), cmd2_args)); if (cmd2.retcode() != 0) { @@ -207,7 +209,7 @@ namespace snapper // Remove directory on target. - SystemCmd::Args cmd3_args = { RMDIR_BIN, backup_config.target_path + "/" + to_string(num) }; + SystemCmd::Args cmd3_args = { RMDIR_BIN, "--", backup_config.target_path + "/" + num_string }; SystemCmd cmd3(shellify(backup_config.get_target_shell(), cmd3_args)); if (cmd3.retcode() != 0) {