Skip to content
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

Add temporary passwordless sudo #148

Closed
wants to merge 1 commit into from

Conversation

tuxpeople
Copy link

This should fix #147

Once #79 is ready, this can be removed again.

@geerlingguy
Copy link
Owner

The major issue I have with this approach is that if the playbook stops for some reason after it enables the permission, but before it disables it, the system would have passwordless sudo enabled until someone either manually deleted the config, or successfully completes the playbook again.

@tuxpeople
Copy link
Author

tuxpeople commented Apr 1, 2022

Understood. But an attacker would need your password anyway to login prior to being able to passwordless sudo.

There would also be an option to use the SUDO_ASKPASS together with the keychain, which would only work to retrieve the password when the keychain is unlocked.

How about this:

- name: Run the .osx dotfiles passwordless.
  block:
    - name: Add temporary passwordless sudo permissions
        ansible.builtin.copy:
          content: "{{ ansible_user }} ALL=(ALL) NOPASSWD: ALL"
          dest: "/private/etc/sudoers.d/99_tmp_ansible"
          validate: /usr/sbin/visudo -csf %s
          mode: 0644
        become: true

    - name: Run .osx dotfiles.
      command: "{{ osx_script }}"
      changed_when: false
      become: false 

  always:
    - name: Remove temporary passwordless sudo permissions
        ansible.builtin.file:
          path: "/private/etc/sudoers.d/99_tmp_ansible"
          state: absent
        become: true 

In this case it would be cleaned up even if the .osx run fails. That block would also be possible around the necessary parts of the playbook.

@stale
Copy link

stale bot commented Jul 10, 2022

This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark pull requests as stale.

@stale stale bot added the stale label Jul 10, 2022
@stale
Copy link

stale bot commented Aug 12, 2022

This pull request has been closed due to inactivity. If you feel this is in error, please reopen the pull request or file a new PR with the relevant details.

@stale stale bot closed this Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Propose change for the .osx todo
2 participants