max*_*zig 7 fedora systemd systemd-journald
当我journalctl -f -a在 Fedora 20 下为不同的用户执行时,我得到了不同的结果。对于 root 我得到类似于tail -f /var/log/syslog旧系统上的东西。作为普通用户,我收到 gnome-shell 警告、一些 su 消息、Firefox 写入标准输出的内容等 - 基本上是用户会话日志。
我理解journalctl有不同期刊的概念(journalctl(1)):
输出从所有可访问的日志文件中交错,无论它们是轮换的还是当前正在写入的,也无论它们是属于系统本身还是可访问的用户日志。
但是如何获取给定用户可用的期刊列表?
以及如何让普通用户也可以访问根日志?
journalctl 手册页指出:
所有用户都有权访问他们的私人每用户日志。但是,默认情况下,只有 root 用户和作为“systemd-journal”组成员的用户才能访问系统日志和其他用户的日志。
但这听起来太多了——用户不应该访问其他普通用户的日志(只能访问根日志)。
该systemd-journald手册页介绍了杂志的访问控制是怎么做的:
Journal files are, by default, owned and readable by the "systemd-journal"
system group but are not writable. Adding a user to this group thus enables
her/him to read the journal files.
By default, each logged in user will get her/his own set of journal files in
/var/log/journal/. These files will not be owned by the user, however, in order
to avoid that the user can write to them directly. Instead, file system ACLs
are used to ensure the user gets read access only.
Additional users and groups may be granted access to journal files via file
system access control lists (ACL).
Run Code Online (Sandbox Code Playgroud)
Fedora 20 使用 ACL 为adm和wheel组中的用户提供对所有期刊的读取访问权限。
如何让普通用户也可以访问根日志?
运行setfacl -n -m u:username:r /var/log/journal/*/system.journal。
如何获取给定用户可用的期刊列表?
您可以su到用户并运行journalctl --header|grep '^File Path'以查看他或她有权访问的期刊名称。
getfacl可用于查看哪些组和用户可以访问日志文件。我不知道列出特定用户可读的文件的简单方法。
| 归档时间: |
|
| 查看次数: |
4724 次 |
| 最近记录: |