Skip to content

make ssh_authorized_key readonly #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/puppet/provider/ssh_authorized_key/parsed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def dir_perm
0o700
end

def file_perm
def file_perm_readonly
0o444
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know multiple organisations where world readable files aren't allowed. I don't think it's a good idea to implement such a breaking change. I think it makes more sense to add a parameter for the mode and default to 0600 for now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... sure, but how would that even work considering multiple invocations of the type can have different mode parameters? how would we handle that conflict? we'd just let puppet flap?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case puppet flaps or even better: the type notices it and fails.

end

def file_perm_writable
0o600
end

Expand Down Expand Up @@ -84,7 +88,7 @@ def flush
end
super

File.chmod(file_perm, target)
File.chmod(file_perm_writable, target)
end
# to avoid race conditions when handling permissions as a privileged user
# (CVE-2011-3870) we use the trusted_path method to ensure the entire
Expand All @@ -97,7 +101,7 @@ def flush
gid = Puppet::Util.gid(@resource.should(:user))
File.open(target) do |target|
target.chown(uid, gid)
target.chmod(file_perm)
target.chmod(file_perm_readonly)
end
end
end
Expand Down