content icon indicating copy to clipboard operation
content copied to clipboard

You can't use `sed -i` on /etc/sysctl.d/*.conf

Open neutronscott opened this issue 1 year ago • 3 comments

https://github.com/ComplianceAsCode/content/blob/59013f66872e02613ba822587d7c5d57ba92cd9e/linux_os/guide/system/permissions/restrictions/sysctl_kernel_core_pattern_empty_string/bash/shared.sh#L15

This clobbers the symlink and ruins everything!

neutronscott avatar Apr 26 '24 23:04 neutronscott

The whole thing is a mess. You use grep to find a pattern, then see if it was found, and then a while read loop to read it back in, just to have sed add a hash mark. sed can search for things too. the whole thing probably equivalent to sed 's/^\s*kernel\.core_pattern.*/# &/' "$f" but add a --follow-symlinks in there I guess.

neutronscott avatar Apr 26 '24 23:04 neutronscott

@neutronscott would you like to propose a PR to improve this? I would be happy to review it.

marcusburghardt avatar May 29 '24 07:05 marcusburghardt

I can try that. I was at work and unable to. Also, sorry about the tone, work is like that sometimes.

neutronscott avatar May 29 '24 10:05 neutronscott