Unix socket file permission #1069

Closed
opened 2026-10-05 05:01:21 +02:00 by adam · 6 comments
Owner

Is there any way to set the access mode of the socket? I couldn't find any documentation or clues in the diff.

I'm trying to proxy the HTTP traffic, and it only connects if it's writable (ideally 0666), but the socket is created as 0755.

Originally posted by @frostyfalls in https://github.com/znc/znc/issues/1945#issuecomment-2957966787

Is there any way to set the access mode of the socket? I couldn't find any documentation or clues in the diff. I'm trying to proxy the HTTP traffic, and it only connects if it's writable (ideally 0666), but the socket is created as 0755. _Originally posted by @frostyfalls in https://github.com/znc/znc/issues/1945#issuecomment-2957966787_ <!-- github-sync-id:3132478679 -->
adam closed this issue 2026-10-05 05:01:21 +02:00
Author
Owner

There's no!

It wasn't an issue in my manual tests, and in the ZNC's integration test which is using unix socket almost everywhere now.

Does that proxy specifically check what mode the file has?

There's no! It wasn't an issue in my manual tests, and in the ZNC's integration test which is using unix socket almost everywhere now. Does that proxy specifically check what mode the file has? <!-- github-comment-id:2957987677 -->
Author
Owner

I'm not quite sure, but it's HAProxy. If it wasn't writable by the user its running as, it would just return a 503. My workaround solution was this for systemd:

[Service]
RuntimeDirectory=znc
RuntimeDirectoryMode=0755
UMask=0111

Here's the HAProxy configuration, if interested:

global
    user haproxy
    group haproxy

defaults
    log global
    mode http
    timeout connect 10s
    timeout client 30s
    timeout server 30s

frontend default
    bind :::80 v4v6
    bind :::443 v4v6 ssl crt /etc/haproxy/ssl/
    http-request redirect scheme https unless { ssl_fc }
    use_backend %[req.hdr(Host),lower]
    default_backend no-match

backend no-match
    http-request deny deny_status 404

backend znc.internal.domain
    option forwardfor
    server default /run/znc/znc.sock
I'm not quite sure, but it's HAProxy. If it wasn't writable by the user its running as, it would just return a 503. My workaround solution was this for systemd: ``` [Service] RuntimeDirectory=znc RuntimeDirectoryMode=0755 UMask=0111 ``` Here's the HAProxy configuration, if interested: ``` global user haproxy group haproxy defaults log global mode http timeout connect 10s timeout client 30s timeout server 30s frontend default bind :::80 v4v6 bind :::443 v4v6 ssl crt /etc/haproxy/ssl/ http-request redirect scheme https unless { ssl_fc } use_backend %[req.hdr(Host),lower] default_backend no-match backend no-match http-request deny deny_status 404 backend znc.internal.domain option forwardfor server default /run/znc/znc.sock ``` <!-- github-comment-id:2958035588 -->
Author
Owner

Ah, HAProxy is simply running not as the same user as ZNC, that's why permission is denied

Ah, HAProxy is simply running not as the same user as ZNC, that's why permission is denied <!-- github-comment-id:2960121262 -->
Author
Owner

Indeed; all my other software that I proxy creates their sockets with world writable permissions.

Indeed; all my other software that I proxy creates their sockets with world writable permissions. <!-- github-comment-id:2960725633 -->
Author
Owner

@frostyfalls please test

@frostyfalls please test <!-- github-comment-id:3001392371 -->
Author
Owner

Hey I apologize for not seeing this. It seems to work as intended. Much appreciated :)

Hey I apologize for not seeing this. It seems to work as intended. Much appreciated :) <!-- github-comment-id:3001536443 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#1069