My remove hook is getting the following permission errors on Ubuntu (though it works great on Manjaro):
cannot open /home/myusername/snap/mysnap/common/mytextfile.txt: Permission denied
…and…
rm: cannot remove '/home/myusername/snap/mysnap/common/mytextfile.txt': Permission denied
mytextfile.txt
is placed into that user folder via the snap app itself (using os.environ['SNAP_USER_COMMON']
in python3), after install, and while running as the user. The file even has 777 permissions. But then the remove hook, running as root, can’t access it. What do I need to do to enable the hook to access the file that the snap app itself placed there?
When I run:
snap connections mysnap
…I get this, so it appears as though the home
interface is connected, even though I am running in strict mode and do not manually connect it anywhere:
Interface Plug Slot Notes
desktop mysnap:desktop :desktop -
desktop-legacy mysnap:desktop-legacy :desktop-legacy -
gsettings mysnap:gsettings :gsettings -
home mysnap:home :home -
network mysnap:network :network -
network-bind mysnap:network-bind :network-bind -
unity7 mysnap:unity7 :unity7 -
x11 mysnap:x11 :x11 -
Here are the relevant parts of my YAML:
plugs:
network:
network-bind:
desktop:
desktop-legacy:
x11:
unity7:
home:
gsettings:
hooks:
remove:
plugs: [network, network-bind, home]
parts:
remove-hook:
plugin: nil
build-packages:
- wget
stage-packages:
- wget
override-build: |
cat > myfile << 'EOF'
#!/bin/sh
filelocation="/home/myusername/snap/mysnap/common/mytextfile.txt"
while IFS= read -r mystringvalue
do
echo "$mystringvalue"
#wget stuff goes here...
done < "$filelocation"
rm "$filelocation"
EOF
install -D myfile $SNAPCRAFT_PART_INSTALL/snap/hooks/remove
Thank you in advance for any suggestions you can offer!