diff options
author | Jared R. Baldridge <jrb@expunge.us> | 2014-12-17 12:40:30 -0500 |
---|---|---|
committer | Alex Harpin <development@landsofshadow.co.uk> | 2014-12-20 18:37:06 +0000 |
commit | 9cb23798570a6e7417dc0b849337a6abb0b00849 (patch) | |
tree | 6bd457d7c30f79f474e459e22420bb573aa02e82 /scripts/vyatta-load-user-key.pl | |
parent | bfa34102dfe62a1693ed3a8afcffb1dd203f9f6f (diff) | |
download | vyatta-cfg-system-9cb23798570a6e7417dc0b849337a6abb0b00849.tar.gz vyatta-cfg-system-9cb23798570a6e7417dc0b849337a6abb0b00849.zip |
Adding support for spaces in the key comment field. Bug 411
Diffstat (limited to 'scripts/vyatta-load-user-key.pl')
-rwxr-xr-x | scripts/vyatta-load-user-key.pl | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/scripts/vyatta-load-user-key.pl b/scripts/vyatta-load-user-key.pl index 8641ae5b..5c34b6ab 100755 --- a/scripts/vyatta-load-user-key.pl +++ b/scripts/vyatta-load-user-key.pl @@ -101,6 +101,14 @@ sub geturl { return $curl; } +sub validate_keytype { + my ($keytype) = @_; + if ($keytype eq 'ssh-rsa' || $keytype eq 'ssh-dss') { + return 1; + } + return 0; +} + sub getkeys { my ($user, $in) = @_; @@ -116,14 +124,19 @@ sub getkeys { my $options; $options = shift @fields - if ($#fields == 3); + if (validate_keytype $fields[1]); + + my $keytype; + $keytype = shift @fields; + + my $keycode; + $keycode = shift @fields; - die "Not a valid key file format (see man sshd)" - unless $#fields == 2; + my $comment; + $comment = join(' ', @fields); - my ($keytype, $keycode, $comment) = @fields; die "Unknown key type $keytype : must be ssh-rsa or ssh-dss\n" - unless ($keytype eq 'ssh-rsa' || $keytype eq 'ssh-dss'); + unless validate_keytype $keytype; my $cmd = "set system login user $user authentication public-keys $comment"; |