Skip to content

Commit 42697b4

Browse files
author
h00die
committed
append over read and write
1 parent c50f935 commit 42697b4

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

modules/post/linux/manage/sshkey_persistence.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,8 @@ def write_key(paths, auth_key_file, sep)
119119
paths.each do |path|
120120
path.chomp!
121121
authorized_keys = "#{path}/#{auth_key_file}"
122-
if file?(authorized_keys)
123-
print_status("Adding key to #{authorized_keys}")
124-
data = read_file(authorized_keys)
125-
data << "\n#{our_pub_key}"
126-
else
127-
print_status("Creating #{authorized_keys}")
128-
data = our_pub_key
129-
end
130-
write_file(authorized_keys, data)
122+
print_status("Adding key to #{authorized_keys}")
123+
append_file(authorized_keys, "\n#{our_pub_key}")
131124
print_good("Key Added")
132125
if datastore['PubKey'].nil?
133126
path_array = path.split(sep)

0 commit comments

Comments
 (0)