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

nixos/openvpn: user, forwarding and local state dir #65878

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

peterhoeg
Copy link
Member

@peterhoeg peterhoeg commented Aug 3, 2019

Motivation for this change

We change a few things here:

a) Create the local openvpn user and group so that openvpn can drop privileges.
This is not switched on by default.

b) Define an option to enable IP forwarding which would have to be defined
outside of the openvpn module.

c) Create a local state and runtime directories for anything openvpn might create (replay
persistence logs, current connections, etc).

d) Launch openvpn in a separate openvpn.slice slice and activate from a dedicated openvpn.target target. The former allows one to easily check the logs across all instances, apply resource limitations and stop all instances. The latter allows you to easily start all the instances.

NOTE: I strongly recommend looking at this diff while ignoring whitespace due to the indent changes (options were indented further due to the introduction of a new option) - https://github.com/NixOS/nixpkgs/pull/65878/files?w=1

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @viric

Copy link
Member

@teto teto left a comment

Choose a reason for hiding this comment

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

looks good to me but I don't use openvpn.
can it work without net.ipv4.ip_forward ? or is like for firewalls and default to the secure version.
what about ipv6 ?

@peterhoeg
Copy link
Member Author

peterhoeg commented Aug 5, 2019 via email

@teto
Copy link
Member

teto commented Aug 5, 2019

that sounds similar to the openFirewall option: you very likely need it but we cna't enable it by default. Aren't there some UDP ports that should be open as well ? would it make sense to make ports configurable (I believe that's common to avoid scans on specific ports) ?

@peterhoeg
Copy link
Member Author

peterhoeg commented Aug 5, 2019 via email

@peterhoeg
Copy link
Member Author

peterhoeg commented Aug 5, 2019 via email

@@ -211,6 +226,24 @@ in

boot.kernelModules = [ "tun" ];

boot.kernel.sysctl = lib.mkIf cfg.enableForwarding ({
"net.ipv4.ip_forward" = true;
} // (if config.networking.enableIPv6 then {
Copy link
Member

Choose a reason for hiding this comment

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

optionalAttrs ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, thanks

@teto
Copy link
Member

teto commented Aug 5, 2019

I just wanted to mention that since it's options I would typically expect in network-related modules. It's completely fine if it's too hard to implement or too convoluted, you know better :p

@peterhoeg
Copy link
Member Author

It's completely fine if it's too hard to implement or too convoluted, you know better :p

I fully with you - it makes sense to have this type of stuff standard across the board but here I think it would just add complexity for not a lot of gain.

@ivan
Copy link
Member

ivan commented Sep 6, 2019

For the author, reviewers, and committers: this PR was scanned and appears to add a use of the deprecated types.string, which emits a warning as of #66346. Before merging, please change this to another type, possibly:

  • types.str for a single string where merging does not make sense, or cannot work
  • types.lines for multi-line configuration or scripts where merging is possible
  • types.listOf types.str for a mergeable list of strings

@lheckemann lheckemann added this to the 20.03 milestone Sep 10, 2019
@disassembler disassembler modified the milestones: 20.03, 20.09 Feb 5, 2020
@stale
Copy link

stale bot commented Aug 3, 2020

Hello, I'm a bot and I thank you in the name of the community for your contributions.

Nixpkgs is a busy repository, and unfortunately sometimes PRs get left behind for too long. Nevertheless, we'd like to help committers reach the PRs that are still important. This PR has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

If this is still important to you and you'd like to remove the stale label, we ask that you leave a comment. Your comment can be as simple as "still important to me". But there's a bit more you can do:

If you received an approval by an unprivileged maintainer and you are just waiting for a merge, you can @ mention someone with merge permissions and ask them to help. You might be able to find someone relevant by using Git blame on the relevant files, or via GitHub's web interface. You can see if someone's a member of the nixpkgs-committers team, by hovering with the mouse over their username on the web interface, or by searching them directly on the list.

If your PR wasn't reviewed at all, it might help to find someone who's perhaps a user of the package or module you are changing, or alternatively, ask once more for a review by the maintainer of the package/module this is about. If you don't know any, you can use Git blame on the relevant files, or GitHub's web interface to find someone who touched the relevant files in the past.

If your PR has had reviews and nevertheless got stale, make sure you've responded to all of the reviewer's requests / questions. Usually when PR authors show responsibility and dedication, reviewers (privileged or not) show dedication as well. If you've pushed a change, it's possible the reviewer wasn't notified about your push via email, so you can always officially request them for a review, or just @ mention them and say you've addressed their comments.

Lastly, you can always ask for help at our Discourse Forum, or more specifically, at this thread or at #nixos' IRC channel.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 3, 2020
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 4, 2020
@FRidh FRidh removed this from the 20.09 milestone Dec 20, 2020
@FRidh FRidh added this to the 21.03 milestone Dec 20, 2020
@stale
Copy link

stale bot commented Jun 18, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 18, 2021
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 23, 2022
@peterhoeg
Copy link
Member Author

Been running with this for ages. Should be good to go - just cleaned up the commit.

We change a few things here:

a) Create the local openvpn user and group so that openvpn can drop privileges.
This is not switched on by default.

b) Define an option to enable IP forwarding which would have to be defined
outside of the openvpn module.

c) Create a local state and runtime directories for anything openvpn might create (replay
persistence logs, current connections, etc).
@Artturin Artturin modified the milestones: 21.05, 23.05 Dec 31, 2022
@RaitoBezarius RaitoBezarius modified the milestones: 23.05, 23.11 May 31, 2023
@wegank wegank added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 2.status: merge conflict labels Mar 19, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank marked this pull request as draft March 20, 2024 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants