systeme:selinux
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| systeme:selinux [2019/05/17 21:48] – [Mapping entre utilisateurs SELinux et les rôles SELinux] root | systeme:selinux [2020/02/21 18:36] (Version actuelle) – [sepolicy network] root | ||
|---|---|---|---|
| Ligne 463: | Ligne 463: | ||
| Créez un nouvel utilisateur SELinux et spécifiez le rôle SELinux par défaut et un rôle d' | Créez un nouvel utilisateur SELinux et spécifiez le rôle SELinux par défaut et un rôle d' | ||
| < | < | ||
| - | $ semanage user -a -r s0-s0: | + | $ semanage user -a -r s0-s0: |
| </ | </ | ||
| Ligne 522: | Ligne 522: | ||
| $ semanage permissive -d httpd_t | $ semanage permissive -d httpd_t | ||
| </ | </ | ||
| + | |||
| * Pour lister les domaine désactivé : | * Pour lister les domaine désactivé : | ||
| < | < | ||
| $ semanage permissive -l | $ semanage permissive -l | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | seinfo --permissive -x | ||
| </ | </ | ||
| Ligne 608: | Ligne 613: | ||
| $ semanage fcontext -l | $ semanage fcontext -l | ||
| </ | </ | ||
| + | |||
| + | * Pour vérifier le contexte: | ||
| + | < | ||
| + | $ matchpathcon -V / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | </ | ||
| + | |||
| ==== Booléen ==== | ==== Booléen ==== | ||
| Les booléens permettent de modifier une politique SELinux, sans avoir la moindre connaissance ou compétence sur le sujet de la rédaction de politiques. L' | Les booléens permettent de modifier une politique SELinux, sans avoir la moindre connaissance ou compétence sur le sujet de la rédaction de politiques. L' | ||
| Ligne 777: | Ligne 791: | ||
| < | < | ||
| $ runcon system_u: | $ runcon system_u: | ||
| + | </ | ||
| + | |||
| + | ===== sepolicy ===== | ||
| + | ==== sepolicy generate ==== | ||
| + | Générer une policy pour un service: | ||
| + | < | ||
| + | $ sepolicy generate --init -n myprogram / | ||
| + | </ | ||
| + | |||
| + | Voir https:// | ||
| + | |||
| + | ==== sepolicy transition ==== | ||
| + | Interroger la stratégie SELinux pour voir si un domaine de traitement source peut transitionner vers un domaine de traitement cible: | ||
| + | < | ||
| + | $ sepolicy transition -s httpd_t | ||
| + | </ | ||
| + | |||
| + | ==== sepolicy network ==== | ||
| + | Interroger les stratégies SELinux relatives aux information réseau: | ||
| + | < | ||
| + | $ sepolicy network -p 22 | ||
| + | 22: tcp ssh_port_t 22 | ||
| + | 22: udp reserved_port_t 1-511 | ||
| + | 22: tcp reserved_port_t 1-511 | ||
| + | 22: sctp reserved_port_t 1-511 | ||
| + | </ | ||
| + | |||
| + | ==== sepolicy booleans ==== | ||
| + | Interroger la stratégie SELinux pour voir les descriptions des booléens: | ||
| + | < | ||
| + | $ sepolicy booleans -a | ||
| + | $ sepolicy booleans -b user_ping | ||
| + | </ | ||
| + | |||
| + | ==== sepolicy communicate ==== | ||
| + | Interroger la stratégie SELinux pour voir si les domaines peuvent communiquer ensemble: | ||
| + | < | ||
| + | $ sepolicy communicate -s syslogd_t -t httpd_t -c file | ||
| </ | </ | ||
| Ligne 790: | Ligne 842: | ||
| $ auditctl -l | $ auditctl -l | ||
| </ | </ | ||
| + | |||
| + | |||
| + | ====== Scripts ====== | ||
| + | Download and extract and set the variable **POLICY_LOCATION**. | ||
| + | |||
| + | Add to your '' | ||
| + | <code bash> | ||
| + | POLICY_LOCATION=" | ||
| + | |||
| + | # sefindif - Find interface definitions that have a string that matches the | ||
| + | # given regular expression | ||
| + | sefindif() { | ||
| + | REGEXP=" | ||
| + | pushd ${POLICY_LOCATION}/ | ||
| + | for FILE in */*.if; | ||
| + | do | ||
| + | awk "/ | ||
| + | done | ||
| + | popd > /dev/null 2>& | ||
| + | } | ||
| + | |||
| + | # seshowif - Show the interface definition | ||
| + | seshowif() { | ||
| + | INTERFACE=" | ||
| + | pushd ${POLICY_LOCATION}/ | ||
| + | for FILE in */*.if; | ||
| + | do | ||
| + | grep -A 9999 " | ||
| + | done | ||
| + | popd > /dev/null 2>& | ||
| + | } | ||
| + | |||
| + | # sefinddef - Find macro definitions that have a string that matches the given | ||
| + | # regular expression | ||
| + | sefinddef() { | ||
| + | REGEXP=" | ||
| + | grep -H " | ||
| + | } | ||
| + | |||
| + | # seshowdef - Show the macro definition | ||
| + | seshowdef() { | ||
| + | MACRONAME=" | ||
| + | pushd ${POLICY_LOCATION}/ | ||
| + | for FILE in *.spt; | ||
| + | do | ||
| + | grep -A 9999 " | ||
| + | done | ||
| + | popd > /dev/null 2>& | ||
| + | } | ||
| + | |||
| + | # sefindcon - Find macro definitions for constrains | ||
| + | sefindcon() { | ||
| + | awk "/ | ||
| + | } | ||
| + | |||
| + | # selist - List all templates/ | ||
| + | selist() { | ||
| + | pushd ${POLICY_LOCATION}/ | ||
| + | ( | ||
| + | egrep ' | ||
| + | egrep ' | ||
| + | egrep ' | ||
| + | egrep ' | ||
| + | ) | nl | sed -e "s:$: :g"; | ||
| + | popd > /dev/null 2>& | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $ sefindif ' | ||
| + | services/ | ||
| + | services/ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $ seshowif systemd_tmpfilesd_managed | ||
| + | interface(`systemd_tmpfilesd_managed', | ||
| + | gen_require(` | ||
| + | type systemd_tmpfiles_t; | ||
| + | ') | ||
| + | |||
| + | allow systemd_tmpfiles_t $1:$2 { setattr relabelfrom relabelto create }; | ||
| + | ') | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $ sefinddef ' | ||
| + | obj_perm_sets.spt: | ||
| + | obj_perm_sets.spt: | ||
| + | obj_perm_sets.spt: | ||
| + | obj_perm_sets.spt: | ||
| + | obj_perm_sets.spt: | ||
| + | obj_perm_sets.spt: | ||
| + | obj_perm_sets.spt: | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $ seshowdef manage_files_pattern | ||
| + | define(`manage_files_pattern', | ||
| + | allow $1 $2:dir rw_dir_perms; | ||
| + | allow $1 $3:file manage_file_perms; | ||
| + | ') | ||
| + | </ | ||
| + | |||
systeme/selinux.1558129714.txt.gz · Dernière modification : de root
