Re: systemd CAP_DAC_READ_SEARCH

Christian Perle <[email protected]>
Newsgroups gmane.user-groups.linux.dresden
Organization Silmor
Message-ID <[email protected]>
Hallo Andreas,

On Tue, Jun 13, 2023 at 15:29:02 +0200, Andreas Roth wrote:

[systemd-Unit non-root mit Capabilities]
> Wenn ich eine ältere Version (8.2.*) der Software installiere sind
> die Werte:
> 
> NoNewPrivileges=yes
> AmbientCapabilities=CAP_DAC_READ_SEARCH
> 
> per default nicht gesetzt. Wenn ich sie hinzufüge, ein systemctl
> daemon-reload ausführe kann die Software nicht auf Dateien zugreifen,
> auf welche der Technische Nutzer Leseberechtigung hat.
> 
> Das verwundert mich. Ich habe geprüft ob die capabilites wirklich beim
> Dienst ankommen - sieht erstmal gut aus:
[...]
> [root@ip-10-53-1-118 local]# getpcaps 3527
> 3527: cap_dac_read_search=eip

Mit getpcaps kannst Du nicht sehen, ob die Capabilities auch im
Ambient-Set gesetzt sind. Besser direkt in /proc greppen:

# grep Cap /proc/PID/status


Das folgende Minimalbeispiel hat bei mir in einem Debian 11 Livesystem
funktioniert:

# Put this in /etc/systemd/system/
# telnetd is actually busybox telnetd:
#   CONFIG_TELNETD=y
#   CONFIG_FEATURE_TELNETD_STANDALONE=y
# Shell provided by telnet login runs as unprivileged user but has
# CAP_DAC_READ_SEARCH, thus it can read any file/dir.
# After login, run
# $ grep Cap /proc/$$/status
# to verify CAP_DAC_READ_SEARCH is allowed in ambient set.
[Unit]
Description=telnetd

[Service]
User=user
Group=user
NoNewPrivileges=yes
AmbientCapabilities=CAP_DAC_READ_SEARCH
ExecStart=/usr/local/bin/telnetd -F -p 3333 -l /bin/bash

[Install]
WantedBy=multi-user.target


Gruss,
  Christian
-- 
Christian Perle                                    chris AT linuxinfotag.de
010111                                              http://chris.silmor.de/
101010                          LinuxGuitarKitesBicyclesBeerPizzaRaytracing
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.