-
Notifications
You must be signed in to change notification settings - Fork 31
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
(MODULES-9578) Create ssh_authorized_key in root path #20
(MODULES-9578) Create ssh_authorized_key in root path #20
Conversation
0028eac
to
4eb9141
Compare
54db0bb
to
baba7be
Compare
baba7be
to
f95ddad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; added publicly-visible link from MODULES-9578.
f95ddad
to
51f191a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not safe for root to write to a users' untrusted home directory. Otherwise, the user could create a symlink and have root overwrite ~root/.ssh/authorized_keys and now the user can login as root.
503392e
to
dd2544b
Compare
d8fa1f0
to
4cc041d
Compare
978a8f3
to
55d73fc
Compare
a47a7df
to
0755b94
Compare
|
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the target doesn't exist, then the path isn't considered trusted, and we try, but fail to write the key as the user
904895b
to
7d2002c
Compare
7d2002c
to
f84ea6f
Compare
|
Fixed the rubocop stuff, I'll squash my commits when you're good with this @joshcooper |
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 adds a new parameter, `drop_privileges` which when set to false allows the module to write a ssh_authorized_key file in a privileged path. Due to the possible security implications of this, the parameter must be manually specified in order to activate this functionality. A path is considered to be privileged/trusted if all of its ancestors: - do not contain any symlinks - have the same owner as the user who runs Puppet - are not world/group writable
a46d859
to
b2c153b
Compare
|
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/ |

Previously, when the
targetproperty 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 theuser, 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 executesFileUtils.chownto 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.