public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 container] fix #3367: prevent adding bind and device mountpoints to template
Date: Thu, 12 Sep 2024 11:56:10 +0200	[thread overview]
Message-ID: <20240912095610.149339-1-f.ebner@proxmox.com> (raw)

There is a check in the clone API call that prohibits cloning when a
bind or device mountpoint is present. Converting to a template also
will fail when such a mountpoint is present. In particular, that
failure will also trigger at the end of a restore operation, because
restore will also try to convert to a template again. Add a safeguard
so that users won't get into the problematic situation in the first
place.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

Changes in v2:
    * different approach with safeguard instead of silently dropping
      bind mounts during conversion to template

Previous discussion:
https://lore.proxmox.com/pve-devel/20210402123636.27037-1-f.ebner@proxmox.com/T/#u

 src/PVE/LXC/Config.pm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index ce64c4c..09687ab 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -1181,7 +1181,13 @@ sub update_pct_config {
 	if ($opt =~ m/^mp(\d+)$/ || $opt eq 'rootfs') {
 	    $class->check_protection($conf, "can't update CT $vmid drive '$opt'");
 	    my $mp = $class->parse_volume($opt, $value);
-	    $check_content_type->($mp) if ($mp->{type} eq 'volume');
+	    if ($mp->{type} eq 'volume') {
+		$check_content_type->($mp);
+	    } elsif ($class->is_template($conf)) {
+		# TODO allow bind mounts once admin-defined bind mount sources and corresponding ACL
+		# support is implemented
+		die "cannot add mountpoint '$opt' of type '$mp->{type}' to template\n";
+	    }
 	} elsif ($opt eq 'hookscript') {
 	    PVE::GuestHelpers::check_hookscript($value);
 	} elsif ($opt eq 'nameserver') {
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


                 reply	other threads:[~2024-09-12  9:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240912095610.149339-1-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal