-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
systemd::escape function is does not escape a lot of other characters #242
Comments
Problems with calling systemd-escape on master is that different versions of systemd do different things so you never quite no what you are getting. Server might even be running windows. Indeed the |
Or running inside kubernetes ... Thats correct and thats the reason why this functions should be always called deferred. This avoids any dependency against the master since systemd-escape is executed on the agent only.
And any other special chars, too. Mount points can go wild (looking at samba servers...) |
Deferreed is pretty limited - e.g cannot be called in a template. Hex is handled
When I wrote function I wrote from the docs - clearly not enough. |
It's documented, how you can use Deferred function in epp templates, for example by Defer the epp template call, too. https://puppet.com/docs/puppet/6/deferring_functions.html#deferring_functions-deferred-function-example
I saw this. Converting Hex to String is simple. Can you figure out, how I can convert character to hex?
|
Indeed. Needs an |
And now, it begins to be complex..... Also see the note from @bastelfreak .. #243 (comment) |
Why extlib and not stdlib? |
And why not puppet core? I guess extlib would be the fastest way to get such a function. The lifecycle of puppet or stdlib maybe takes longer... depends on the puppet development team ... |
That's indeed what I thought. It could even be first submitted to stdlib and once it's in core, the stdlib function could delegate. |
We also need to escape dashes in unit names, for instance for .swap services on device nodes with dashes in them. systemd-escape escapes dashes: # systemd-escape -p /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-ua-swap dev-disk-by\x2did-scsi\x2d0QEMU_QEMU_HARDDISK_drive\x2dua\x2dswap but this function does not (yet). In the long term, we may want to more closely match the behaviour of systemd's unit-name.c, but this is all I need for now. (Also cf. voxpupuli#242.)
The function
systemd::escape
introduced in #220 supports only a minimalistic subset of escape sequences.For mount units, the
-
needs to be escaped and replaced by\x2d
(hex representation).In general, numbers, letters and some special chars are allowed and others needs to be replaced by a hex presentation.
Before someone ask 'Can you create a PR?'.
First I want to know if it worth to reimplement the systemd-escape logic into the puppet DSL or should the puppet function replaced by a function it's simply calling
systemd-escape
? In combination withDefferred functions
, it should NOT add the dependency having systemd installed on the puppet master.In case the current function should extend, I need to know how I can convert strings/chars to octal or hex decimal and do comparisons like
if "x".ord > 127
?The text was updated successfully, but these errors were encountered: