[pve-devel] [PATCH storage] CephConfig: ensure newline in $secret parameter

Aaron Lauterer a.lauterer at proxmox.com
Mon Jan 24 15:18:40 CET 2022



On 1/24/22 15:03, Thomas Lamprecht wrote:
> On 17.01.22 11:11, Aaron Lauterer wrote:
>> Ping? Patch should still apply
>>
>> On 11/26/21 16:02, Aaron Lauterer wrote:
>>> Ensure that the user provided $secret ends in a newline. Otherwise we
>>> will have Input/output errors from rados_connect.
>>>
>>> Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
>>> ---
>>>    PVE/CephConfig.pm | 1 +
>>>    1 file changed, 1 insertion(+)
>>>
>>> diff --git a/PVE/CephConfig.pm b/PVE/CephConfig.pm
>>> index 5c94a04..ac28e76 100644
>>> --- a/PVE/CephConfig.pm
>>> +++ b/PVE/CephConfig.pm
>>> @@ -227,6 +227,7 @@ sub ceph_create_keyfile {
>>>        eval {
>>>            if (defined($secret)) {
>>>            mkdir '/etc/pve/priv/ceph';
>>> +        $secret = "${secret}\n" if $secret !~ m/\n$/;
> 
> FWIW, we normally use chomp for this, e.g.:
> 
> chomp $secret
> file_set_contents($ceph_storage_keyring, "$secret\n", 0400);
> 
> https://perldoc.perl.org/functions/chomp
> 
> IIRC, that little nit made me not apply+push it immediately and then it seems
> like it went under the radar.

Okay. I'll incorporate that in a v2





More information about the pve-devel mailing list