Skip to content

get_service_file unable to find containerd.sock #548

Closed
@spedersen-emailage

Description

@spedersen-emailage

get_service_file looks for $SERVICE in these directories:

  • /etc/systemd/system/
  • /lib/systemd/system/
  • /usr/lib/systemd/system/

As well as looks at systemctl's FragmentPath property.

Reference:

get_service_file() {
SERVICE="$1"
if [ -f "/etc/systemd/system/$SERVICE" ]; then
echo "/etc/systemd/system/$SERVICE"
return
fi
if [ -f "/lib/systemd/system/$SERVICE" ]; then
echo "/lib/systemd/system/$SERVICE"
return
fi
if systemctl show -p FragmentPath "$SERVICE" 2> /dev/null 1>&2; then
systemctl show -p FragmentPath "$SERVICE" | sed 's/.*=//'
return
fi
echo "/usr/lib/systemd/system/$SERVICE"
}

CIS test 1.1.8 throws INFO and remediation has a blank recommendation because containerd.sock is not found in any of those directories or via FP.

[INFO] 1.1.8 - Ensure auditing is configured for Docker files and directories - containerd.sock (Automated)
[INFO]    * File not found
...
[INFO] 1.1.8 - Install auditd. Add -w  -k docker to the /etc/audit/rules.d/audit.rules file. Then restart the audit daemon using command service auditd restart. Remediation Impact: Audit can generate large log files. So you need to make sure that they are rotated and archived periodically. Create a separate partition for audit logs to avoid filling up other critical partitions.

Note the extra space between -w and -k above.

Instead, when docker runs with active containers, it's only found at /run/containerd/containerd.sock.

# find / -name "containerd.sock"
/run/containerd/containerd.sock

This has been observed with Docker v20.10.25 on Amazon Linux 2 and v25.0.3 on Amazon Linux 2023.

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2024-04-11 13:06:55 UTC; 1h 31min ago
     Docs: https://docs.docker.com
 Main PID: 5089 (dockerd)
    Tasks: 62
   Memory: 644.9M
   CGroup: /system.slice/docker.service
           ├─5089 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --default-ulimit nofile=32768:65536
...

Note --containerd points to /run/containerd/containerd.sock.

I checked CIS Docker Benchmark v1.6.0 and it does not specify the location of containerd.sock, only that you find it and monitor it.

Can the tests be updated to check /run as well?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions