puppetlabs / puppetlabs-sshkeys_core

Apache License 2.0
4 stars 32 forks source link

(MODULES-9578) Create ssh_authorized_key in root path #20

Closed GabrielNagy closed 5 years ago

GabrielNagy commented 5 years ago

Previously, when the target property was set, the ssh_authorized_key resource could not create directories/files within root-owned paths. This behavior is due to the module switching context to the user, then attempting to create the directory/file as the specified user, ultimately failing because of insufficient permissions.

This commit removes the context change logic, and creates the authorized_key file as root, then executes FileUtils.chown to make it owned by the target user.

This commit also removes the functionality that created parent directories, since it should not be in the scope of this module.

Cherry-picked 2 commits from @pillarsdotnet's tree, related to tests.

GabrielNagy commented 5 years ago

Acceptance tests are passing: pic-selected-190813-1556-28

GabrielNagy commented 5 years ago

@joshcooper I've restored the functionality that creates the parent directory (in case we're writing as the user/path is not trusted), so this should not be a breaking change anymore.

GabrielNagy commented 5 years ago

Fixed the rubocop stuff, I'll squash my commits when you're good with this @joshcooper

GabrielNagy commented 5 years ago

Passing acceptance run (except for ubuntu 14.04 which is no longer in our pipeline and can be ignored): https://jenkins-master-prod-1.delivery.puppetlabs.net/view/modules/view/Core/view/sshkeys_core/view/adhoc/job/forge-module_puppetlabs-sshkeys_core_intn-sys_nightly-adhoc/2/