Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

10.2. SELinux 및 journald

systemd 에서 the journald 데몬( systemd-journal이라고도 함)은 로깅 데이터를 수집하고 저장하는 시스템 서비스인 syslog 유틸리티의 대안입니다. 커널에서 수신되는 로깅 정보, 시스템 서비스의 표준 및 오류 출력에서 libc syslog() 함수를 사용하는 사용자 프로세스 또는 네이티브 API를 사용하는 로깅 정보를 기반으로 구조화 및 인덱싱된 저널을 생성하고 유지관리합니다. 각 로그 메시지의 여러 메타데이터 필드를 안전한 방식으로 암시적으로 수집합니다.
systemd-journal 서비스는 SELinux와 함께 사용하여 보안을 강화할 수 있습니다. SELinux는 설계한 작업만 수행할 수 있도록 허용하여 프로세스를 제어합니다. 정책 작성자의 보안 목표에 따라 때로는 더 적은 경우도 있습니다. 예를 들어 SELinux는 손상된 ntpd 프로세스가 네트워크 시간 처리 이외의 모든 작업을 수행하지 못하게 합니다. 그러나 ntpd 프로세스는 SELinux가 손상된 프로세스가 해당 메시지를 계속 보낼 수 있도록 syslog 메시지를 전송합니다. 손상된 ntpd 는 다른 데몬과 일치하도록 syslog 메시지를 포맷하고 관리자가 오작동할 수 있거나 syslog 파일을 읽어 전체 시스템을 손상시키는 유틸리티를 제공할 수 있었습니다.
systemd-journal 데몬은 모든 로그 메시지를 확인하고 특히 SELinux 레이블을 추가합니다. 그러면 로그 메시지의 불일치가 감지되고 발생하기 전에 이 유형의 공격을 방지할 수 있습니다. journalctl 유틸리티를 사용하여 systemd 저널 로그를 쿼리할 수 있습니다. 명령줄 인수를 지정하지 않으면 이 유틸리티를 실행하면 가장 오래된 항목부터 시작하여 저널의 전체 내용이 나열됩니다. 시스템 구성 요소에 대한 로그를 포함하여 시스템에서 생성된 모든 로그를 보려면 journalctl 을 root로 실행합니다. 루트가 아닌 사용자로 실행하는 경우 현재 로그인한 사용자와 관련된 로그로만 출력이 제한됩니다.

예 10.2. journalctl을 사용하여 로그 나열

journalctl 을 사용하여 특정 SELinux 레이블과 관련된 모든 로그를 나열할 수 있습니다. 예를 들어 다음 명령은 system_u:system_r:policykit_t:s0 라벨에 로깅된 모든 로그를 나열합니다.
~]# journalctl _SELINUX_CONTEXT=system_u:system_r:policykit_t:s0
Oct 21 10:22:42 localhost.localdomain polkitd[647]: Started polkitd version 0.112
Oct 21 10:22:44 localhost.localdomain polkitd[647]: Loading rules from directory /etc/polkit-1/rules.d
Oct 21 10:22:44 localhost.localdomain polkitd[647]: Loading rules from directory /usr/share/polkit-1/rules.d
Oct 21 10:22:44 localhost.localdomain polkitd[647]: Finished loading, compiling and executing 5 rules
Oct 21 10:22:44 localhost.localdomain polkitd[647]: Acquired the name org.freedesktop.PolicyKit1 on the system bus Oct 21 10:23:10 localhost polkitd[647]: Registered Authentication Agent for unix-session:c1 (system bus name :1.49, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Oct 21 10:23:35 localhost polkitd[647]: Unregistered Authentication Agent for unix-session:c1 (system bus name :1.80 [/usr/bin/gnome-shell --mode=classic], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.utf8)
journalctl 에 대한 자세한 내용은 journalctl(1) 매뉴얼 페이지를 참조하십시오.