大网数据广告活动
服务器运维问答

Securely use find with sudo

· 52CE 我爱测

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 metada…

问题原文

原帖链接 · Troels Arvin · CC BY-SA 3.0

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?

已采纳解答

原帖链接 · Lenniey · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-05-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。