From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <t.lamprecht@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 0980472B96
 for <pve-devel@lists.proxmox.com>; Wed, 16 Jun 2021 15:11:44 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 0032311BD1
 for <pve-devel@lists.proxmox.com>; Wed, 16 Jun 2021 15:11:44 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 04F4511BC3
 for <pve-devel@lists.proxmox.com>; Wed, 16 Jun 2021 15:11:43 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id CD3D843B5D
 for <pve-devel@lists.proxmox.com>; Wed, 16 Jun 2021 15:11:42 +0200 (CEST)
Message-ID: <422e61d2-821c-d58b-9bcd-2c270c64c88c@proxmox.com>
Date: Wed, 16 Jun 2021 15:11:37 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101
 Thunderbird/90.0
Content-Language: en-US
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Fabian Ebner <f.ebner@proxmox.com>
References: <20210616072700.54289-1-f.ebner@proxmox.com>
 <20210616072700.54289-5-f.ebner@proxmox.com>
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
In-Reply-To: <20210616072700.54289-5-f.ebner@proxmox.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  1
 AWL -1.583 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 KAM_SOMETLD_ARE_BAD_TLD      5 .stream, .trade, .pw, .top, .press, .guru,
 .casa & .date TLD Abuse
 NICE_REPLY_A           -0.095 Looks like a legit reply (A)
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [base.pw]
Subject: Re: [pve-devel] [PATCH v2 storage 1/5] postinst: move cifs
 credential files into subdirectory upon update
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Wed, 16 Jun 2021 13:11:44 -0000

On 16.06.21 09:26, Fabian Ebner wrote:
> +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

can we diff in this case and remove the old one if the files are identical?

> +                    else
> +                        echo "Info: renaming $file to $target" >&2
> +                        mv "$file" "$target"
> +                    fi
> +                fi
> +            done
> +        fi
> +    fi
> +    ;;
> +
> +esac
> +
> +exit 0
>