On Wed, 2025-01-01 at 18:33 +0100, Matthias Hanft wrote:
>
> So it seems that I can't use any parameters at all any more -
> from PHP.
>
> What's the trick to get this working again?
Hmm. I can't replicate this failure. Using both `php -a` and foo.php,
I get expected results. (I'm using the INPUT chain because that's what
I have with real rules.)
---
php > exec("/sbin/iptables -L INPUT -n -v -x -w", $iptables);
php > var_dump($iptables);
array(37) {
[0]=>
string(46) "Chain INPUT (policy ACCEPT 0 packets, 0 bytes)"
...
...
---
$ cat foo.php
<?php
exec("/sbin/iptables -L INPUT -n -v -x -w", $iptables);
var_dump($iptables);
$ php foo.php
array(37) {
[0]=>
string(46) "Chain INPUT (policy ACCEPT 0 packets, 0 bytes)"
...
...
---
I noticed that your path to iptables is in /usr/bin/, but `which` on my
system says /sbin/. Are you running this as root? What version of PHP
are you using?