]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- protect paths with two dashes 990/head
authorArvin Schnell <aschnell@suse.de>
Tue, 11 Feb 2025 15:47:13 +0000 (16:47 +0100)
committerArvin Schnell <aschnell@suse.de>
Tue, 11 Feb 2025 15:47:13 +0000 (16:47 +0100)
client/snbk/CmdBtrfs.cc
client/snbk/CmdRealpath.cc
client/snbk/TheBigThing.cc

index 3548d29110fc44d7cf43ad3777c4c61bc546e0b8..88a3aba3e04733045c00f2683ba37bd0842af7a8 100644 (file)
@@ -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)
index 0eb417ab068291fd9e35d3e5ad00d284bba2332d..eebb104029fbbce92ed704759f357a499e0a96c8 100644 (file)
@@ -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)
index 3c22cc08961bf624003e8871864b1a6583528068..c3a6b2c2c76b3844e951e37e0d0c027de72d08c0 100644 (file)
@@ -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)
        {