Skip to content

Commit

Permalink
rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Feb 1, 2019
1 parent dc80138 commit 59979a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/installation/ssh_key.rb
Expand Up @@ -47,11 +47,11 @@ def write_files(dir)
files.each do |file|
path = File.join(dir, file.filename)
IO.write(path, file.content)
if file.filename.match(/^ssh_host_.*(key)$/)
if file.filename =~ /^ssh_host_.*(key)$/
# ssh deamon accepts only private keys with restricted
# file permissions.
log.info("Set permissions of #{file.filename} to 0600")
File.chmod(0600, path)
File.chmod(0o600, path)
else
# Taking already given permissions
log.info("Set permissions of #{file.filename} to #{file.permissions.to_s(8)}")
Expand Down
4 changes: 2 additions & 2 deletions test/ssh_key_test.rb
Expand Up @@ -8,12 +8,12 @@

describe "#write_files" do
before do
sshkey.read_files(FIXTURES_DIR.join("root2/etc/ssh",subject.name).to_s)
sshkey.read_files(FIXTURES_DIR.join("root2/etc/ssh", subject.name).to_s)
end

it "writes ssh keys with the right permissions" do
expect(IO).to receive(:write).twice
expect(File).to receive(:chmod).with(0600,
expect(File).to receive(:chmod).with(0o600,
"/mnt/etc/ssh/ssh_host_ed25519_key")
expect(File).to receive(:chmod).with(33188,
"/mnt/etc/ssh/ssh_host_ed25519_key.pub")
Expand Down

0 comments on commit 59979a0

Please sign in to comment.