Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Iliya Manolov
slapos
Commits
a2c96eb4
Commit
a2c96eb4
authored
Sep 29, 2016
by
Nicolas Wavrant
Committed by
Alain Takoudjou
Sep 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dropbear recipe: correctly split keys for authorized_key file when more than one is given
/reviewed-on
nexedi/slapos!101
parent
ec6f62ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
slapos/recipe/dropbear.py
slapos/recipe/dropbear.py
+7
-2
slapos/test/recipe/test_dropbear.py
slapos/test/recipe/test_dropbear.py
+22
-0
No files found.
slapos/recipe/dropbear.py
View file @
a2c96eb4
...
...
@@ -168,15 +168,20 @@ def keysplit(s):
"""
Split a string like "ssh-rsa AKLFKJSL..... ssh-rsa AAAASAF...."
and return the individual key_type + key strings.
TODO: handle comments in ssh keys, which are generated
by default at key creation.
"""
s
=
s
.
replace
(
'
\
n
'
,
' '
)
si
=
iter
(
s
.
split
(
' '
))
while
True
:
key_type
=
next
(
si
)
if
key_type
==
''
:
continue
try
:
key_value
=
next
(
si
)
except
StopIteration
:
# odd number of elements, should not happen, yield the last one by itself
yield
key_type
# odd number of elements, should not happen
break
yield
'%s %s'
%
(
key_type
,
key_value
)
...
...
slapos/test/recipe/test_dropbear.py
0 → 100644
View file @
a2c96eb4
import
unittest
from
slapos.recipe.dropbear
import
keysplit
class
TestAuthorizedKey
(
unittest
.
TestCase
):
def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0u9T1qBjU4/raTWjUj2/DhVDNa0gX6OE/xUIdMZMqeeVHndFqb1lkORiPoXcTrD734HNvrmW73rI5TBWMK86RQ=="
]
for
given_key
in
given_key_list
:
tested_result
=
[]
for
key
in
keysplit
(
given_key
):
tested_result
.
append
(
key
)
self
.
assertEqual
(
tested_result
,
expected_result
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment