public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 storage 1/5] postinst: move cifs credential files into subdirectory upon update
Date: Wed, 16 Jun 2021 09:26:56 +0200	[thread overview]
Message-ID: <20210616072700.54289-5-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210616072700.54289-1-f.ebner@proxmox.com>

and drop the compat code.

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

Changes from v1:
    * make sure to create the /etc/pve/priv/storage directory which might not
      exist yet
    * always print info when a file was found
    * use variable for target path
    * use mv
    * removing the helper needs to wait until 8.0

 PVE/Storage/CIFSPlugin.pm |  3 ---
 debian/postinst           | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 3 deletions(-)
 create mode 100644 debian/postinst

diff --git a/PVE/Storage/CIFSPlugin.pm b/PVE/Storage/CIFSPlugin.pm
index be06cc7..9d69b01 100644
--- a/PVE/Storage/CIFSPlugin.pm
+++ b/PVE/Storage/CIFSPlugin.pm
@@ -59,9 +59,6 @@ sub get_cred_file {
 
     if (-e $cred_file) {
 	return $cred_file;
-    } elsif (-e "/etc/pve/priv/${storeid}.cred") {
-	# FIXME: remove fallback with 7.0 by doing a rename on upgrade from 6.x
-	return "/etc/pve/priv/${storeid}.cred";
     }
     return undef;
 }
diff --git a/debian/postinst b/debian/postinst
new file mode 100644
index 0000000..508075b
--- /dev/null
+++ b/debian/postinst
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+set -e
+
+#DEBHELPER#
+
+case "$1" in
+  configure)
+    if test -n "$2"; then
+
+        # TODO: remove once PVE 8.0 is released
+        if dpkg --compare-versions "$2" 'lt' '7.0-3'; then
+            for file in /etc/pve/priv/*.cred; do
+                if [ -f "$file" ]; then
+                    mkdir -p "/etc/pve/priv/storage"
+                    echo "Info: found CIFS credentials using old path: $file" >&2
+                    base=$(basename --suffix=".cred" "$file")
+                    target="/etc/pve/priv/storage/$base.pw"
+                    if [ -f "$target" ]; then
+                        echo "Warning: not renaming $file, because $target already exists!" >&2
+                    else
+                        echo "Info: renaming $file to $target" >&2
+                        mv "$file" "$target"
+                    fi
+                fi
+            done
+        fi
+    fi
+    ;;
+
+esac
+
+exit 0
-- 
2.30.2





  parent reply	other threads:[~2021-06-16  7:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16  7:26 [pve-devel] [PATCH-SERIES v2 manager/storage] Some breaking API changes/cleanups Fabian Ebner
2021-06-16  7:26 ` [pve-devel] [PATCH v2 manager 1/3] pve6to7: add checks for backup retention options Fabian Ebner
2021-06-16  7:26 ` [pve-devel] [PATCH v2 manager 2/3] pve6to7: add check for CIFS credentials Fabian Ebner
2021-06-16  7:26 ` [pve-devel] [PATCH v2 manager 3/3] ui: storage: update hint about prune-backups default Fabian Ebner
2021-06-16  7:26 ` Fabian Ebner [this message]
2021-06-16 13:11   ` [pve-devel] [PATCH v2 storage 1/5] postinst: move cifs credential files into subdirectory upon update Thomas Lamprecht
2021-06-17  8:09     ` Fabian Ebner
2021-06-16  7:26 ` [pve-devel] [PATCH v2 storage 2/5] config: mention that maxfiles is deprecated Fabian Ebner
2021-06-16  7:26 ` [pve-devel] [PATCH v2 storage 3/5] config: add backup content type to default local storage Fabian Ebner
2021-06-16  7:26 ` [pve-devel] [PATCH v2 storage 4/5] cephfs: revert safe-guard check for Luminous Fabian Ebner
2021-06-16  7:27 ` [pve-devel] [RFC v2 storage 5/5] cephfs: update reminder for systemd_netmount removal Fabian Ebner
2021-06-16 11:51 ` [pve-devel] applied-series: [PATCH-SERIES v2 manager/storage] Some breaking API changes/cleanups Fabian Grünbichler

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=20210616072700.54289-5-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