-
I'm trying to monitor my Podman Pods with Zabbix 7, but it keeps failing with the following error message.
The Pod is running as a rootless user (UID 1004) with linger enabled. $ loginctl list-users
UID USER LINGER STATE
1004 user yes lingering Also, I've enabled the Podman service for this user. $ systemctl --user status podman.service
● podman.service - Podman API Service
Loaded: loaded (/usr/lib/systemd/user/podman.service; enabled; preset: disabled)
Active: active (running) since Sun 2024-09-29 08:38:06 -03; 2s ago
TriggeredBy: ● podman.socket
Docs: man:podman-system-service(1)
Main PID: 5317 (podman)
Tasks: 7 (limit: 190751)
Memory: 14.4M
CPU: 25ms
CGroup: /user.slice/user-1004.slice/[email protected]/app.slice/podman.service
└─5317 /usr/bin/podman --log-level=info system service And the Podman socket is in listening state. $ systemctl --user status podman.socket
● podman.socket - Podman API Socket
Loaded: loaded (/usr/lib/systemd/user/podman.socket; disabled; preset: disabled)
Active: active (listening) since Sat 2024-09-28 18:38:28 -03; 13h ago
Until: Sat 2024-09-28 18:38:28 -03; 13h ago
Triggers: ● podman.service
Docs: man:podman-system-service(1)
Listen: /run/user/1004/podman/podman.sock (Stream)
CGroup: /user.slice/user-1004.slice/[email protected]/app.slice/podman.socket With the local user, I can successfully test the socket response using cURL. $ curl --unix-socket /run/user/${UID}/podman/podman.sock http://d/v5.0.0/libpod/info
{"host":{"arch":"amd64","buildahVersion":"1.33.8","cgroupManager":"systemd","cgroupVersion":"v2","cgroupControllers":["memory","pids"],
(...)
"OsArch":"linux/amd64","Os":"linux"}} With all that done, I then added the # usermod -aG user zabbix
# groups zabbix
zabbix : zabbix user
$ ls -lah /run/user/1004/podman/podman.sock
srw-rw---- 1 user user 0 Sep 28 18:38 /run/user/1004/podman/podman.sock Still, Zabbix requests are denied. When I try a local request with another user, it is also denied. $ curl -v --unix-socket /run/user/1004/podman/podman.sock http://d/v5.0.0/libpod/info
* Trying /run/user/1004/podman/podman.sock:0...
* Immediate connect fail for /run/user/1004/podman/podman.sock: Permission denied
* Closing connection 0
curl: (7) Couldn't connect to server With Docker, we can create a Docker group and add the necessary users. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 12 replies
-
You would have to set the socket to group user access of podman with R/W Start the service |
Beta Was this translation helpful? Give feedback.
-
Even when I set the pod user socket to full access [user@pod ~]$ chmod 777 /run/user/1004/podman/podman.sock
[user@pod ~]$ ls -lah /run/user/1004/podman/podman.sock
srwxrwxrwx 1 user user 0 Sep 28 18:38 /run/user/1004/podman/podman.sock [user2@pod ~]$ curl -v --unix-socket /run/user/1004/podman/podman.sock http://d/v5.0.0/libpod/info
* Trying /run/user/1004/podman/podman.sock:0...
* Immediate connect fail for /run/user/1004/podman/podman.sock: Permission denied
* Closing connection 0
curl: (7) Couldn't connect to server |
Beta Was this translation helpful? Give feedback.
-
I think I've finally figured out the problem. It seems that the user's directory permission ( [user@pod ~]$ ls -lad /run/user/1004
drwx------ 8 user user 200 Sep 28 18:38 /run/user/1004 This happens because the directory is created with restrictive permissions after user linger is enabled. That is, it is created with user permissions only, no group permissions. Like the example below. [root@host ~]# sudo loginctl enable-linger 1005
[root@host ~]# su -l test
[test@host ~]$ ls -lad /run/user/1005
drwx------ 3 test test 100 Sep 29 14:20 /run/user/1005 Only after adding execution permission to the directory, other users from the same group were able to access the Podman socket, including Zabbix. [user@pod ~]$ chmod g+x /run/user/1004/
[user@pod ~]$ ls -lad /run/user/1004/
drwx--x--- 8 user user 200 Sep 28 18:38 /run/user/1004/ [user2@pod ~]$ curl --unix-socket /run/user/1004/podman/podman.sock http://d/v5.0.0/libpod/info
{"host":{"arch":"amd64","buildahVersion":"1.33.8","cgroupManager":"systemd","cgroupVersion":"v2",
(...)
"OsArch":"linux/amd64","Os":"linux"}} |
Beta Was this translation helpful? Give feedback.
-
Despite adding permissions to the user's run directory and solving the initial permission problem, the permission is reset after a reboot. So I tried adding the [user@pod ~]$ systemctl --user cat podman.socket
# /usr/lib/systemd/user/podman.socket
[Unit]
Description=Podman API Socket
Documentation=man:podman-system-service(1)
[Socket]
ListenStream=%t/podman/podman.sock
SocketMode=0660
SocketGroup=zabbix
[Install]
WantedBy=sockets.target Reloaded SystemD and restarted the socket, but it did not start. SystemD reported a [user@pod ~]$ systemctl --user status podman.socket
× podman.socket - Podman API Socket
Loaded: loaded (/usr/lib/systemd/user/podman.socket; enabled; preset: disabled)
Active: failed (Result: exit-code) since Wed 2024-10-02 20:43:33 -03; 1min 5s ago
Triggers: ● podman.service
Docs: man:podman-system-service(1)
Listen: /run/user/1004/podman/podman.sock (Stream)
CPU: 790us
Oct 02 20:43:33 pod systemd[113]: Starting Podman API Socket...
Oct 02 20:43:33 pod systemd[1939]: podman.socket: Failed to chown(): Operation not permitted
Oct 02 20:43:33 pod systemd[113]: podman.socket: Control process exited, code=exited, status=235/CHOWN
Oct 02 20:43:33 pod systemd[113]: podman.socket: Failed with result 'exit-code'.
Oct 02 20:43:33 pod systemd[113]: Failed to listen on Podman API Socket. I must say... using Podman's API socket is turning out to be quite a pain. |
Beta Was this translation helpful? Give feedback.
-
What I'm trying to accomplish is to monitor the rootless Pod with Zabbix. So far, what I'm catching up is that SystemD creates the [root@pod ~]# /usr/lib/tmpfiles.d/systemd.conf
d /run/user 0755 root root - In it, if user linger is enabled, a directory is created for the user with permission 0700, which means no group access. [user@pod ~]$ ls -lad /run/user/1004
drwx------ 8 user user 200 Oct 3 16:17 /run/user/1004 Since the
With this, I aim to give the directory group execution permission after a reboot. If we run [user@pod ~]$ SYSTEMD_LOG_LEVEL=debug systemd-tmpfiles --user --create
Looking for configuration files in (higher priority first):
/etc/xdg/user-tmpfiles.d
/home/user/.config/user-tmpfiles.d
/run/user/1004/user-tmpfiles.d
/home/user/.local/share/user-tmpfiles.d
/usr/local/share/user-tmpfiles.d
/usr/share/user-tmpfiles.d
SELinux enabled state cached to: disabled
Reading config file "/usr/share/user-tmpfiles.d/podman-docker.conf"…
Reading config file "/home/user/.config/user-tmpfiles.d/podman_user_1004.conf"…
Running create action for entry z /run/user/1004
Running create action for entry L /run/user/1004/docker.sock
Found existing symlink "/run/user/1004/docker.sock". Now, users that belong to the rootless Pod user should have access to the socket API. [user2@pod ~]$ curl --unix-socket /run/user/1004/podman/podman.sock http://d/v5.0.0/libpod/info
{"host":{"arch":"amd64","buildahVersion":"1.33.8","cgroupManager":"systemd","cgroupVersion":"v2","cgroupControllers":
(...)
2024","Built":1725368544,"OsArch":"linux/amd64","Os":"linux"}} StepsJust to summarize, these are the steps taken to allow another user access to the rootless Podman socket API.
[root@pod ~]# loginctl enable-linger [user|UID]
[root@pod ~]# usermod -aG user zabbix
[root@pod ~]# exec newgrp user
[user@pod ~]$ systemctl --user enable --now podman.socket
systemd-tmpfiles --user --create I've been searching so much the last few days that I may have forgotten a thing or two about these steps. Anyway, this has been quite a learning experience. |
Beta Was this translation helpful? Give feedback.
What I'm trying to accomplish is to monitor the rootless Pod with Zabbix.
So far, what I'm catching up is that SystemD creates the
/run/user
directory as root.In it, if user linger is enabled, a directory is created for the user with permission 0700, which means no group access.
[user@pod ~]$ ls -lad /run/user/1004 drwx------ 8 user user 200 Oct 3 16:17 /run/user/1004
Since the
/run/user/$UID
directory is created by enabling user linger, I've created the.config/user-tmpfiles.d/podman_user_1004.conf
file with the following value. (Thanks @afbjorklund)With this, I aim to give …