1

I have a bash script that runs hostapd_cli all_sta and the script executes successfully from the command line under both jessie and stretch. The script also works when run under sudo on jessie but not on stretch. On stretch the command times out with the error 'STA-FIRST' command timed out. When I invoke hostapd_cli under strace I see that it opens a socket file under /tmp:

bind(3, {sa_family=AF_UNIX, sun_path="/tmp/wpa_ctrl_13552-1"}, 110) = 0
connect(3, {sa_family=AF_UNIX, sun_path="/var/run/hostapd/wlan1"}, 110) = 0

as a test I temporarily modified the script and added a line:

echo "this is a test" >/tmp/test 2>/root/error

When the modified script runs under sudo the file in /tmp is not created and no error is written to /tmp/error

On my system /tmp is not a tmpfs, just a plain old directory under / on a ext3 fs. So root is unable to create a file under /tmp and there is ample space.

# df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb2       6.7G  5.1G  1.4G  80% /

And a ls -ld /tmp gives:

# ls -ld /tmp
drwxrwxrwt 9 root root 4096 Jul 27 23:50 /tmp/

If I can figure out why /tmp can't be written to I believe the hostapd_cli command will work. What could be happening here?

0

The reason this was not working as expected was because /tmp was remapped by systemd to /tmp/systemd-private-67fcab218d3d46bcb5092dd8a6d4789b-nagios-nrpe-server.service-lN2L1e/tmp

The issue had nothing to do with sudo but the fact that sudo was executing as a plugin running under the nrpe daemon which in turn was configured to have a private /tmp under systemd.

To resolve I had set to:

systemctl stop nagios-nrpe-server
set PrivateTmp=false in /etc/systemd/system/multi-user.target.wants/nagios-nrpe-server.service
systemctl daemon-reload
systemctl start nagios-nrpe-server
| improve this answer | |

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.