summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2014-12-18 02:25:35 +0600
committerDaniil Baturin <daniil@baturin.org>2014-12-18 02:25:35 +0600
commit952981667de42a279a5e1d3a631d11811d0c3011 (patch)
tree1525dccc47d9a13ff38757e0ead31855ec67a4ea
parente8f01f4c49b6985b127ea02e31592b4f34508a68 (diff)
parent4b74107a954940eefbb79089e5778179eca66b52 (diff)
downloadvyatta-cfg-system-952981667de42a279a5e1d3a631d11811d0c3011.tar.gz
vyatta-cfg-system-952981667de42a279a5e1d3a631d11811d0c3011.zip
Merge pull request #36 from jrb/helium
Adding support for spaces in the key comment field. Bug 411
-rwxr-xr-xscripts/vyatta-load-user-key.pl23
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";