I am currently working on a Linux based single board computer for an engineering company, and I am in charge of updating the local configuration website hosted within the board. The point of this configuration server is so that a user can connect to the board via their web browser and modify settings within the board.
The current setting that I am trying to create involves setting the timezone of the board's hardware clock. Unfortunately, the way board handles time zones is by setting up a system link between a file within /usr/share/zoneinfo/ to /etc/localtime.
My issue is that I need to run the following command from the website:
ln -s /usr/share/zoneinfo/Etc/GMT$1 /etc/localtime
where $1 is a + or - followed by a number. These are generated by a dropdown on the website.
My major problem occurs when I try to run this command from the PHP of the website. By catching the response of the exec command, I have found that I am not getting sufficient permissions to create/modify the symlink. I have tried the approach of creating a bash script and running that from the PHP. I have also tried running a C based executable from the PHP.
Things to note: The user passwords are randomly generated, and sudo is not included on the embedded Linux package.
My goal is to avoid running the Apache server as root because of security concerns. Is there any way to give individual scripts (possibly temporary) permissions to run the command, or any other sort of workaround to this?