Linux – Securely use find with sudo

findlinuxsudo

On a Linux server, I need to remove root privileges from a group of users. But those users have legitimate reasons to be able to use the "find" utility to search for files based on file names, modification dates, and other metadata.

On the server, file names are not sensitive, but the file contents may be.

I would like use sudo to allow the users to search for files anywhere on the server. The "find" utility is great, but it allows for all kinds of side effects, such as using "-exec" to spawn arbitrary commands.

Can I get find to work with my restrictions?

Best Answer

What about locate?

locate reads one or more databases prepared by updatedb(8) and writes file names matching at least one of the PATTERNs to standard output, one per line. If --regex is not specified, PATTERNs can contain globbing characters. If any PATTERN contains no globbing characters, locate behaves as if the pattern were PATTERN.

By default, locate does not check whether files found in database still exist. locate can never report files created after the most recent update of the relevant database.

Or maybe even slocate:

Secure Locate provides a secure way to index and quickly search for files on your system. It uses incremental encoding just like GNU locate to compress its database to make searching faster, but it will also store file permissions and ownership so that users will not see files they do not have access to.

This manual page documents the GNU version of slocate. slocate Enables system users to search entire filesystems without displaying unauthorized files.

Related Topic