mirror of
https://github.com/inspec/inspec
synced 2024-12-23 03:23:27 +00:00
3d7244fb07
Wildcards are evaluated prior to applying `sudo` permissions. This means that running `sudo find /some/path/*.conf` will fail if the user does not have read permissions on `/some/path/` because the wildcard cannot expand before `sudo` is applied and `*.conf` isn't a file. The solution for this is to run the command in a subshell that has the proper permissions (e.g. `sudo sh -c 'find /some/path/*.conf'`). This modifies `Utils::FindFiles` to use a subshell thus allowing wildcard support. This fixes #2157 Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
30 lines
544 B
Ruby
30 lines
544 B
Ruby
# This recipe is used to test the function of `Utils::FindFiles`.
|
|
|
|
directory '/etc/find_files/'
|
|
|
|
user 'secret'
|
|
group 'secret'
|
|
|
|
directory '/etc/find_files/secret' do
|
|
mode '600'
|
|
owner 'secret'
|
|
group 'secret'
|
|
end
|
|
|
|
%w{secret_file1 secret_file2}.each do |f|
|
|
file File.join('/etc/find_files/secret', f) do
|
|
mode '600'
|
|
owner 'secret'
|
|
group 'secret'
|
|
end
|
|
end
|
|
|
|
directory '/etc/find_files/public' do
|
|
mode '777'
|
|
end
|
|
|
|
%w{public_file1 public_file2}.each do |f|
|
|
file File.join('/etc/find_files/public', f) do
|
|
mode '777'
|
|
end
|
|
end
|