Haproxy and socat sudo

haproxysudo

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

visudo

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

Best Answer

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

Related Topic