SELinux + systemctl
Feb 21 16:05:56 change53 systemd[1077931]: toy_redis_to_postgres.service: Failed to locate executable /usr/local/toy_redis_to_posgres/toy_redis_to_postgres: Permission denied
Feb 21 16:05:56 change53 systemd[1077931]: toy_redis_to_postgres.service: Failed at step EXEC spawning /usr/local/toy_redis_to_posgres/toy_redis_to_postgres: Permission denied
Ubuntu에 잘 배포했던 녀석을 Rocky에 다시 배포 할 일이 있어서 서비스를 등록하고 start를 시키는데 permission error가 난다.
무언가 가물가물 기억은 잘 안 나는데, 응용프로그램을 등록 해 줬었던거 같다.
한참을 해메다 보니 gpt가 대충 알려줘서 해결한다.
# 상태체크
sudo ausearch -m AVC,USER_AVC -ts recent
# 일시적으로 강제 비활성화
sudo setenforce 0
sudo systemctl restart myapp
# SELinux 쩡책 수정
sudo chcon -t bin_t /usr/local/bin/myapp
서비스가 정상 작동하는 것을 보고 SELinux관련 임시 설정을 복원하는등 작업을 했더니..
- 살아 돌아가던 서비스는 살아있으나
- 서비스가 redis에 접속을 시도하려 했더니, 차단되는 현상을 보인다.
응용프로그램 로그
Feb 21 16:43:00 change53 toy_redis_to_postgres[1078437]: OK Called. 2025-02-21 16:43:00.064787182 +0900 KST m=+1406.567257775
Feb 21 16:43:00 change53 toy_redis_to_postgres[1078437]: dial tcp [::1]:6379: connect: permission denied
journal로그에도..
gpt가 어찌 방법을 알려주는데
sudo dnf install setroubleshoot setools
sudo ausearch -m AVC,USER_AVC -ts recent | audit2allow -M mypolicy
sudo semodule -i mypolicy.pp
이것저것 생각하면 그냥 container로 올리는게 속편하겠다 싶다.
Enjoy Reading This Article?
Here are some more articles you might like to read next: