Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am running the boa webserver on an IP camera with BusyBox. I have set up a ScriptAlias and can run CGI scripts. I can echo "who" to the page and it says I am running as root, but I cannot write files to /etc.

ScriptAlias  /scripts/  /etc/httpd/html/scripts/

This is my page:

#! /bin/sh -e

echo -e "Cache-Control: no-cache\r" 
echo -e "Pragma: no-cache\r" 
echo -e "Expires: Thu, 01 Dec 1994 16:00:00 GMT\r" 
echo -e "Content-Type: text/html\r" 
echo -e "\r" 
echo

cat << EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>File Write test</title>
</head>
<body>
EOT

echo -e "$(who)"
echo "test">/etc/test

cat << EOT
</body>
</html>
EOT

This is my error log:

[root@axis-00408ca2fee9 /etc]1247# tail -f /var/log/boa.log
./filetest.cgi: ./filetest.cgi: 129: cannot create /etc/test: Permission denied

Here's the file permissions:

[root@axis-00408ca2fee9 /etc/httpd/html/scripts]1247# ls -l
-rwxr-xr-x    1 root     admin         597 Aug 15 07:03 filetest.cgi

BusyBox is set to run as root:

# User: The name or UID the server should run as.
# Group: The group name or GID the server should run as.

User root Group root

This is the output from the page:

USER TTY IDLE TIME HOST  root pts/0 . Oct 25 07:09 ::ffff:192.168.2.136

When I write the same file to /tmp, it shows the owner and group as anonymous:

[root@axis-00408ca2fee9 /etc/httpd/html/scripts]1247# ls /tmp/* -l
-rw-r--r--    1 root     root            0 Oct 25  2010 /tmp/snmpv3_initial_user_pw_tmp
-rw-r-----    1 anonymou anonymou        5 Aug 15 08:09 /tmp/test
share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.