[pve-devel] [PATCH] - preserve authorized_key key order - identify double keys by key and not by comment
Dietmar Maurer
dietmar at proxmox.com
Thu Aug 30 07:31:46 CEST 2012
Ok, committed - please review and test:
https://git.proxmox.com/?p=pve-cluster.git;a=commitdiff;h=2055b0a9e41912cb02810b621608b24430c8a1fe
> -----Original Message-----
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> bounces at pve.proxmox.com] On Behalf Of Dietmar Maurer
> Sent: Donnerstag, 30. August 2012 07:05
> To: Stefan Priebe; pve-devel at pve.proxmox.com
> Subject: Re: [pve-devel] [PATCH] - preserve authorized_key key order -
> identify double keys by key and not by comment
>
> > + my @lines = split(/\n/, $data);
> > + foreach my $line (@lines) {
> > + if ($line =~ m/^ssh-rsa\s+(\S+)\s+\S+$/) {
> > + next if ($vhash->{$1});
> > + $vhash->{$1} = 1;
> > + }
> > + $newdata .= $line . "\n";
> > }
> > -
> > - $newdata .= join("", values(%$vhash));
>
> Or:
>
> diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm index
> a877d41..4b8a075 100644
> --- a/data/PVE/Cluster.pm
> +++ b/data/PVE/Cluster.pm
> @@ -1018,13 +1018,11 @@ sub ssh_merge_keys {
> while ($data && $data =~ s/^((.*?)(\n|$))//) {
> my $line = "$2\n";
> if ($line =~ m/^ssh-rsa\s+\S+\s+(\S+)$/) {
> - $vhash->{$1} = $line;
> - } else {
> - $newdata .= $line;
> + next if $vhash->{$1};
> + $vhash->{$1} = 1;
> }
> + $newdata .= $line;
> }
> -
> - $newdata .= join("", values(%$vhash));
>
> PVE::Tools::file_set_contents($sshauthkeys, $newdata, 0600); }
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list