PHP 8.1.34 being installed still via GUI update. EOL & vulnerable to PHP2Shell?

Very cool @jeremypoulter ! I’d be inclined to agree with @alexandrecuer here - we have two interlinked problems here - one is reliably/atomically serving updates to the deployed fleet of Emon* devices, and the other is efficiently maintaining the operating system itself so we can stay current with the accelerating pace of security updates in this new world of AI cat and mouse games.

I love the architectural approach - an immutable core OS, A/B boot and update stuff - keep the workloads like emoncms and emonhub in containers, makes it very easy to add HA, ebusd, etc etc onto the same hardware, and move away from fragile shell scripts, git pulls and dpkg crunching away and falling over / running out of disk. Endless OS has been doing an immutable OS with ostree since 2014 way before it was cool.:slight_smile:

The RAUC stuff, test harness, etc all looks excellent. If we weren’t on Pi, I’d probably suggest systemd-boot / systemd-sysupdated which is where all of the UAPI / Image Based Linux / systemd / Amutable / etc cool cats are investing. But as we’re on Pi, the “when in Rome…” argument carries a lot of water, and EFI firmware on Pi is really janky.

That said, on the other problem of efficiently maintaining the OS so we can stay current with security updates, moving to effectively committing the OEM project to maintaining their own OS seems like a step in very much the wrong direction. Maintaining our own Buildroot makes every glibc, libpng, etc etc CVE our own responsibility. I know I’m hardly a seasoned contributor here, but I would go far as strongly advising against it. :sweat_smile:

Back to the “when in Rome” argument, given that Raspberry Pi maintain the OS for Raspberry Pi, and Debian maintains the rest, and on the whole we seem to be a Debian shop (I’d assume that our container images will either be Debian based, or Alpine which is kind of just diet Debian for containers), my recommendation would be to keep all of the updater work and infrastructure, and work on a mkosi process to build the OS payloads by unpacking debs. Then we’ll get all of the security updates, latest Pi kernels and firmware, etc for free, and we just have to re-run the image build to get latest everything, rather than keeping on top of dozens of components patches/releases, and hosting multi-TB multi-hour rebuilds. That’s a great deal of human and infrastructure cost for benefits I’d struggle to articulate.

(I’ve not reviewed the code or tried anything yet, but GitHub - valtzu/rpi-mkosi: An example on how to build & distribute images for Raspberry Pi with mkosi · GitHub looks interesting - it goes down the systemd-boot path which I think is overkill, but it might be interesting to look at how they use mkosi.)

Of course, feel free to ignore me - I might be able to find time to play with some of this, but am meant to be reviewing some legal paperwork for work so I can’t promise anything! I’m not the one doing the work and volunteer time is famously non-fungible. Appreciate everything you all do! :heart:

From my point of view mosquitto-PHP is fine

of course it is not really maintained, and it has to be compiled but it does the job. when building the all in one docker alpine image using s6 overlay, I rarely have problem with mosquitto-PHP…

see GitHub - Open-Building-Management/emoncms: emoncms home-assistant addon · GitHub

I haven’t yet, I basically took the original Docker image and updated it with some of the stuff in the all-in-one docker, in principle it can be a base to build on. You actually probably don’t want just one docker image, but one location not get the images. For example my (original) use case was for heatpumpmonitor.org development where I just wanted EmonCMS and not the other stuff. I would imagine the Home Assistant addon includes some bits but not MQTT. This sort of thing is super easy to do as well as things like building different base OSs and you will see many examples of this.

That is the plan, will be transferred to the OEM or EmonCMS org when it is more complete product

You are correct the solid update is only part of the solution, my intention is to use dependabot or a similar tool (Renovate looks promising) to make sure the dependencies are kept up-to-date. This is largely why a added the x86 VM and testing. Depedancies can be updated on a branch, tested and merged automatically. Should even be able to test on a Pi via CI, we found this great product, USB-SD-Mux, that allows you to pragmatically switch an SD card between a PC and the Pi.

I will certainly take a look at mkosi, but the use of build root (which is what Alpine is based on, not Debian) vastly reduces the dependencies so there are only a handful, The kernel, build root, docker, RAUC and maybe a few others, once you have had to deal with Node depedancies that is child’s play :wink: The build time is a currently around 1-3 hours on the default GitHub runners (depending on caching) though which is not great so definitely something I want to look at.

beyond my limted knowledge, but the other use case is running emoncms on a PVE setup. Previously I have used the build scripts on an Ubuntu Container. PVE is definitely a use case to be considered :slight_smile:

Thanks @jeremypoulter, I didn’t mean to suggest Alpine was derived from Debian, it was just me being glib. :slight_smile: Fundamentally for me, it’s an OS that someone else maintains, and we can consume their binaries and pull in the packages we need.

I totally agree that automating maintenance and testing as much as possible is the goal - Renovate, QEMU and USB-SD-Mux testing are all very cool, and a Dockerfile can get us a consistent build environment. But I don’t think either of those necessarily tracks through to “so we should use Buildroot”.

For Raspberry Pi, their serving suggestion is Raspberry Pi OS, and that’s the system they support first with kernels, firmware, etc. If we build on that, backed by Debian’s security team, our security updates and hardware support are as current as Raspberry Pi OS itself, or at worst one rebuild / re-pin away, which is the work of minutes rather than hours.

Rather than argue in the abstract, my friend Claude and I tried mocking it up for the x86 target: EmonOS without Buildroot: building its A/B images and RAUC bundle from Debian packages with mkosi (proof of concept) · GitHub. It’s a Debian builder Dockerfile, a ~40-line mkosi.conf and a build script. It runs against your EmonOS checkout and re-uses the overlays, prepare-target.sh, slot layout, genimage config, GRUB A/B script and bundle.sh more or less unchanged. It looks promising to me:

  • A clean build takes about 50 seconds. The system slot is 306 MB.
  • It boots your A/B layout in QEMU, and RAUC, Docker, first-boot, persist and so on all come up.
  • rauc install of the Debian-built bundle → reboot → boots slot B.

Caveats are in the README. The Pi is untested, U-Boot would still need building from source for your env layout, Debian stable has RAUC 1.13 and Docker 26 rather than the latest (we could add Docker’s own apt repo), and I haven’t ported the data-image preload so it just does boot testing rather than your full test suite.

(I’d also look at whether we can avoid U-Boot entirely and use the Pi firmware’s tryboot A/B support, which already works on Pi 4 and Pi 5 and is what Raspberry Pi themselves have signed up to support going forward. It would mean each slot’s kernel lives on its own FAT boot partition, so the partition layout would change a bit. Pi 5 support has also taken a long time to land upstream in U-Boot.)

Not a merge request, just a sketch of something that to me has fewer moving parts and doesn’t need us to take on any Buildroot building/maintenance/etc, but still gets all of the atomic A/B updates and automated testing, which to me is the hugely valuable piece. Would love to know what you think if you have a chance to play with it.

So to some degree the starting point of the project was HAOS and that is the structure they took, so it is not like we would be winging it, but equally a do see (and agree with) your points. Will definitely take a look at what you have done. If it doesn’t make things to complicated I may try building both solutions in parallel.

In principle already done, there is an x86 VM version. Not tried it in Proxmox directly but no reason it should not work. I do however wonder if an ISO would be easier so you can do it from the GUI, for some reason Proxmox does not support importing images from the GUI, at least it didn’t last time I tried it.

There is MQTT on the HA addon but you can use external broker if yu want