Hardcoded /opt Paths in Binary Files


I’m trying to run the VMware SSL VPN client which is supplied as binaries only, and unfortunately the binaries have hardcoded /opt paths in them.

I’ve tried patching the binaries by replacing all references to /opt with /tmp, but that hasn’t worked and there are still references to /opt (although many references are indeed replaced).
I used this for patching strings: Every day with Linux: Patch strings in binary files with sed

I’ve also tried running it in a buildFHSUserEnv env but /opt isn’t writeable.

Is there a better way to go about this?


Theoretically it would be possible to bind-mount a directory as /opt with buildFHSUserEnvBubblewrap since bubblewrap supports it. But I don’t think the aforementioned function provides a way at this time. I only briefly glanced at it, but take a look and see if perhaps with some tweaks it can be made to work. It’s located at pkgs/build-support/build-fhs-userenv-bubblewrap

Thanks Emmanuel, I’ll give that a try

It looks like the underlying chroot env doesn’t support extraBindMounts as of chroot-user: rewrite in C, drop CHROOTENV_EXTRA_BINDS · NixOS/nixpkgs@edb59ee · GitHub

The rationale was that the host is now mounted at /host and everything could be symlinked in, making extraBindMounts unnecessary (see Improvements for FHS user chrootenv by abbradar · Pull Request #16030 · NixOS/nixpkgs · GitHub).
However this doesn’t help with these situations… so I might reinstate this functionality or just make /opt writeable in the chroot env

EDIT: I just realised that buildFHSUserEnvBubblewrap uses bubblewrap (what a shock) so the above limitation doesn’t apply to it. So that looks like it’ll be an easier tweak to make.