All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] improve systemd service
@ 2025-10-24  2:08 Christoph Anton Mitterer
  2025-10-24  2:08 ` [PATCH 1/9] tools: don’t set options whose values match their defaults Christoph Anton Mitterer
                   ` (9 more replies)
  0 siblings, 10 replies; 24+ messages in thread
From: Christoph Anton Mitterer @ 2025-10-24  2:08 UTC (permalink / raw)
  To: netfilter-devel

Hey.

This is a first series of patches that tries to improve the included
`nftables.service`.

It contains the (hopefully) less controversial stuff I’d like to do. O:-)

The main idea is to make things more hardened as it should be for loading
firewall rules.


[PATCH 8/9] tools: flush the ruleset only on an actual dedicated unit
might need some more discussion:

1. Instead of the whole logic I’ve addeed we could also choose to simply never
   do anything on stop, i.e. not seeting `ExecStop=` at all, which would mean
   that even on `systemctl stop nftables.service`, the ruleset isn’t flushed.

   Might even better prevent accidentally stopping the firewall; and writing
   `nft flush ruleset` instead would be even shorter.


2. If we keep the basic idea as proposed in the patch, there's still:
   a) Do you want my slightly awkward multi-line syntax with `\n\` line
      terminators or would you rather have anything in one line or something
      else?

      A problematic thing about the multi-line syntax is that it seems
      impossible to write e.g. the shell’s `;;` on a single line with only
      leading whitespace, as systemd then ignores that as a comment. See [0].
      Might be error prone with future changes.

   b) systemd sets some default PATH (which is even an compile option, IIRC)
      that usually contains /usr/loca/[s]bin.
      Because of that it’s IMO safer to use absolute pathnames for sh and
      systemctl (just in case a user made some local overrides).

      Maybe it would be even better to set a fixde `ExecSearchPath=` (wihout
      /u/local), IIRC that also exports PATH, which would then be inherited by
      `nft`, should that ever exec some binary via PATH resoluiton.

      I have chose to *not* use @sbindir@ (respectively add a @bindir@) for sh
      and systemctl because these aren’t shipped by nftables, and I think if any
      distro would really use something different, patching the file would be
      completely upon them.

      While I’ve been in favour of usr-merge, I still can’t write `/usr/bin/sh`.
      ;-)

      The perfectionist in me would want to add a `unset -v job_type`, to
      prevent that from being exported to `nft`, just in case anyone would have
      configured/override his systemd to export a env var of the same name.


A planned 2nd series would focus on hardening with things like the already
present `ProtectSystem=`.
Quite some more sandboxing seetings seem to be usable with this and IMO units
should generally try to set as many as (reasonably) possible.

I’ll probably send a mail first with proposals on what could be hardened and
what people would think about the various points.


Last but not least, one idea would have been to set:
  WorkingDirectory=/etc

If no further `--includepath` is configured, this would cause relative pathnames
starting with `./` in nft’s `include` statement to use the same path as relative
pathnames without `./` – at least when the default `--includepath` is kept at
`/etc`.
No strong opinion myself, whther that would be better or not. Anyone?

It wouldn’t be backwards compatible, if someone used the service with it’s
current (current) working dir (which is /), and specified absolute pathnames as
relative ones.


Cheers,
Chris.

[0] https://github.com/systemd/systemd/issues/39332



^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2025-10-30 23:44 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-24  2:08 [PATCH 0/8] improve systemd service Christoph Anton Mitterer
2025-10-24  2:08 ` [PATCH 1/9] tools: don’t set options whose values match their defaults Christoph Anton Mitterer
2025-10-24  2:08 ` [PATCH 2/9] tools: use the same pair of boolean literals Christoph Anton Mitterer
2025-10-24  2:08 ` [PATCH 3/9] tools: include further `Documentation=` URIs Christoph Anton Mitterer
2025-10-24  2:08 ` [PATCH 4/9] tools: reorder options Christoph Anton Mitterer
2025-10-28 17:15   ` Jan Engelhardt
2025-10-29  0:29     ` Christoph Anton Mitterer
2025-10-24  2:08 ` [PATCH 5/9] tools: depend on `sysinit.target` Christoph Anton Mitterer
2025-10-28 17:19   ` Jan Engelhardt
2025-10-29  0:35     ` Christoph Anton Mitterer
2025-10-24  2:08 ` [PATCH 6/9] tools: don’t stop `nftables.service` (and flush the ruleset) on shutdown Christoph Anton Mitterer
2025-10-24  2:08 ` [PATCH 7/9] tools: don’t stop `nftables.service` (and flush the ruleset) when isolating another unit Christoph Anton Mitterer
2025-10-24  2:08 ` [PATCH 8/9] tools: flush the ruleset only on an actual dedicated unit stop Christoph Anton Mitterer
2025-10-28 17:31   ` Jan Engelhardt
2025-10-28 17:37     ` Florian Westphal
2025-10-29  0:41     ` Christoph Anton Mitterer
2025-10-29 10:07       ` Jan Engelhardt
2025-10-30  0:53         ` Christoph Anton Mitterer
2025-10-30 23:34   ` Christoph Anton Mitterer
2025-10-24  2:08 ` [PATCH 9/9] tools: let the unit fail if the rules file is missing Christoph Anton Mitterer
2025-10-28 16:33 ` [PATCH 0/8] improve systemd service Florian Westphal
2025-10-29  0:27   ` Christoph Anton Mitterer
2025-10-29 11:40     ` Florian Westphal
2025-10-29 12:07       ` Jan Engelhardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.