tech:notes_linux_capabilities_securite_caps_capsh_setcap
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 | ||
| tech:notes_linux_capabilities_securite_caps_capsh_setcap [2025/09/30 13:18] – Jean-Baptiste | tech:notes_linux_capabilities_securite_caps_capsh_setcap [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Notes Linux capabilities sécurité caps capsh setcap | ||
| + | |||
| + | Voir : | ||
| + | * [Les capabilities sous Linux](http:// | ||
| + | * [Linux capabilities : se passer des commandes su et sudo](https:// | ||
| + | |||
| + | ~~~bash | ||
| + | man 7 capabilities | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | capsh --print | ||
| + | getpcaps $$ | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ~~~ | ||
| + | $ dpkg -L libcap-ng-utils | grep ' | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | ~~~ | ||
| + | |||
| + | Voir : | ||
| + | * [[Serveur en écoute sur un port inférieur à 1024 sans utiliser root ni setuid grâce aux capabilities setcap]] | ||
| + | |||
| + | |||
| + | ## tcpdump permission pour non-root | ||
| + | |||
| + | Autoriser les utilisateur non-root à utiliser tcpdump | ||
| + | |||
| + | NOTE : il est aussi possible d' | ||
| + | |||
| + | Source : https:// | ||
| + | |||
| + | Add a capture group and add yourself to it: | ||
| + | |||
| + | ~~~bash | ||
| + | sudo groupadd pcap | ||
| + | sudo usermod -a -G pcap $USER | ||
| + | ~~~ | ||
| + | |||
| + | Next, change the group of tcpdump and set permissions: | ||
| + | |||
| + | ~~~bash | ||
| + | sudo chgrp pcap / | ||
| + | sudo chmod 750 / | ||
| + | ~~~ | ||
| + | |||
| + | Finally, use setcap to give tcpdump the necessary permissions: | ||
| + | |||
| + | ~~~bash | ||
| + | sudo setcap cap_net_raw, | ||
| + | ~~~ | ||
| + | |||
| + | Be careful, that this will allow everybody from the group pcap to manipulate network interfaces and read raw packets! | ||
| + | |||
| + | |||
| + | ## PAM user | ||
| + | |||
| + | Voir : | ||
| + | * / | ||
| + | * libcap | ||
| + | |||
| + | |||
| + | ## Service SystemD | ||
| + | |||
| + | Exemple | ||
| + | |||
| + | `coredns.service` | ||
| + | ~~~ini | ||
| + | [Unit] | ||
| + | Description=CoreDNS Server | ||
| + | Documentation=https:// | ||
| + | After=network-online.target | ||
| + | Wants=network-online.target | ||
| + | |||
| + | [Service] | ||
| + | User=coredns | ||
| + | Group=coredns | ||
| + | AmbientCapabilities=CAP_NET_BIND_SERVICE | ||
| + | Restart=always | ||
| + | WorkingDirectory=/ | ||
| + | ExecStart=/ | ||
| + | ExecReload=/ | ||
| + | |||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| + | ~~~ | ||
| + | |||
| + | Source : https:// | ||
| + | |||
| + | |||
| + | |||
| + | ## SyncThing - syncOwnership | ||
| + | |||
| + | Source : https:// | ||
| + | |||
| + | ~~~bash | ||
| + | sudo chown root / | ||
| + | sudo chmod 755 / | ||
| + | sudo setcap CAP_CHOWN, | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | ## Autres | ||
| + | |||
| + | ~~~bash | ||
| + | nerdctl run -ti --rm --cap-drop=all docker.io/ | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | crictl inspect 6142ce06b10d6 | ||
| + | ~~~ | ||
