[pve-devel] [PATCH v2 storage 1/5] postinst: move cifs credential files into subdirectory upon update

Fabian Ebner f.ebner at proxmox.com
Wed Jun 16 09:26:56 CEST 2021


and drop the compat code.

Signed-off-by: Fabian Ebner <f.ebner at 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






More information about the pve-devel mailing list