Skip to content

Commit 52c3520

Browse files
committed
feat(googleauth): rhel family support
1 parent 1dcd7d5 commit 52c3520

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

users/googleauth.sls

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# vim: sts=2 ts=2 sw=2 et ai
22
{%- from "users/map.jinja" import users with context %}
33
4-
{%- if not grains['os_family'] in ['RedHat', 'Suse'] %}
4+
{%- if not grains['os_family'] in ['Suse'] %}
55
users_googleauth-package:
66
pkg.installed:
77
- name: {{ users.googleauth_package }}
@@ -33,7 +33,11 @@ users_{{ users.googleauth_dir }}:
3333
users_googleauth-pam-{{ svc }}-{{ name }}:
3434
file.replace:
3535
- name: /etc/pam.d/{{ svc }}
36+
{%- if grains['os_family'] == 'RedHat' %}
37+
- pattern: '^(auth[ \t]*substack[ \t]*password-auth)'
38+
{%- else %}
3639
- pattern: '^(@include[ \t]*common-auth)'
40+
{%- endif %}
3741
- repl: '{{ repl }}\n\1'
3842
- unless: grep pam_google_authenticator.so /etc/pam.d/{{ svc }}
3943
- backup: .bak

users/init.sls

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ include:
5050
- users.sudo
5151
{%- endif %}
5252
{%- if used_googleauth %}
53+
{%- if grains['os_family'] == 'RedHat' %}
54+
- epel
55+
{%- endif %}
5356
- users.googleauth
5457
{%- endif %}
5558
{%- if used_user_files %}
@@ -506,7 +509,28 @@ users_{{ users.sudoers_dir }}/{{ sudoers_d_filename }}:
506509
- name: {{ users.sudoers_dir }}/{{ sudoers_d_filename }}
507510
{% endif %}
508511
509-
{%- if not grains['os_family'] in ['RedHat', 'Suse'] %}
512+
{%- if grains['os_family'] == 'RedHat' %}
513+
policycoreutils-package:
514+
pkg.installed:
515+
- pkgs:
516+
- policycoreutils
517+
{%- if grains['osmajorrelease']|int <= 7 %}
518+
- policycoreutils-python
519+
{%- else %}
520+
- policycoreutils-python-utils
521+
{%- endif %}
522+
users_googleauth_selinux_present:
523+
selinux.fcontext_policy_present:
524+
- name: "{{ users.googleauth_dir }}(/.*)?"
525+
- filetype: 'a'
526+
- sel_user: unconfined_u
527+
- sel_type: ssh_home_t
528+
- sel_level: s0
529+
- require:
530+
- pkg: policycoreutils-package
531+
{%- endif %}
532+
533+
{%- if not grains['os_family'] in ['Suse'] %}
510534
{%- if 'google_auth' in user %}
511535
{%- for svc in user['google_auth'] %}
512536
users_googleauth-{{ svc }}-{{ name }}:
@@ -518,11 +542,20 @@ users_googleauth-{{ svc }}-{{ name }}:
518542
- group: {{ users.root_group }}
519543
- mode: '0600'
520544
- require:
545+
{%- if grains['os_family'] == 'RedHat' %}
546+
- pkg: epel_release
547+
{%- endif %}
521548
- pkg: users_googleauth-package
522549
{%- endfor %}
523550
{%- endif %}
524551
{%- endif %}
525552
553+
{%- if grains['os_family'] == 'RedHat' %}
554+
users_googleauth_selinux_applied:
555+
selinux.fcontext_policy_applied:
556+
- name: {{ users.googleauth_dir }}
557+
{%- endif %}
558+
526559
# this doesn't work (Salt bug), therefore need to run state.apply twice
527560
#include:
528561
# - users

users/map.jinja

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
'polkit_dir': '/etc/polkit-1/localauthority.conf.d',
3131
'polkit_defaults': 'unix-group:sudo;'
3232
},
33+
'RedHat': {
34+
'sudoers_dir': '/etc/sudoers.d',
35+
'sudoers_file': '/etc/sudoers',
36+
'googleauth_dir': '/etc/google_authenticator.d',
37+
'root_group': 'root',
38+
'shell': '/bin/bash',
39+
'visudo_shell': '/bin/bash',
40+
'bash_package': 'bash',
41+
'sudo_package': 'sudo',
42+
'googleauth_package': 'google-authenticator',
43+
'polkit_dir': '/etc/polkit-1/localauthority.conf.d',
44+
'polkit_defaults': 'unix-group:sudo;'
45+
},
3346
'Gentoo': {
3447
'sudoers_dir': '/etc/sudoers.d',
3548
'sudoers_file': '/etc/sudoers',

0 commit comments

Comments
 (0)