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

Add options to manage file system access options to Service #445

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

carthik
Copy link

@carthik carthik commented Apr 3, 2024

Add options to manage file system access options to Service

Added in version 231, systemd provides options to manage file system access options to processes executed by systemd services. Adding these as valid options.

See https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#ReadWritePaths= for docs.

This Pull Request (PR) fixes the following issues

n/a

Added in version 231, systemd provides options to manage file system access options to
processes executed by systemd services. Adding these as valid options.

See https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#ReadWritePaths=
for docs.
REFERENCE.md Outdated
@@ -2753,6 +2753,11 @@ Struct[{
Optional['ProtectHome'] => Variant[Boolean, Enum['read-only', 'tmpfs']],
Optional['BindPaths'] => Variant[Stdlib::Unixpath,Pattern[/-\/.+/], Array[Variant[Stdlib::Unixpath,Pattern[/-\/.+/]],1]],
Optional['BindReadOnlyPaths'] => Variant[Stdlib::Unixpath,Pattern[/-\/.+/], Array[Variant[Stdlib::Unixpath,Pattern[/-\/.+/]],1]],
Optional['ReadWritePaths'] => Variant[Stdlib::Unixpath,Pattern[/-\/.+/], Array[Variant[Stdlib::Unixpath,Pattern[/-\/.+/]],1]],
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Optional['ReadWritePaths'] => Variant[Stdlib::Unixpath,Pattern[/-\/.+/], Array[Variant[Stdlib::Unixpath,Pattern[/-\/.+/]],1]],
Optional['ReadWritePaths'] => Variant[Stdlib::Unixpath,Pattern[/^-\/.+/], Array[Variant[Stdlib::Unixpath,Pattern[/^-\/.+/]],1]],

and similar. The - is always at the start.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks!
I updated the regular expression to accommodate this (from the systemd docs):

Paths in ReadWritePaths=, ReadOnlyPaths=, InaccessiblePaths=, ExecPaths= and NoExecPaths= may be prefixed with "-", in which case they will be ignored when they do not exist. If prefixed with "+" the paths are taken relative to the root directory of the unit, as configured with RootDirectory=/RootImage=, instead of relative to the root directory of the host (see above). When combining "-" and "+" on the same path make sure to specify "-" first, and "+" second.

Tested thus: https://rubular.com/r/oATb23JSEuE0MX

@traylenator
Copy link
Contributor

Could you add a few examples and counter examples to - https://github.com/voxpupuli/puppet-systemd/blob/master/spec/type_aliases/systemd_unit_service_spec.rb

@traylenator traylenator added the enhancement New feature or request label Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants