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.
setuid(0)
fixed it. I've marked the question as a dupe.