sysctl via shell_exec

Hi,

I am having some trouble setting hw.snd.default_unit to my first and seccond sound-device using php. Setting it via console works fine, but when using it in my php-script on the webserver it just prints the setting of hw.snd.default_unit.

This is the line that I use:
Code:
$output=shell_exec("sysctl hw.snd.default_unit=1");

And that's what I get: hw.snd.default_unit:1

Any ideas? Searched the net and the forum already and found nothing.


Greg
 
And it does perfectly well, if the user running the php script IS NOT root...

I assume the user you're running your http server isn't root...
 
I've installed samba on the BSD-server. I'm using it as a NAS and there are two soundcards installed with two sets of speakers. One set is in the bathroom and the other one is in the sleeping-room.

I've programmed a webmask to choose playlists or radiostations to play and now I'm looking to find a way to change the soundcard on which to play. As I stated before, it works perfectly from the console. To be honest, I don't know if the script is started by the root of the system. How do I check or change it?

Thank you for your support,

Greg



BTW: it can take a while for me to read and answer, because my son was born some hours ago.
 
First of all, congrats for your newborn!!!!

Secondly, run:

# sockstat -4l

to see what user your apache uses (99.9999% it's running as www, since you haven't change its config I assume), then you should find a way to allow sysctl tuning via a non-root user, which probably leads you to security/sudo as the easiest solution and allow www to use sysctl(8) command.
 
Hi Mamalos.

First of all, thank you for your congrats.

Secondly, thank you for your help.

Apache is using the www-user to start.

I've edited the sudoers file and changed
my php-script to run sysctl via sudo.
What can I say? It works like a charm!


Greg
 
Back
Top