Hello
I'd need to remove the setuid bit from certain files (as that was the finding of some security audit). On the command line, I'd simply do a "chmod u-s $file
", as that would be the least interfering way and would do exactly, what I would need to do: "Remove the setuid bit from a file".
How can I do that in a recipe? I tried:
%w[/usr/lib/pt_chown /usr/lib/eject/dmcrypt-get-device /usr/bin/chfn].each do |setuidfile|
file "Setuid Berechtigung anpassen: " + setuidfile do
path setuidfile
mode "u-s"
end # of file "Setuid Berechtigung anpassen: " + setuidfile do
end # of %w[/usr/lib/pt_chown /usr/lib/eject/dmcrypt-get-device /usr/bin/chfn].each do |setuidfile|
But this fails:
================================================================================
Recipe Compile Error in /opt/kitchen/cookbooks/ew-hardening/recipes/default.rb
================================================================================
ArgumentError
-------------
invalid value for Integer(): "0u-s"
Cookbook Trace:
---------------
/opt/kitchen/cookbooks/ew-hardening/recipes/default.rb:141:in `block (2 levels) in from_file'
/opt/kitchen/cookbooks/ew-hardening/recipes/default.rb:139:in `block in from_file'
/opt/kitchen/cookbooks/ew-hardening/recipes/default.rb:138:in `each'
/opt/kitchen/cookbooks/ew-hardening/recipes/default.rb:138:in `from_file'
Relevant File Content:
----------------------
/opt/kitchen/cookbooks/ew-hardening/recipes/default.rb:
134: #############################################
135: # Audit
136: # Setuid Dateien anpassen
137: # https://wiki.ubuntu.com/Security/Investigation/Setuid
138: %w[/usr/lib/pt_chown /usr/lib/eject/dmcrypt-get-device /usr/bin/chfn].each do |setuidfile|
139: file "Setuid Berechtigung anpassen: " + setuidfile do
140: path setuidfile
141>> mode "u-s"
142: end # of file "Setuid Berechtigung anpassen: " + setuidfile do
143: end # of %w[/usr/lib/pt_chown /usr/lib/eject/dmcrypt-get-device /usr/bin/chfn].each do |setuidfile|
144:
145: # EOF
146:
Chef Client failed. 0 resources updated
But according to the docs at "mode", it should be possible to use a string, I'd think:
mode
Ruby Types: Integer, String
…
UNIX- and Linux-based systems: A quoted 3-5 character string that defines the octal mode that is passed to chmod. For example: '755', '0755', or '00755'. If the value is specified as a quoted string, it works exactly as if the chmod command was passed.
Í am passing this as a quoted string (I'd think…). But what am I doing wrong?
I'm on Chef 11.8.2.
Thanks a lot,
Alexander