Diagnostics > Backup & Restore : Found a condition where "Download configuration as XML" fails, returns an empty file.
-
Can some one try this scenario :
Use the default setting, and then select (marked green) "Skip packages".
Click "Download configuration as XML" and the browser should download the XML file.Now, activate the captive portal interface on a LAN, and go here :
add a rather big file (must be less then 1 Mbytes).
I've uploaded a 610 Kbytes file.Now go to
again, select again "Skip packages".
Download the XML Configuratyion file, you should get the XML file without package information. = Ok.
I got : a zero byte size file. = No ok./usr/local/pfSense/include/www/backup.inc line close to line 164 :
$data = preg_replace('/\t*<installedpackages>.*<\/installedpackages>\n/sm', '', $data);
fails.
Instead of removing everything between <installedpackages> and </installedpackages>, it return an empty array.The $data string or loaded "config.xml" is to big ?
When I remove the big captive portal <element,>the uploaded file, the issue is gone, all is well. An xml file without package info is downloaded.
Can some one reproduce ?
-
Not seeing that in initial testing with a 380KB file. What pfSense version?
-
Hmm, I do with a 605KB file in there too though. Digging...
-
pfSense 24.03.
What happens is : see the "preg_replace" above : as soon as the input $data becomes 'to big' the return results becomes an empty array, and that explain the zero byte file.
Coffee wasn't effective yesterday.
This morning, I found an 11 years old Maximum length for a string for preg_replace() in PHP? which shows exactly what I (think) I'm experiencing.
A solution is proposed.pfSense uses the default pcre.backtrack_limit = 1000000
So :
Just before the preg_replace, 5 fold the value :
ini_set('pcre.backtrack_limit', 5000000);
solves the issue right away.
Not sure if this is a clean / best way to handle things. My 4100 handles this just fine. Must be tested on smaller devices like the 1100 ? I hate to 'explode' numbers like this.If absurd, IMHO, to stash info in the pfSense config file anyway, but I know it can get big.
The captive portal File Manager allows files to be uploaded up until 1 Mbytes, and the number of files has no constraint ... -
Mmm, the interesting this is that if I add files of at least the same size using the Filer package there is no problem. That is inside the installed packages section of course but the input data is still large.
Also if you choose not to skip the rrd data the remaining file is usually huge. But still strips the package info fine.
-
The xml (config file) is read and parsed first. Then the issue happens under mentioned conditions.
The rdd data is added later on added. See line 188 in the backup.inc file.Btw : when I add a big data chunk using the File manager in the captive portals section, this data is stored outside of the <installedpackages>.*</installedpackages> XML block.
I haven't tried the other way around : a package with a lot of data.Anyway, the preg_replace parses the entire xml file.
The size of the chunk between <installedpackages>.*</installedpackages> is not big all for me.Take note : I found this situation because I had a 750 Mb (edit : 750 K bytes - see below) PDF file uploaded into the portal's file manager. It was just a 'test' and not essential for me.
And normally, I never save the pfSense config without the package info as that backup would be quiet useless. -
Opened a bug to track this: https://redmine.pfsense.org/issues/15624
-
@Gertjan said in Diagnostics > Backup & Restore : Found a condition where "Download configuration as XML" fails, returns an empty file.:
I had a 750 Mb PDF file uploaded into the portal's file manager.
It allowed you to upload that? Do you mean 750kB?
-
750 Kbytes - sorry.
The 1 M byte limit works. -
Patch on the redmine works for me.
-
Same thing for me