Customizing snapd (sandbox patching for Ubuntu 20.04)

I’m trying to come up with a solution to use the new Chromium snap with other software like Slack & Zoom. I think there’s going to be a better long-term solution for this soon, but I need a solution for my current Ubuntu 19.10 system.

Usually I can apply simple patches by recompiling the deb source packages, e.g. I’ve been trying something like this:

TMPDIR=$(mktemp -d)
cd $TMPDIR
apt-get -y source snapd
sed -i 's/"http", "https", "mailto", "snap", "help"/"http", "https", "mailto", "snap", "help", "apt", "zoommtg", "slack"/' snapd-2.42.1+19.10/usersession/userd/launcher.go
cd snapd-2.42.1+19.10 && dch -l$(hostname) fix_missing_app_types
cd ..
cd snapd-2.42.1+19.10$(hostname)1 && DEB_BUILD_OPTIONS=nocheck debuild -b -uc -us
cd ..
sudo dpkg -i snapd_2.42.1+19.10$(hostname)1_amd64.deb
sudo reboot

For some reason this isn’t working correctly for me. The compilation & install are fine (I’ve tried putting in other debug strings & can see them in /usr/bin/snap), but I still see the old error message in syslog when trying to launch one of the new URLs.

I feel like I’m missing something simple – any advice?

Major thanks to Alexey Kuznetsov on launchpad who figured out the issue.

The complete working example is:

apt-get build-dep snapd
TMPDIR=$(mktemp -d)
cd $TMPDIR
apt-get -y source snapd
sed -i 's/"http", "https", "mailto", "snap", "help"/"http", "https", "mailto", "snap", "help", "apt", "zoommtg", "slack"/' snapd-*/usersession/userd/launcher.go
sed -i 's/!osutil.GetenvBool(reExecKey, true)/true/' snapd-*/cmd/cmd_linux.go
cd snapd-* && dch -l$(hostname) fix_missing_app_types
cd ..
cd snapd-* && DEB_BUILD_OPTIONS=nocheck debuild -b -uc -us
cd ..
sudo dpkg -i snapd_*.deb
sudo service snapd restart
killall snap