diff options
author | Jared R. Baldridge <jrb@expunge.us> | 2014-12-17 12:40:30 -0500 |
---|---|---|
committer | Jared R. Baldridge <jrb@expunge.us> | 2014-12-17 14:13:55 -0500 |
commit | 4b74107a954940eefbb79089e5778179eca66b52 (patch) | |
tree | 1525dccc47d9a13ff38757e0ead31855ec67a4ea /scripts | |
parent | e8f01f4c49b6985b127ea02e31592b4f34508a68 (diff) | |
download | vyatta-cfg-system-4b74107a954940eefbb79089e5778179eca66b52.tar.gz vyatta-cfg-system-4b74107a954940eefbb79089e5778179eca66b52.zip |
Adding support for spaces in the key comment field. Bug 411
Diffstat (limited to 'scripts')
-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"; |