SOLVED grandstream/gxp2140 Auto Provision Uncaught Exception

Status
Not open for further replies.

ricktendo

Member
Jun 12, 2021
40
5
8
I have FusionPBX installed in Raspbian on a RaspberryPi 3B+, I have been trying to auto provision my Grandstream GXP2140 phone using the "grandstream/gxp2140" template and it was not working, this also appears to affect the gxp2130, gxp2135, gxp2160, gxp2170 (and possibly others but I have not tested)

So to find out why I manually pulled the config using curl like so:

Here is the result

Code:
curl -i -u test:changeme --digest http://192.168.15.40/app/provision/aabbccddeeff.cfg

HTML:
HTTP/1.1 200 OK
Server: nginx/1.14.2
Date: Thu, 10 Jun 2021 01:02:55 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: PHPSESSID=6rb6llmk5iv8v8dinjoavo81qd; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache

<br />
<b>Fatal error</b>:  Uncaught Exception: Unexpected input at line8526:
 in /var/www/fusionpbx/resources/templates/engine/smarty/sysplugins/smarty_internal_templatelexer.php:368
Stack trace:
0 /var/www/fusionpbx/resources/templates/engine/smarty/sysplugins/smarty_internal_templatelexer.php(279): Smarty_Internal_Templatelexer->yylex1()
1 /var/www/fusionpbx/resources/templates/engine/smarty/sysplugins/smarty_internal_smartytemplatecompiler.php(123): Smarty_Internal_Templatelexer->yylex()
2 /var/www/fusionpbx/resources/templates/engine/smarty/sysplugins/smarty_internal_templatecompilerbase.php(481): Smarty_Internal_SmartyTemplateCompiler->doCompile('<?xml version="...', true)
3 /var/www/fusionpbx/resources/templates/engine/smarty/sysplugins/smarty_internal_templatecompilerbase.php(402): Smarty_Internal_TemplateCompilerBase->compileTemplateSource(Object(Smarty_Internal_Template), false, NULL)
4 /var/www/fusionpbx/resources/templates/engine/smarty/sysplugins/smarty_template_compiled.php(184): Smarty_Internal_TemplateCompilerBase- in <b>/var/www/fusionpbx/resources/templates/engine/smarty/sysplugins/smarty_internal_templatelexer.php</b> on line <b>368</b><br />

Note: I have already reported this bug but so far no confirmation if they were able to replicate this, could somebody confirm my findings?

Steps to reproduce:
  1. Create a new Extension and assign/create new Device with any random MAC example aa:bb:cc:dd:ee:ff (because we will simulate provision/pull the config manually,) use the grandstream/gxp2140 template
  2. Ensure you enable Provision and you have http_auth_username, http_auth_password configured (in my example I use test:changeme credentials)
  3. Simulate the pull of the phone config from any computer on the network like so:
Code:
curl -i -u test:changeme --digest http://192.168.15.40/app/provision/aabbccddeeff.cfg

P.S. as a temporary workaround I have been using the older gxp21xx template, but this is based on older firmware and does not have many of the features present in the dedicated gxp2140 template, let me know if there is other information I could provide.
 

ad5ou

Active Member
Jun 12, 2018
892
205
43
Just tried that template on a test system with latest code and it works as expected.

Also in case you didn't know, you can use the GUI to download the files for testing.
In top right of device edit page select "files"
1624542312313.png
Then click new dropdown to select the <mac>.xml
1624542359251.png
Assuming you have http_auth turned on, the we browser will prompt for credentials.

I've seen "smarty" errors when a template has been edited with broken variables etc. Other than that, I can't think of much else.
 
  • Like
Reactions: ricktendo

ricktendo

Member
Jun 12, 2021
40
5
8
I have also tried downloading from the GUI and I get error "Unauthorized"

Code:
192.168.XX.XX - - [23/Jun/2021:03:23:16 -0600] "GET /app/provision/index.php?mac=aabbccddeeff&file={$mac}.xml&content_type=application/octet-stream HTTP/1.1" 401 13 "https://192.168.XX.XX/app/devices/device_edit.php?id=508de129-a352-4612-a12c-ea1c621e37a4" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"

Maybe I am missing a php dependency, like php-mbstring for Email to FAX, or my version of php breaks it. Like I mentioned I have it installed on Raspberry Pi, did a fresh re-install also.

Note: I have not manually edited any of the templates, and am on fusionpbx version 4.5.26
 
Last edited:

ricktendo

Member
Jun 12, 2021
40
5
8
I have now tested on Debian 10 amd64 and the gxp2140 auto provision issue is NOT present, however I still cannot download the files from the dropdown in the WEB-UI (still get access denied)

Autoprovision issue seems to only affect Raspberry Pi OS 32bit
 
Last edited:

ricktendo

Member
Jun 12, 2021
40
5
8
Quote from Mark:
I recently experienced the problem on Raspberry Pi. So tonight I decided to see how to fix it. I started by deleting sections of the code to figure out where it was failing. It might be the template size that was causing the issue. The 2130, 2135, 2140, 2160, and 2170 all have large sections of the configuration that are commented out with a # symbol. So to fix this problem without deleting those lines I added {literal} and {/literal} to instruct Smarty template engine not to parse those lines and the strategy worked. The problem is now fixed for the Raspberry Pi. Took me a couple hours to solve this and it is now working.
 
Status
Not open for further replies.