Skip to content

Instantly share code, notes, and snippets.

@jonyesno
Created October 29, 2010 10:04
Show Gist options
  • Save jonyesno/653266 to your computer and use it in GitHub Desktop.
Save jonyesno/653266 to your computer and use it in GitHub Desktop.
Patch to make Puppet also assume the target user's group when writing authorized_keys
--- /usr/lib/ruby/site_ruby/1.8/puppet/provider/ssh_authorized_key/parsed.rb.orig 2010-10-29 10:55:56.000000000 +0100
+++ /usr/lib/ruby/site_ruby/1.8/puppet/provider/ssh_authorized_key/parsed.rb 2010-10-29 11:12:59.000000000 +0100
@@ -64,12 +64,13 @@
def flush
raise Puppet::Error, "Cannot write SSH authorized keys without user" unless user
raise Puppet::Error, "User '#{user}' does not exist" unless uid = Puppet::Util.uid(user)
+ raise Puppet::Error, "Can't obtain gid for user '#{user}'" unless gid = Puppet::Util.gid(user)
unless File.exist?(dir = File.dirname(target))
Puppet.debug "Creating #{dir}"
Dir.mkdir(dir, dir_perm)
- File.chown(uid, nil, dir)
+ File.chown(uid, gid, dir)
end
- Puppet::Util::SUIDManager.asuser(user) { super }
+ Puppet::Util::SUIDManager.asuser(user, gid) { super }
File.chown(uid, nil, target)
File.chmod(file_perm, target)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment