Hi,
I would like to ask for some help/guidance how to properly execute bin/sh from inside snap. I have tested many different approaches but not of them seams to work so far and I’m out of ideas.
I’m trying to build snap for binary that executes for example mosquitto_pub trough /bin/sh. I added dash to snap but binary still executes systems /bin/sh and command executed by binary - /bin/sh -c mosquitto_pub
will not work because system is not aware of snap PATH.
So then I tried to rewrite /bin/sh with layout inside snapcraft.yaml but it is not possible - snapcraft is complaining about it upon snap build process.
Then I tried to run sh with full path, but also without much luck as binary and library path is unknown for sh:
~# /snap/some_app/current/bin/sh -c "ldd /snap/some_app/current/usr/bin/mosquitto_pub"
linux-vdso.so.1 (0x00007ffc47350000)
libmosquitto.so.1 => not found
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe82a734000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe82ab44000)
Only way I was able to run mosquitto_pub was providing path variables to full sh path:
~# LD_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void:/snap/some_app/current/lib/x86_64-linux-gnu:/snap/some_app/current/usr/lib/x86_64-linux-gnu:/snap/some_app/current/lib:/snap/some_app/current/usr/lib:/snap/some_app/current/lib/x86_64-linux-gnu:/snap/some_app/current/usr/lib/x86_64-linux-gnu PATH=$PATH:/snap/some_app/current/usr/bin/:/snap/some_app/current/sbin/:/snap/some_app/current/bin/ /snap/some_app/current/bin/sh -c "mosquitto_pub"
Also end user is able to provide in config file what binary to execute like shell="mosquitto_pub ..."
or shell="curl ..."
and in standalone and docker versions it works, but in snap version asking end user to replace it with very long line would be inconvenient.
Hopefully I described my issue clearly, but if not - please do ask what I should clarify.
Any help would be much appreciated!