WAGO / pfc-firmware-sdk-G2

Firmware SDK for PFC200-G2 family
Mozilla Public License 2.0
13 stars 5 forks source link

WBM refuses to open. #12

Closed Jabbl closed 10 months ago

Jabbl commented 10 months ago

I've compiled FW25 according to the instructions, but encounter issues when trying to navigate to the device.

The console log of the browser gives an error

pfc.js?dace362d8608afcb78ac:20 Uncaught (in promise) Error: Unexpected token '<', "<?php

inc"... is not valid JSON
    at new t (pfc.js?dace362d8608afcb78ac:20:1595)
    at e.<anonymous> (pfc.js?dace362d8608afcb78ac:90:7589)
    at pfc.js?dace362d8608afcb78ac:90:6157
    at Object.throw (pfc.js?dace362d8608afcb78ac:90:6262)
    at s (pfc.js?dace362d8608afcb78ac:90:5027)

The PLC has no source map for the pfc.js file, which means debugging is quite hard, but it looks to me like the WBM tries loading either infos.php or login_data.php as JSON and therefore throws since PHP-files start with <?php.

Full browser stack trace:

pfc.js?dace362d8608afcb78ac:20 Uncaught (in promise) Error: Unexpected token '<', "<?php

inc"... is not valid JSON
    at new t (pfc.js?dace362d8608afcb78ac:20:1595)
    at e.<anonymous> (pfc.js?dace362d8608afcb78ac:90:7589)
    at pfc.js?dace362d8608afcb78ac:90:6157
    at Object.throw (pfc.js?dace362d8608afcb78ac:90:6262)
    at s (pfc.js?dace362d8608afcb78ac:90:5027)
t @ pfc.js?dace362d8608afcb78ac:20
(anonymous) @ pfc.js?dace362d8608afcb78ac:90
(anonymous) @ pfc.js?dace362d8608afcb78ac:90
(anonymous) @ pfc.js?dace362d8608afcb78ac:90
s @ pfc.js?dace362d8608afcb78ac:90
Promise.then (async)
(anonymous) @ pfc.js?dace362d8608afcb78ac:90
(anonymous) @ pfc.js?dace362d8608afcb78ac:90
(anonymous) @ pfc.js?dace362d8608afcb78ac:90
(anonymous) @ pfc.js?dace362d8608afcb78ac:90
o @ pfc.js?dace362d8608afcb78ac:90
e.reloadParameters @ pfc.js?dace362d8608afcb78ac:90
e @ pfc.js?dace362d8608afcb78ac:90
p @ pfc.js?dace362d8608afcb78ac:90
(anonymous) @ pfc.js?dace362d8608afcb78ac:90
n @ pfc.js?dace362d8608afcb78ac:20
(anonymous) @ pfc.js?dace362d8608afcb78ac:20
(anonymous) @ pfc.js?dace362d8608afcb78ac:20
(anonymous) @ pfc.js?dace362d8608afcb78ac:20
(anonymous) @ pfc.js?dace362d8608afcb78ac:20

Device type: 750-8212 Device name: PFC200V3-5FAA98 Browser: Tested Chrome, Edge and Firefox

falk-werner commented 10 months ago

Hello @Jabbl,

in order to reproduce the issue we have the following questions:

Since the WBM-request returns a PHP script and PHP should be interpreted by the webserver by default, we would like to ask you to perform some checks on the device:

This file should look like

fastcgi.map-extensions = ( ".html" => ".php" )

$SERVER["socket"] =~ default_sockets {
  $HTTP["url"] =~ "\.php$" {
    fastcgi.server += (
      ".php" =>
      ( "localhost" =>
        (
          "socket" => "/tmp/php-fastcgi.socket",
          "bin-path" => "/usr/bin/php-cgi",
          "min-procs" => 1,
          "max-procs" => 2,
          "max-load-per-proc" => 8,
          "idle-timeout" => 50,
          # Fix PATH_INFO for PHP scripts that rely on it (like Wordpress).
          "broken-scriptfilename" => "enable"
        )
      )
    )
  }
}
Jabbl commented 10 months ago

I've used WAGO Ethernet Settings with a service cable to adjust the device to use a static IP-address.\ URL: 10.50.1.25\ Note: The favicon shows correctly, the title of the tab is Web-based Management and I am correctly redirected to 10.50.1.25/wbm/.

php -i: php-i.txt

Other commands:

> root@PFC200V3-5FAA98:~ opkg list-installed | grep php
php-pam - 2.2.4
php-selection - 1.2.0
php8 - 8.1.16+wago2

> root@PFC200V3-5FAA98:~ cat /etc/lighttpd/lighttpd.conf | grep "mod_cgi" -B 4
server.modules             = (
    "mod_access",
    "mod_accesslog",
    "mod_auth",
    "mod_cgi",

> root@PFC200V3-5FAA98:~ cat /etc/lighttpd/lighttpd.conf | grep "include_shell"
include_shell "cat fastcgi.confd/*.conf 2>/dev/null ||:"

> root@PFC200V3-5FAA98:~ cat /etc/lighttpd/fastcgi.confd/php.conf
cat: can't open '/etc/lighttpd/fastcgi.confd/php.conf': No such file or directory

> root@PFC200V3-5FAA98:~ cat /etc/lighttpd/fastcgi.confd/param-service.conf
$SERVER["socket"] =~ default_sockets {
  fastcgi.server += (
    "/wda" =>
    ((
      "socket" => "/tmp/paramserv.fcgi.socket",
      "check-local" => "disable"
    )),
    "/files" =>
    ((
      "socket" => "/tmp/paramserv.files.fcgi.socket",
      "check-local" => "disable"
    ))
  )
}
Jabbl commented 10 months ago

Since php.conf is missing I decided to check the ptxconf file and compare it to the one on Github.\ I then noticed that option PTXCONF_LIGHTTPD_MOD_FASTCGI_PHP was disabled in my configuration, even though I never remember unselecting it.

The only change I remember doing is enabling jq, as I wanted that tool to be available to me, but maybe opening the ptxdist menu changed some other settings in the background?

I've now re-enabled PTXCONF_LIGHTTPD_MOD_FASTCGI_PHP and will try again.

Jabbl commented 10 months ago

With PTXCONF_LIGHTTPD_MOD_FASTCGI_PHP re-enabled the WBM now responds correctly.\ I'm not sure what caused this to be disabled in the first place, but at least it works correctly now.