Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Conversation

@ghost
Copy link

@ghost ghost commented Apr 6, 2019

Hi there 🙃

I encountered the same issue as described on #212. Whereas I don’t think tweaking the firewalld is a good idea because it adds dependencies, we should consider allowing ssh ports on SELinux policy if they differ from the default values.

@rndmh3ro rndmh3ro self-assigned this Apr 10, 2019
@rndmh3ro
Copy link
Member

Hey @guilieb,

this looks good on first view. I'll like to check this manually since travis skips the selinux-tasks.

@ghost
Copy link
Author

ghost commented Apr 10, 2019

Done 😉. Thanks for the review !

state: present
with_items:
- "{{ ssh_server_ports }}"
when: ssh_server_ports != ['22']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this when-condition since the seport-module is idemopent and will not change anything here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s because I’m too impatient, I’d like to skip tasks if unnecessary. I’m changin' this !

@rndmh3ro
Copy link
Member

Hey Guillaume,

so I tested this and its still looking good! I added one additional comment and if this is taken care of its ready to be merged!

@ghost
Copy link
Author

ghost commented Apr 17, 2019

Done 😉

@rndmh3ro
Copy link
Member

There's a failure now for Centos 6 machines.
The reason is SELinux was installed but not activated. The other tasks did not fail because they do not rely on SELinux being activated. However the seport-module relies on SELinux being activated.

So that's why I revamped the checking of selinux. With the following patch, the task should only run when SELinux is installed and activated:

diff --git a/tasks/hardening.yml b/tasks/hardening.yml
index ed30320..9194495 100644
--- a/tasks/hardening.yml
+++ b/tasks/hardening.yml
@@ -71,13 +71,6 @@
     - ssh_challengeresponseauthentication
     - ssh_google_auth
 
-- name: test to see if selinux is installed and running
-  command: getenforce
-  register: sestatus
-  failed_when: false
-  changed_when: false
-  check_mode: no
-
 - name: include selinux specific tasks
   include_tasks: selinux.yml
-  when: sestatus.rc == 0
+  when: ansible_selinux and ansible_selinux.status != "disabled"
diff --git a/tasks/selinux.yml b/tasks/selinux.yml
index 531e459..0114625 100644
--- a/tasks/selinux.yml
+++ b/tasks/selinux.yml
@@ -57,7 +57,7 @@
   - name: install selinux policy
     command: semodule -i {{ ssh_custom_selinux_dir }}/ssh_password.pp
 
-  when: not ssh_use_pam and sestatus.stdout != 'Disabled' and ssh_password_module.stdout.find('ssh_password') != 0
+  when: not ssh_use_pam and ansible_selinux != 'Disabled' and ssh_password_module.stdout.find('ssh_password') != 0
 
 # The following tasks only get executed when selinux is installed, UsePam is 'yes' and the ssh_password module is installed.
 # See http://danwalsh.livejournal.com/12333.html for more info

Can you apply this patch to your PR and commit it, please?

Signed-off-by: Guillaume Bernard <contact@guillaume-bernard.fr>
@ghost
Copy link
Author

ghost commented Apr 29, 2019

Done again !

@rndmh3ro
Copy link
Member

Thanks! I'll have to make some additional changes, but I'll do these by myself.

@rndmh3ro rndmh3ro merged commit 7907e48 into dev-sec:master Apr 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant