Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

Commit

Permalink
Centralize root check, user ansible var, not env var
Browse files Browse the repository at this point in the history
fixes #17 - the current check logic was failing under docker which
doesnt always inject a `USER` environment variable. Rather than try to
work around that in docker, lets update our root check logic to be more
universally compatible.
  • Loading branch information
msheiny committed Feb 6, 2018
1 parent 2c657b3 commit fd900d2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
13 changes: 13 additions & 0 deletions tasks/become_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Run setup as same user as role
setup:

- name: Stop if running with elevated privileges.
fail:
msg: >-
WARNING! You should not compile the Linux kernel with
superuser privileges. Doing so may create an unbootable
system. See Greg Kroah-Hartman's Linux Kernel in a Nutshell
for anecdotes about how doing so has broken systems
in the past: http://www.kroah.com/lkn/
when: ansible_user_id == 'root'
10 changes: 0 additions & 10 deletions tasks/main-stable.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
---
- name: Stop if running with elevated privileges.
fail:
msg: >-
WARNING! You should not compile the Linux kernel with
superuser privileges. Doing so may create an unbootable
system. See Greg Kroah-Hartman's Linux Kernel in a Nutshell
for anecdotes about how doing so has broken systems
in the past: http://www.kroah.com/lkn/
when: ansible_env.USER == 'root'

# Install packages before fetching dynamic URLs, since python-requests
# is required by the URL-fetching Ansible module.
- include: packages.yml
Expand Down
10 changes: 0 additions & 10 deletions tasks/main-unofficial.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
---
- name: Stop if running with elevated privileges.
fail:
msg: >-
WARNING! You should not compile the Linux kernel with
superuser privileges. Doing so may create an unbootable
system. See Greg Kroah-Hartman's Linux Kernel in a Nutshell
for anecdotes about how doing so has broken systems
in the past: http://www.kroah.com/lkn/
when: ansible_env.USER == 'root'

- name: Install stretch backports repository.
become: yes
apt_repository:
Expand Down
2 changes: 2 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
- include: become_check.yml

- include: main-stable.yml
when: grsecurity_build_patch_type != 'unofficial'

Expand Down

0 comments on commit fd900d2

Please sign in to comment.