I created a test user and want to limit this "test" user to run only the following command via visudo.

echo "show stat" | socat stdio /var/run/haproxy.sock


test    ALL=(root)NOPASSWD:/usr/bin/socat stdio /var/run/haproxy.sock

ls -lat /var/run/haproxy.sock

srwxr-xr-x 1 munin haproxy 0 May 22 22:32 /var/run/haproxy.sock

I ran the following command

test#sudo echo "show stat" | socat stdio /var/run/haproxy.sock

The error message

2013/05/22 23:13:14 socat[21289] E connect(3, AF=1 "/var/run/haproxy.sock", 23): Permission denied

May I know what was incorrectly configured in visudo


In your pipe, only echo is run with elevated privileges, I believe you need a sudo before socat.


The echo is running as root, but the socat isn't. Try this instead:

echo "show stat" | sudo socat stdio /var/run/haproxy.sock

You can define a normal (non-privileged) unix socket like:

    stats socket /var/run/haproxy/socket.sock mode 666

You can avoid permission denied if you change configuration like below.

stats socket /var/run/haproxy/socket.sock level admin


echo "set server"|nc -U /var/run/haproxy/socket.sock
Require 'backend/server'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.