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

Changed sysctl configuration to exclusively use templates. #431

Merged
merged 2 commits into from
Nov 14, 2023

Conversation

KoenDG
Copy link
Contributor

@KoenDG KoenDG commented Nov 10, 2023

Ok, I said earlier I'd take a look next week, but I found I had nothing to do this evening, so I had a look and came up with this.

This code provides two templates: one for generic sysctl hardening, and an other for disabling ipv6.

In my opinion, this separates the concerns of generic sysctl hardening versus disabling ipv6. Both can be done on their own, and this way both can have their appropriate tags, and only those, without extras that only apply in certain situations.

This also works around an other issue where systemd's sysctl binary doesn't have the option to load only a single file with sysctl settings. You're stuck restarting the service completely, even if you only want to change 1 file. By splitting this into 2 config files, one doesn't hinder the other.

On top of that, I've added code to remove the ipv6 sysctl file, if the system doesn't have ipv6 support. This can happen if a previous run of these playbooks(or whatever the user did to their device manually) disabled it, and now there's a file there that doesn't apply.

I'm not sure it's strictly necessary to remove it, though it seems logically consistent. Maybe it's more pragmatic to leave it in place?

Which brings me to 2 final question:

  1. Do we want to remove the ipv6 conf file in case the machine doesn't have ipv6 anymore? I'm not sure if it's necessary to leave it in place, after the GRUB settings have been altered and the system has been rebooted.
  2. Are there any tags missing for either case?

I don't think "what if the user wants to re-enable ipv6" is a relevant question for this project, as if focuses on hardening only, not undoing the hardening.

So maybe 3rd question: should something to that effect be added to the readme? Or maybe it's already there, it's been a while since I checked.

I'm not sure about what the linter is going to say about what I've done, so that and any other remarks are welcome.

Previously these settings were applied with ansible's sysctl option, but this ran into conflicts.

This code provides two templates: one for generic sysctl hardening, and an other for disabling ipv6.

Forgot to remove the ipv6 tag from the generic sysctl template.

Cleanup, typos
README.md Show resolved Hide resolved
@KoenDG
Copy link
Contributor Author

KoenDG commented Nov 10, 2023

Cleanup, typos, squashed into 1 commit, should be done now, from my point at this moment.

tasks/ipv6.yml Show resolved Hide resolved
templates/etc/sysctl/sysctl.ipv6.conf.j2 Show resolved Hide resolved
templates/etc/sysctl/sysctl.main.conf.j2 Show resolved Hide resolved
@konstruktoid
Copy link
Owner

  1. Do we want to remove the ipv6 conf file in case the machine doesn't have ipv6 anymore? I'm not sure if it's necessary to leave it in place, after the GRUB settings have been altered and the system has been rebooted.

I'm fine with removing it, since it will be added later if requried.

  1. Are there any tags missing for either case?

No worries, I'm planning to add and remove some later onanyway

So maybe 3rd question: should something to that effect be added to the readme? Or maybe it's already there, it's been a while since I checked.

I'll update the README after this has been merged.

I'm not sure about what the linter is going to say about what I've done, so that and any other remarks are welcome.

The linter was happy 👍

@KoenDG
Copy link
Contributor Author

KoenDG commented Nov 14, 2023

Updated as requested.

@konstruktoid konstruktoid merged commit 6e9c632 into konstruktoid:master Nov 14, 2023
1 check passed
@konstruktoid
Copy link
Owner

Thanks @KoenDG!

@KoenDG KoenDG deleted the sysctl_template branch November 14, 2023 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants