CephConfig: ensure newline in $secret and $cephfs_secret parameter

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>
Reviewed-by: Fabian Ebner <f.ebner@proxmox.com>
Tested-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Aaron Lauterer
2022-01-24 16:11:53 +01:00
committed by Thomas Lamprecht
parent 73dfe360dd
commit e7bc1f03b7

View File

@ -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 = $@) {