public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH v2 storage] CephConfig: ensure newline in $secret and $cephfs_secret parameter
@ 2022-01-24 15:11 Aaron Lauterer
  2022-01-25  9:54 ` Fabian Ebner
  2022-01-25  9:58 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Aaron Lauterer @ 2022-01-24 15:11 UTC (permalink / raw)
  To: pve-devel

Ensure that the user provided $secret ends in a newline. Otherwise we
will have Input/output errors from rados_connect.

For consistency and possible future proofing, also add a newline to
CephFS secrets.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
---

changes:
- instead conditional with regex, use chomp and always adding the newline
- do the same to $cephfs_secret

From previous version (though not sure if they still apply with these
changes):

Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
Tested-by: Fabian Ebner <f.ebner@proxmox.com>

 PVE/CephConfig.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/PVE/CephConfig.pm b/PVE/CephConfig.pm
index 5c94a04..c388f02 100644
--- a/PVE/CephConfig.pm
+++ b/PVE/CephConfig.pm
@@ -227,14 +227,16 @@ sub ceph_create_keyfile {
 	eval {
 	    if (defined($secret)) {
 		mkdir '/etc/pve/priv/ceph';
-		PVE::Tools::file_set_contents($ceph_storage_keyring, $secret, 0400);
+		chomp $secret;
+		PVE::Tools::file_set_contents($ceph_storage_keyring, "${secret}\n", 0400);
 	    } elsif ($type eq 'rbd') {
 		mkdir '/etc/pve/priv/ceph';
 		PVE::Tools::file_copy($ceph_admin_keyring, $ceph_storage_keyring);
 	    } elsif ($type eq 'cephfs') {
 		my $cephfs_secret = $ceph_get_key->($ceph_admin_keyring, 'admin');
 		mkdir '/etc/pve/priv/ceph';
-		PVE::Tools::file_set_contents($ceph_storage_keyring, $cephfs_secret, 0400);
+		chomp $cephfs_secret;
+		PVE::Tools::file_set_contents($ceph_storage_keyring, "${cephfs_secret}\n", 0400);
 	   }
 	};
 	if (my $err = $@) {
-- 
2.30.2





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH v2 storage] CephConfig: ensure newline in $secret and $cephfs_secret parameter
  2022-01-24 15:11 [pve-devel] [PATCH v2 storage] CephConfig: ensure newline in $secret and $cephfs_secret parameter Aaron Lauterer
@ 2022-01-25  9:54 ` Fabian Ebner
  2022-01-25  9:58 ` [pve-devel] applied: " Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Fabian Ebner @ 2022-01-25  9:54 UTC (permalink / raw)
  To: Aaron Lauterer, pve-devel

Am 24.01.22 um 16:11 schrieb Aaron Lauterer:
> Ensure that the user provided $secret ends in a newline. Otherwise we
> will have Input/output errors from rados_connect.
> 
> For consistency and possible future proofing, also add a newline to
> CephFS secrets.
> 
> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
> ---
> 
> changes:
> - instead conditional with regex, use chomp and always adding the newline
> - do the same to $cephfs_secret
> 
>  From previous version (though not sure if they still apply with these
> changes):
> 

Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
Tested-by: Fabian Ebner <f.ebner@proxmox.com>

since I gave the new version a go.

> 
>   PVE/CephConfig.pm | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/CephConfig.pm b/PVE/CephConfig.pm
> index 5c94a04..c388f02 100644
> --- a/PVE/CephConfig.pm
> +++ b/PVE/CephConfig.pm
> @@ -227,14 +227,16 @@ sub ceph_create_keyfile {
>   	eval {
>   	    if (defined($secret)) {
>   		mkdir '/etc/pve/priv/ceph';
> -		PVE::Tools::file_set_contents($ceph_storage_keyring, $secret, 0400);
> +		chomp $secret;
> +		PVE::Tools::file_set_contents($ceph_storage_keyring, "${secret}\n", 0400);
>   	    } elsif ($type eq 'rbd') {
>   		mkdir '/etc/pve/priv/ceph';
>   		PVE::Tools::file_copy($ceph_admin_keyring, $ceph_storage_keyring);
>   	    } elsif ($type eq 'cephfs') {
>   		my $cephfs_secret = $ceph_get_key->($ceph_admin_keyring, 'admin');
>   		mkdir '/etc/pve/priv/ceph';
> -		PVE::Tools::file_set_contents($ceph_storage_keyring, $cephfs_secret, 0400);
> +		chomp $cephfs_secret;
> +		PVE::Tools::file_set_contents($ceph_storage_keyring, "${cephfs_secret}\n", 0400);
>   	   }
>   	};
>   	if (my $err = $@) {




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pve-devel] applied: [PATCH v2 storage] CephConfig: ensure newline in $secret and $cephfs_secret parameter
  2022-01-24 15:11 [pve-devel] [PATCH v2 storage] CephConfig: ensure newline in $secret and $cephfs_secret parameter Aaron Lauterer
  2022-01-25  9:54 ` Fabian Ebner
@ 2022-01-25  9:58 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2022-01-25  9:58 UTC (permalink / raw)
  To: Proxmox VE development discussion, Aaron Lauterer

On 24.01.22 16:11, Aaron Lauterer wrote:
> Ensure that the user provided $secret ends in a newline. Otherwise we
> will have Input/output errors from rados_connect.
> 
> For consistency and possible future proofing, also add a newline to
> CephFS secrets.
> 
> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
> ---
> 
> changes:
> - instead conditional with regex, use chomp and always adding the newline
> - do the same to $cephfs_secret
> 
> From previous version (though not sure if they still apply with these
> changes):

good call for including them here

> 
> Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
> Tested-by: Fabian Ebner <f.ebner@proxmox.com>

added those now that Fabian reconfirmed them for v2 too

> 
>  PVE/CephConfig.pm | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-25  9:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 15:11 [pve-devel] [PATCH v2 storage] CephConfig: ensure newline in $secret and $cephfs_secret parameter Aaron Lauterer
2022-01-25  9:54 ` Fabian Ebner
2022-01-25  9:58 ` [pve-devel] applied: " Thomas Lamprecht

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