Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
snf-ganeti
Commits
4cc2a728
Commit
4cc2a728
authored
Oct 30, 2007
by
Michael Hanselmann
Browse files
Fix _UpdateEtcHosts to understand empty lines.
Reviewed-by: schreiberal
parent
1a8c0ce1
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/cmdlib.py
View file @
4cc2a728
...
...
@@ -386,39 +386,35 @@ def _UpdateKnownHosts(fullnode, ip, pubkey):
add_lines
=
[]
removed
=
False
while
True
:
rawline
=
f
.
readline
()
for
rawline
in
f
:
logger
.
Debug
(
'read %s'
%
(
repr
(
rawline
),))
if
not
rawline
:
# End of file
break
line
=
rawline
.
split
(
'
\n
'
)[
0
]
parts
=
line
.
split
(
' '
)
fields
=
parts
[
0
].
split
(
','
)
key
=
parts
[
2
]
haveall
=
True
havesome
=
False
for
spec
in
[
ip
,
fullnode
]:
if
spec
not
in
fields
:
haveall
=
False
if
spec
in
fields
:
havesome
=
True
logger
.
Debug
(
"key, pubkey = %s."
%
(
repr
((
key
,
pubkey
)),))
if
haveall
and
key
==
pubkey
:
inthere
=
True
save_lines
.
append
(
rawline
)
logger
.
Debug
(
"Keeping known_hosts '%s'."
%
(
repr
(
rawline
),))
continue
parts
=
rawline
.
rstrip
(
'
\r\n
'
).
split
()
# Ignore unwanted lines
if
len
(
parts
)
>=
3
and
not
rawline
.
lstrip
()[
0
]
==
'#'
:
fields
=
parts
[
0
].
split
(
','
)
key
=
parts
[
2
]
haveall
=
True
havesome
=
False
for
spec
in
[
ip
,
fullnode
]:
if
spec
not
in
fields
:
haveall
=
False
if
spec
in
fields
:
havesome
=
True
logger
.
Debug
(
"key, pubkey = %s."
%
(
repr
((
key
,
pubkey
)),))
if
haveall
and
key
==
pubkey
:
inthere
=
True
save_lines
.
append
(
rawline
)
logger
.
Debug
(
"Keeping known_hosts '%s'."
%
(
repr
(
rawline
),))
continue
if
havesome
and
(
not
haveall
or
key
!=
pubkey
):
removed
=
True
logger
.
Debug
(
"Discarding known_hosts '%s'."
%
(
repr
(
rawline
),))
continue
if
havesome
and
(
not
haveall
or
key
!=
pubkey
):
removed
=
True
logger
.
Debug
(
"Discarding known_hosts '%s'."
%
(
repr
(
rawline
),))
continue
save_lines
.
append
(
rawline
)
...
...
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