Sample Header Ad - 728x90

setuid root problem with sticky bit: curl can't write to a new/empty directory in /tmp

1 vote
1 answer
74 views
I'm carrying out a one-off configuration operation which requires a remote client to communicate with a remote server. The client runs Apache, which runs a configure binary, which fetches various scripts from the server with curl. The returned scripts must be run by root. On the client configure is C++ code, and the binary is setuid root (no lectures please, unless you've got a better idea): $ ll /var/www1/cgi-bin/configure -rwsr-xr-x 1 root root 76160 Jul 13 19:20 /var/www1/cgi-bin/configure* The configure code creates a randomly-named directory in /tmp with mkdtemp : # ls -ld /tmp/vs_MYSosq drwx------ 2 root www-data 4096 Jul 13 20:29 /tmp/vs_MYSosq # ll /tmp/vs_MYSosq total 8 drwx------ 2 root www-data 4096 Jul 13 20:29 ./ drwxrwxrwt 25 root root 4096 Jul 13 20:29 ../ The code then execs curl, which retrieves the scripts, but then fails to write them to this directory (it exits with code 23). Any idea why curl can't write to this directory? Is this fixable or do I have to move out of /tmp (which is preferred because it's a ramdisk)? It's presumably a sticky-bit issue, but I can't see how, since the directory is empty and curl isn't attempting to over-write anything.
Asked by QF0 (391 rep)
Jul 13, 2024, 07:46 PM
Last activity: Jul 13, 2024, 09:41 PM