Jeff Pang wrote:
> 2007/7/9, Elijah Alcantara <elijah.alcantara@gmail.com>:
>
>>
>> I was thinking of saving these rules to the database then if the user
>> clicks on the apply button at the frontend the squid proxy will fetch
>> all these rules from a text/config file that the system created from
>> the database.
>>
>
> The only thing I can think is that you may run webserver with root
> since you need to modify squid.conf and execute 'squid -k reconfigure'
> command.btw,parsing and redefining squid.conf by php is not easy,is
> it?Maybe perl is better choice.
>
> good luck.
I find it quite easy ;-) PHP is after all just a better version of Perl...
Read squid.conf it into a variable, explode on '\n'. Then loop and
explode again on ' '. Finally process as needed. By that I mean insert
into your DB using the ACL names as cross-linked keys and line# for
*_access keys.
To dump the results back simply loop over your tables doing a DB lookup,
use CATSTR() in SQL and ORDER BY the particular key in use for each table.
Done. Also, theres no need to run either squid or webserver as root. You
can simply:
make the user: of the particular .php page doing fopen() on squid.conf
the same cache_effective_user as set in squid, that will allow
Read-Write access to squid.conf without changing its ownership.
the PHP.ini safe_mode_exec_dir directory needs to include a symlink to
the squid binary if PHP is run in safe mode for the exec("squid -k
reconfigure") call.
Or you could maybe just chown("squid.conf") from PHP between fclose()
and exec().
Amos
Received on Mon Jul 09 2007 - 04:49:57 MDT
This archive was generated by hypermail pre-2.1.9 : Wed Aug 01 2007 - 12:00:03 MDT