Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Diagnostics > Backup & Restore : Found a condition where "Download configuration as XML" fails, returns an empty file.

    Scheduled Pinned Locked Moved General pfSense Questions
    11 Posts 2 Posters 631 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • GertjanG
      Gertjan
      last edited by Gertjan

      Can some one try this scenario :

      86c615c0-37c3-43d9-a365-e4520dcc667c-image.png

      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 :

      0001b0c6-da62-4c61-b824-7a212dadd296-image.png

      add a rather big file (must be less then 1 Mbytes).
      I've uploaded a 610 Kbytes file.

      Now go to

      141b2197-fb8b-463e-8d7a-57fb7cba4f0b-image.png

      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 ?

      No "help me" PM's please. Use the forum, the community will thank you.
      Edit : and where are the logs ??

      1 Reply Last reply Reply Quote 0
      • stephenw10S
        stephenw10 Netgate Administrator
        last edited by

        Not seeing that in initial testing with a 380KB file. What pfSense version?

        1 Reply Last reply Reply Quote 0
        • stephenw10S
          stephenw10 Netgate Administrator
          last edited by

          Hmm, I do with a 605KB file in there too though. Digging...

          GertjanG 1 Reply Last reply Reply Quote 0
          • GertjanG
            Gertjan @stephenw10
            last edited by Gertjan

            @stephenw10

            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

            83b63cf5-2f35-4f47-882c-f871c9162ddb-image.png

            So :

            80dc276e-fbe4-475b-a5d5-224604bdcdbd-image.png

            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 ...

            No "help me" PM's please. Use the forum, the community will thank you.
            Edit : and where are the logs ??

            1 Reply Last reply Reply Quote 1
            • stephenw10S
              stephenw10 Netgate Administrator
              last edited by

              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.

              GertjanG 1 Reply Last reply Reply Quote 0
              • GertjanG
                Gertjan @stephenw10
                last edited by Gertjan

                @stephenw10

                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.

                No "help me" PM's please. Use the forum, the community will thank you.
                Edit : and where are the logs ??

                stephenw10S 1 Reply Last reply Reply Quote 0
                • stephenw10S
                  stephenw10 Netgate Administrator
                  last edited by

                  Opened a bug to track this: https://redmine.pfsense.org/issues/15624

                  1 Reply Last reply Reply Quote 0
                  • stephenw10S
                    stephenw10 Netgate Administrator @Gertjan
                    last edited by

                    @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?

                    GertjanG 1 Reply Last reply Reply Quote 0
                    • GertjanG
                      Gertjan @stephenw10
                      last edited by

                      @stephenw10

                      750 Kbytes - sorry.
                      The 1 M byte limit works.

                      No "help me" PM's please. Use the forum, the community will thank you.
                      Edit : and where are the logs ??

                      1 Reply Last reply Reply Quote 0
                      • stephenw10S
                        stephenw10 Netgate Administrator
                        last edited by

                        Patch on the redmine works for me.

                        GertjanG 1 Reply Last reply Reply Quote 1
                        • GertjanG
                          Gertjan @stephenw10
                          last edited by

                          @stephenw10

                          Same thing for me 👍

                          No "help me" PM's please. Use the forum, the community will thank you.
                          Edit : and where are the logs ??

                          1 Reply Last reply Reply Quote 1
                          • First post
                            Last post
                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.