Data and config file questions

After 8 months of trying to snap my game, I finally was able to install and run it. Yay!
But there still are just a few little problems that need to be fixed.

The biggest one is that unless I run $ gladupe from either /snap/gladupe/current/ or /home/caleb/projects/gladupe, it won’t find my data files, so instead of beautiful image sprites I get ugly colored rectangles. How do I fix this or change $PWD to be /snap/gladupe/current?

The second is that getenv("HOME") (my program is in C) returns /home/caleb/snap/gladupe/x2 whereas it normally (as in non-snapped) returns /home/caleb. How do I fix that or should I change my code? I just want a file path to save the maps somewhere. Previously that was at /home/caleb/.local/share/gladupe

The other thing I need is a way to install a config file and a few maps when the snap is installed.
I’m imaging some shell script defined in the snapcraft.yaml file, but some tips in that direction (yaml shell script or otherwise) would be great.

Thanks

just write a small wrapper shell script that cd’s into the $SNAP dir (make it executable and make sure it ends up in bin/ in your snap package):

#! /bin/sh

cd $SNAP
exec "$@"

and change your command entry:

apps: 
  gladupe:
    command: yourscript.sh $SNAP/path/to/gladupe

you can not write to hidden dirs in the actual homedir of the user with snaps (well, at least not without some special interface setup that requires manual review of your snap). this is why snap packages have per-snap homedirs (/home/<user>/snap/<snapname>/current) and $HOME (along with the $SNAP_USER_DATA variable) always points to this to make sure everyhting is writable. if your code properly uses getenv(“HOME”) everywhere and doesnt have any hardcoded /home/<user>/ anywhere it should all be fine.

see:

@ogra Thanks for the reply. I made the wrapper and it works great.
I was also able to change the map location from /home/caleb/snap/gladupe/x1/.local/share/gladupe with some macros, and am able to load and save maps into it.

I tried adding a snap/hooks/install file, containing:

#! /bin/sh

cp -r $SNAP/maps/ $HOME/maps/
cp -r $SNAP/settings/ $HOME/settings/

but I don’t think they’re getting run. At least, when I add an echo command it didn’t do anything.

Also, I’m getting a bunch of (seemingly) random segfaults. My program doesn’t have memory problems (my code, at least), so I’m not sure what to make of them.
Are there any debugging programs I could use to introspect these? I usually use gdb and valgrind, but they’re not very informative in this case.

And all these errors are when in install it via sudo snap install --devmode gladupe_0.1_amd64.snap. When I install and run it by sudo snap install gladupe && gladupe it gives a immediately gives a segfault.

Edit:
The bunch of random segfaults were because I was trying to save files into directories that didn’t exist (because the hook wasn’t working), but snap store segfault is still there.

the install hook is only run at initial install of a snap AFAIK … try moving it to be a configure hook instead or do a “snap remove --purge gladupe” and install it afresh …

(also, dont forget to make the hook script executable, thats essential)

I changed the filename to snap/hooks/configure, double-checked that it’s executable, and reinstalled it, but it still isn’t getting called. Many thanks for you’re help though; I’m closer than ever before :clap:

hmm, you should be able to see some log output from the script by running journalctl -f in a second terminal while you run sudo snap install ... in another one.

my guess is you will see complaints about a directories not existing … you probably want to add some mkdir -p ... commands to the top of the script to make sure the target dirs exist before copying to them …

Here is my output when installing from the snap store:

caleb@whistling-duck:~$ journalctl -f
-- Logs begin at Mon 2019-04-01 12:33:49 -03. --
Mar 13 11:36:58 whistling-duck systemd[2264]: snap-gladupe-5.mount: Succeeded.
Mar 13 11:36:58 whistling-duck systemd[1]: snap-gladupe-5.mount: Succeeded.
Mar 13 11:36:58 whistling-duck ModemManager[1047]: <info>  Couldn't check support for device '/sys/devices/pci0000:00/0000:00:19.0': not supported by any plugin
Mar 13 11:36:59 whistling-duck ModemManager[1047]: <info>  Couldn't check support for device '/sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0': not supported by any plugin
Mar 13 11:36:59 whistling-duck systemd[1]: Reloading.
Mar 13 11:36:59 whistling-duck systemd[1]: /lib/systemd/system/dbus.socket:4: ListenStream= references a path below legacy directory /var/run/, updating /var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
Mar 13 11:36:59 whistling-duck systemd[1]: Starting resolvconf-pull-resolved.service...
Mar 13 11:36:59 whistling-duck systemd[1]: resolvconf-pull-resolved.service: Succeeded.
Mar 13 11:36:59 whistling-duck systemd[1]: Started resolvconf-pull-resolved.service.
Mar 13 11:36:59 whistling-duck sudo[29963]: pam_unix(sudo:session): session closed for user root
Mar 13 11:37:09 whistling-duck sudo[30180]:    caleb : TTY=pts/1 ; PWD=/home/caleb/projects/gladupe ; USER=root ; COMMAND=/usr/bin/snap install gladupe
Mar 13 11:37:09 whistling-duck sudo[30180]: pam_unix(sudo:session): session opened for user root by (uid=0)
Mar 13 11:37:09 whistling-duck snapd[985]: api.go:986: Installing snap "gladupe" revision unset
Mar 13 11:37:09 whistling-duck snapd[985]: snapmgr.go:295: cannot read snap info of snap "gladupe" at revision 5: cannot find installed snap "gladupe" at revision 5: missing file /snap/gladupe/5/meta/snap.yaml
Mar 13 11:37:15 whistling-duck tracker-store[29847]: OK
Mar 13 11:37:15 whistling-duck systemd[2264]: tracker-store.service: Succeeded.
Mar 13 11:37:27 whistling-duck snapd[985]: snapmgr.go:295: cannot read snap info of snap "gladupe" at revision 5: cannot find installed snap "gladupe" at revision 5: missing file /snap/gladupe/5/meta/snap.yaml
Mar 13 11:37:28 whistling-duck systemd[1]: Reloading.
Mar 13 11:37:28 whistling-duck systemd[1]: /lib/systemd/system/dbus.socket:4: ListenStream= references a path below legacy directory /var/run/, updating /var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
Mar 13 11:37:28 whistling-duck systemd[1]: Starting resolvconf-pull-resolved.service...
Mar 13 11:37:28 whistling-duck systemd[1]: resolvconf-pull-resolved.service: Succeeded.
Mar 13 11:37:28 whistling-duck systemd[1]: Started resolvconf-pull-resolved.service.
Mar 13 11:37:28 whistling-duck systemd[1]: Mounting Mount unit for gladupe, revision 5...
Mar 13 11:37:28 whistling-duck systemd[1]: Mounted Mount unit for gladupe, revision 5.
Mar 13 11:37:30 whistling-duck audit[30319]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.gladupe" pid=30319 comm="apparmor_parser"
Mar 13 11:37:30 whistling-duck kernel: kauditd_printk_skb: 4 callbacks suppressed
Mar 13 11:37:30 whistling-duck kernel: audit: type=1400 audit(1584110250.185:954): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.gladupe" pid=30319 comm="apparmor_parser"
Mar 13 11:37:30 whistling-duck audit[30321]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.gladupe.hook.install" pid=30321 comm="apparmor_parser"
Mar 13 11:37:30 whistling-duck kernel: audit: type=1400 audit(1584110250.253:955): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.gladupe.hook.install" pid=30321 comm="apparmor_parser"
Mar 13 11:37:30 whistling-duck audit[30320]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.gladupe.gladupe" pid=30320 comm="apparmor_parser"
Mar 13 11:37:30 whistling-duck kernel: audit: type=1400 audit(1584110250.257:956): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.gladupe.gladupe" pid=30320 comm="apparmor_parser"
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-6
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-7
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-7/2-7:1.1
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-0:1.0
Mar 13 11:37:32 whistling-duck systemd-udevd[30364]: Using default interface naming scheme 'v240'.
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-8
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-8/2-8:1.0
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-8/2-8:1.1
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-7/2-7:1.0
Mar 13 11:37:32 whistling-duck systemd-udevd[30352]: Using default interface naming scheme 'v240'.
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb3
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.0
Mar 13 11:37:32 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): EDID vendor "LGD", prod id 1034
Mar 13 11:37:32 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): Printing DDC gathered Modelines:
Mar 13 11:37:32 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): Modeline "1920x1080"x0.0  140.10  1920 1980 2016 2092  1080 1083 1088 1116 +hsync -vsync (67.0 kHz eP)
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.0/0003:1E7D:2C2E.0003
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb3/3-0:1.0
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.0/usbmisc/hiddev0
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:1d.0/usb1
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:1d.0/usb1/1-0:1.0
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1
Mar 13 11:37:32 whistling-duck systemd-udevd[30343]: Process '/sbin/crda' failed with exit code 234.
Mar 13 11:37:32 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1:1.0
Mar 13 11:37:32 whistling-duck systemd-udevd[30336]: Using default interface naming scheme 'v240'.
Mar 13 11:37:32 whistling-duck systemd-udevd[30362]: Using default interface naming scheme 'v240'.
Mar 13 11:37:32 whistling-duck systemd-udevd[30340]: Using default interface naming scheme 'v240'.
Mar 13 11:37:32 whistling-duck systemd-udevd[30343]: Using default interface naming scheme 'v240'.
Mar 13 11:37:32 whistling-duck systemd-udevd[30329]: Using default interface naming scheme 'v240'.
Mar 13 11:37:32 whistling-duck systemd-udevd[30334]: Using default interface naming scheme 'v240'.
Mar 13 11:37:32 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): EDID vendor "LGD", prod id 1034
Mar 13 11:37:32 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): Printing DDC gathered Modelines:
Mar 13 11:37:32 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): Modeline "1920x1080"x0.0  140.10  1920 1980 2016 2092  1080 1083 1088 1116 +hsync -vsync (67.0 kHz eP)
Mar 13 11:37:33 whistling-duck audit[30449]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/snap/core/8689/usr/lib/snapd/snap-confine" pid=30449 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck audit[30449]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/snap/core/8689/usr/lib/snapd/snap-confine//mount-namespace-capture-helper" pid=30449 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck kernel: audit: type=1400 audit(1584110253.105:957): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/snap/core/8689/usr/lib/snapd/snap-confine" pid=30449 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck kernel: audit: type=1400 audit(1584110253.105:958): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/snap/core/8689/usr/lib/snapd/snap-confine//mount-namespace-capture-helper" pid=30449 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck audit[30451]: AVC apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap-update-ns.gladupe" pid=30451 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck kernel: audit: type=1400 audit(1584110253.133:959): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap-update-ns.gladupe" pid=30451 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck audit[30452]: AVC apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap.gladupe.gladupe" pid=30452 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck kernel: audit: type=1400 audit(1584110253.285:960): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap.gladupe.gladupe" pid=30452 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck audit[30455]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.core" pid=30455 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck audit[30456]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.core.hook.configure" pid=30456 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck audit[30454]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.gladupe.hook.install" pid=30454 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck kernel: audit: type=1400 audit(1584110253.289:961): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.core" pid=30455 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck kernel: audit: type=1400 audit(1584110253.289:962): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.core.hook.configure" pid=30456 comm="apparmor_parser"
Mar 13 11:37:33 whistling-duck kernel: audit: type=1400 audit(1584110253.289:963): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.gladupe.hook.install" pid=30454 comm="apparmor_parser"
Mar 13 11:37:34 whistling-duck systemd[2264]: tmp-snap.rootfs_jFggXh.mount: Succeeded.
Mar 13 11:37:34 whistling-duck systemd[1]: tmp-snap.rootfs_jFggXh.mount: Succeeded.
Mar 13 11:37:34 whistling-duck ModemManager[1047]: <info>  Couldn't check support for device '/sys/devices/pci0000:00/0000:00:19.0': not supported by any plugin
Mar 13 11:37:34 whistling-duck ModemManager[1047]: <info>  Couldn't check support for device '/sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0': not supported by any plugin
Mar 13 11:37:35 whistling-duck sudo[30180]: pam_unix(sudo:session): session closed for user root
^C
caleb@whistling-duck:~$ 

When I run the program, it says:

Mar 13 11:40:48 whistling-duck audit[30728]: AVC apparmor="DENIED" operation="connect" profile="snap.gladupe.gladupe" pid=30728 comm="gladupe" family="unix" sock_type="stream" protocol=0 requested_mask="send receive connect" denied_mask="send connect" addr=none peer_addr="@/tmp/.X11-unix/X0" peer="unconfined"
Mar 13 11:40:48 whistling-duck kernel: audit: type=1400 audit(1584110448.436:966): apparmor="DENIED" operation="connect" profile="snap.gladupe.gladupe" pid=30728 comm="gladupe" family="unix" sock_type="stream" protocol=0 requested_mask="send receive connect" denied_mask="send connect" addr=none peer_addr="@/tmp/.X11-unix/X0" peer="unconfined"
Mar 13 11:40:48 whistling-duck kernel: gladupe[30728]: segfault at 0 ip 00007fc43165e3eb sp 00007ffc04453b90 error 4 in libSDL2-2.0.so.0.8.0[7fc43158b000+125000]
Mar 13 11:40:48 whistling-duck kernel: Code: b3 8c 02 00 48 89 05 2c e1 25 00 e8 df f1 ff ff 48 8d 35 c8 e3 25 00 48 8d 3d 09 92 02 00 48 89 05 0a e1 25 00 e8 c5 f1 ff ff <48> 8b 00 48 8d 35 ab e3 25 00 48 8d 3d 91 8c 02 00 48 89 05 e5 e0

Also, I am on Ubuntu 19.10 but using core: 18 in the snapcraft.yaml, and when I run $ snapcraft, part of the output (just after the prime phase) is

The requested action has already been taken. Consider
specifying parts, or clean the steps you want to run again.

Would either of those cause problem?

you are missing the x11 plug in your apps entry …

I added apps: gladupe: plugs: - x11, re-ran snapcraft and pushed it. Now I get this output when installing:

-- Logs begin at Fri 2019-04-26 10:34:05 -04. --
Mar 13 13:26:03 whistling-duck systemd[1]: snap-gladupe-13.mount: Succeeded.
Mar 13 13:26:03 whistling-duck systemd[2264]: snap-gladupe-13.mount: Succeeded.
Mar 13 13:26:03 whistling-duck systemd[1]: Reloading.
Mar 13 13:26:04 whistling-duck dbus-daemon[2293]: [session uid=1000 pid=2293] Successfully activated service 'org.freedesktop.Tracker1'
Mar 13 13:26:04 whistling-duck systemd[2264]: Started Tracker metadata database store and lookup manager.
Mar 13 13:26:04 whistling-duck systemd[1]: /lib/systemd/system/dbus.socket:4: ListenStream= references a path below legacy directory /var/run/, updating /var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
Mar 13 13:26:05 whistling-duck systemd[1]: Starting resolvconf-pull-resolved.service...
Mar 13 13:26:05 whistling-duck systemd[1]: resolvconf-pull-resolved.service: Succeeded.
Mar 13 13:26:05 whistling-duck systemd[1]: Started resolvconf-pull-resolved.service.
Mar 13 13:26:05 whistling-duck sudo[11834]: pam_unix(sudo:session): session closed for user root
Mar 13 13:26:12 whistling-duck sudo[12100]:    caleb : TTY=pts/1 ; PWD=/home/caleb/projects/gladupe ; USER=root ; COMMAND=/usr/bin/snap install gladupe
Mar 13 13:26:12 whistling-duck sudo[12100]: pam_unix(sudo:session): session opened for user root by (uid=0)
Mar 13 13:26:12 whistling-duck snapd[985]: api.go:986: Installing snap "gladupe" revision unset
Mar 13 13:26:36 whistling-duck tracker-store[12027]: OK
Mar 13 13:26:36 whistling-duck systemd[2264]: tracker-store.service: Succeeded.
Mar 13 13:27:31 whistling-duck systemd[1]: Reloading.
Mar 13 13:27:31 whistling-duck systemd[1]: /lib/systemd/system/dbus.socket:4: ListenStream= references a path below legacy directory /var/run/, updating /var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
Mar 13 13:27:31 whistling-duck systemd[1]: Starting resolvconf-pull-resolved.service...
Mar 13 13:27:31 whistling-duck systemd[1]: resolvconf-pull-resolved.service: Succeeded.
Mar 13 13:27:31 whistling-duck systemd[1]: Started resolvconf-pull-resolved.service.
Mar 13 13:27:31 whistling-duck systemd[1]: Mounting Mount unit for gladupe, revision 14...
Mar 13 13:27:31 whistling-duck systemd[1]: Mounted Mount unit for gladupe, revision 14.
Mar 13 13:27:33 whistling-duck audit[12261]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.gladupe" pid=12261 comm="apparmor_parser"
Mar 13 13:27:33 whistling-duck kernel: kauditd_printk_skb: 4 callbacks suppressed
Mar 13 13:27:33 whistling-duck kernel: audit: type=1400 audit(1584116853.043:1092): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.gladupe" pid=12261 comm="apparmor_parser"
Mar 13 13:27:33 whistling-duck audit[12263]: AVC apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap.gladupe.hook.configure" pid=12263 comm="apparmor_parser"
Mar 13 13:27:33 whistling-duck kernel: audit: type=1400 audit(1584116853.107:1093): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap.gladupe.hook.configure" pid=12263 comm="apparmor_parser"
Mar 13 13:27:33 whistling-duck audit[12262]: AVC apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap.gladupe.gladupe" pid=12262 comm="apparmor_parser"
Mar 13 13:27:33 whistling-duck kernel: audit: type=1400 audit(1584116853.115:1094): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap.gladupe.gladupe" pid=12262 comm="apparmor_parser"
Mar 13 13:27:33 whistling-duck dbus-daemon[2293]: [session uid=1000 pid=2293] Activating via systemd: service name='org.freedesktop.Tracker1' unit='tracker-store.service' requested by ':1.86' (uid=1000 pid=2886 comm="/usr/lib/tracker/tracker-miner-fs " label="unconfined")
Mar 13 13:27:33 whistling-duck systemd[2264]: Starting Tracker metadata database store and lookup manager...
Mar 13 13:27:33 whistling-duck dbus-daemon[2293]: [session uid=1000 pid=2293] Successfully activated service 'org.freedesktop.Tracker1'
Mar 13 13:27:33 whistling-duck systemd[2264]: Started Tracker metadata database store and lookup manager.
Mar 13 13:27:34 whistling-duck dbus-daemon[2293]: [session uid=1000 pid=2293] Activating via systemd: service name='org.freedesktop.Tracker1.Miner.Extract' unit='tracker-extract.service' requested by ':1.86' (uid=1000 pid=2886 comm="/usr/lib/tracker/tracker-miner-fs " label="unconfined")
Mar 13 13:27:34 whistling-duck systemd[2264]: Starting Tracker metadata extractor...
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb3
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb3/3-0:1.0
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-8
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3
Mar 13 13:27:39 whistling-duck systemd-udevd[12337]: Using default interface naming scheme 'v240'.
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-0:1.0
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-8/2-8:1.1
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-7
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-8/2-8:1.0
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.0
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-6
Mar 13 13:27:39 whistling-duck systemd-udevd[12324]: Using default interface naming scheme 'v240'.
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.0/0003:1E7D:2C2E.0004
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-3/2-3:1.0/usbmisc/hiddev0
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-7/2-7:1.1
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0
Mar 13 13:27:39 whistling-duck systemd-udevd[12304]: Process '/sbin/crda' failed with exit code 234.
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:14.0/usb2/2-7/2-7:1.0
Mar 13 13:27:39 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): EDID vendor "LGD", prod id 1034
Mar 13 13:27:39 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): Printing DDC gathered Modelines:
Mar 13 13:27:39 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): Modeline "1920x1080"x0.0  140.10  1920 1980 2016 2092  1080 1083 1088 1116 +hsync -vsync (67.0 kHz eP)
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:1d.0/usb1
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:1d.0/usb1/1-0:1.0
Mar 13 13:27:39 whistling-duck upowerd[2050]: treating change event as add on /sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1:1.0
Mar 13 13:27:39 whistling-duck systemd-udevd[12398]: Using default interface naming scheme 'v240'.
Mar 13 13:27:39 whistling-duck systemd-udevd[12319]: Using default interface naming scheme 'v240'.
Mar 13 13:27:39 whistling-duck systemd-udevd[12302]: Using default interface naming scheme 'v240'.
Mar 13 13:27:39 whistling-duck systemd-udevd[12325]: Using default interface naming scheme 'v240'.
Mar 13 13:27:39 whistling-duck systemd-udevd[12309]: Using default interface naming scheme 'v240'.
Mar 13 13:27:39 whistling-duck systemd-udevd[12334]: Using default interface naming scheme 'v240'.
Mar 13 13:27:39 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): EDID vendor "LGD", prod id 1034
Mar 13 13:27:39 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): Printing DDC gathered Modelines:
Mar 13 13:27:39 whistling-duck /usr/lib/gdm3/gdm-x-session[2290]: (II) modeset(0): Modeline "1920x1080"x0.0  140.10  1920 1980 2016 2092  1080 1083 1088 1116 +hsync -vsync (67.0 kHz eP)
Mar 13 13:27:40 whistling-duck dbus-daemon[2293]: [session uid=1000 pid=2293] Successfully activated service 'org.freedesktop.Tracker1.Miner.Extract'
Mar 13 13:27:40 whistling-duck systemd[2264]: Started Tracker metadata extractor.
Mar 13 13:27:40 whistling-duck audit[12428]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/snap/core/8689/usr/lib/snapd/snap-confine" pid=12428 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck audit[12428]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/snap/core/8689/usr/lib/snapd/snap-confine//mount-namespace-capture-helper" pid=12428 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck kernel: audit: type=1400 audit(1584116860.153:1095): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/snap/core/8689/usr/lib/snapd/snap-confine" pid=12428 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck kernel: audit: type=1400 audit(1584116860.153:1096): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="/snap/core/8689/usr/lib/snapd/snap-confine//mount-namespace-capture-helper" pid=12428 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck tracker-extract[12276]: Could not load desktop file 'file:///var/lib/snapd/desktop/applications/gladupe_gladupe.desktop': Key file does not start with a group
Mar 13 13:27:40 whistling-duck audit[12431]: AVC apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap.gladupe.gladupe" pid=12431 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck kernel: audit: type=1400 audit(1584116860.333:1097): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="snap.gladupe.gladupe" pid=12431 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck audit[12434]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.gladupe" pid=12434 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck audit[12436]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.core" pid=12436 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck audit[12435]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.gladupe.hook.configure" pid=12435 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck audit[12437]: AVC apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.core.hook.configure" pid=12437 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck kernel: audit: type=1400 audit(1584116860.341:1098): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.gladupe" pid=12434 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck kernel: audit: type=1400 audit(1584116860.341:1099): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.core" pid=12436 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck kernel: audit: type=1400 audit(1584116860.341:1100): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.gladupe.hook.configure" pid=12435 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck kernel: audit: type=1400 audit(1584116860.341:1101): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.core.hook.configure" pid=12437 comm="apparmor_parser"
Mar 13 13:27:41 whistling-duck systemd[2264]: tmp-snap.rootfs_VjBvZG.mount: Succeeded.
Mar 13 13:27:41 whistling-duck systemd[1]: tmp-snap.rootfs_VjBvZG.mount: Succeeded.
Mar 13 13:27:41 whistling-duck ModemManager[1047]: <info>  Couldn't check support for device '/sys/devices/pci0000:00/0000:00:19.0': not supported by any plugin
Mar 13 13:27:41 whistling-duck ModemManager[1047]: <info>  Couldn't check support for device '/sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0': not supported by any plugin
Mar 13 13:27:41 whistling-duck sudo[12100]: pam_unix(sudo:session): session closed for user root
Mar 13 13:27:50 whistling-duck systemd[2264]: tracker-extract.service: Succeeded.
^C

and when running:

-- Logs begin at Fri 2019-04-26 10:34:05 -04. --
Mar 13 13:27:40 whistling-duck kernel: audit: type=1400 audit(1584116860.341:1098): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.gladupe" pid=12434 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck kernel: audit: type=1400 audit(1584116860.341:1099): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap-update-ns.core" pid=12436 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck kernel: audit: type=1400 audit(1584116860.341:1100): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.gladupe.hook.configure" pid=12435 comm="apparmor_parser"
Mar 13 13:27:40 whistling-duck kernel: audit: type=1400 audit(1584116860.341:1101): apparmor="STATUS" operation="profile_replace" info="same as current profile, skipping" profile="unconfined" name="snap.core.hook.configure" pid=12437 comm="apparmor_parser"
Mar 13 13:27:41 whistling-duck systemd[2264]: tmp-snap.rootfs_VjBvZG.mount: Succeeded.
Mar 13 13:27:41 whistling-duck systemd[1]: tmp-snap.rootfs_VjBvZG.mount: Succeeded.
Mar 13 13:27:41 whistling-duck ModemManager[1047]: <info>  Couldn't check support for device '/sys/devices/pci0000:00/0000:00:19.0': not supported by any plugin
Mar 13 13:27:41 whistling-duck ModemManager[1047]: <info>  Couldn't check support for device '/sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0': not supported by any plugin
Mar 13 13:27:41 whistling-duck sudo[12100]: pam_unix(sudo:session): session closed for user root
Mar 13 13:27:50 whistling-duck systemd[2264]: tracker-extract.service: Succeeded.
Mar 13 13:28:01 whistling-duck gsd-media-keys[2786]: # _g_io_module_get_default: Found default implementation gvfs (GDaemonVfs) for ‘gio-vfs’
Mar 13 13:28:01 whistling-duck gsd-media-keys[2786]: # _g_io_module_get_default: Found default implementation dconf (DConfSettingsBackend) for ‘gsettings-backend’
Mar 13 13:28:01 whistling-duck gsd-media-keys[2786]: # watch_fast: "/org/gnome/terminal/legacy/" (establishing: 0, active: 0)
Mar 13 13:28:01 whistling-duck gsd-media-keys[2786]: # unwatch_fast: "/org/gnome/terminal/legacy/" (active: 0, establishing: 1)
Mar 13 13:28:01 whistling-duck gsd-media-keys[2786]: # watch_established: "/org/gnome/terminal/legacy/" (establishing: 0)
Mar 13 13:28:06 whistling-duck audit[12543]: AVC apparmor="DENIED" operation="connect" profile="snap.gladupe.gladupe" name="/run/user/1000/bus" pid=12543 comm="gladupe" requested_mask="wr" denied_mask="wr" fsuid=1000 ouid=1000
Mar 13 13:28:06 whistling-duck kernel: audit: type=1400 audit(1584116886.161:1102): apparmor="DENIED" operation="connect" profile="snap.gladupe.gladupe" name="/run/user/1000/bus" pid=12543 comm="gladupe" requested_mask="wr" denied_mask="wr" fsuid=1000 ouid=1000
Mar 13 13:28:06 whistling-duck kernel: audit: type=1400 audit(1584116886.165:1103): apparmor="DENIED" operation="connect" profile="snap.gladupe.gladupe" name="/run/user/1000/bus" pid=12543 comm="gladupe" requested_mask="wr" denied_mask="wr" fsuid=1000 ouid=1000
Mar 13 13:28:06 whistling-duck audit[12543]: AVC apparmor="DENIED" operation="connect" profile="snap.gladupe.gladupe" name="/run/user/1000/bus" pid=12543 comm="gladupe" requested_mask="wr" denied_mask="wr" fsuid=1000 ouid=1000
Mar 13 13:28:06 whistling-duck audit[12543]: AVC apparmor="DENIED" operation="open" profile="snap.gladupe.gladupe" name="/home/caleb/.cache/mesa_shader_cache/index" pid=12543 comm="gladupe" requested_mask="wrc" denied_mask="wrc" fsuid=1000 ouid=1000
Mar 13 13:28:06 whistling-duck kernel: audit: type=1400 audit(1584116886.401:1104): apparmor="DENIED" operation="open" profile="snap.gladupe.gladupe" name="/home/caleb/.cache/mesa_shader_cache/index" pid=12543 comm="gladupe" requested_mask="wrc" denied_mask="wrc" fsuid=1000 ouid=1000
Mar 13 13:28:10 whistling-duck tracker-store[12265]: OK
Mar 13 13:28:10 whistling-duck systemd[2264]: tracker-store.service: Succeeded.
^C

But now the program runs without segfaulting immediatly.

well, now is the time where you should start using snappy-debug :wink:

sudo snap install snappy-debug
...
snappy-debug.scanlog -r --only-snap=gladupe

that will tell you about the other missing interfaces … add them as asked by the tool :slight_smile:

I ran the debugger, and it gave me quite a bit of output like

= AppArmor =
Time: Mar 14 10:26:15
Log: apparmor="ALLOWED" operation="open" profile="snap.gladupe.gladupe" name="/home/caleb/.cache/mesa_shader_cache/6a/76b9c31446950f9989dd899df47de754bfd4fa" pid=25833 comm="gladupe" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
File: /home/caleb/.cache/mesa_shader_cache/6a/76b9c31446950f9989dd899df47de754bfd4fa (read)
Suggestions:
* adjust program to read necessary files from $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON
* add 'personal-files (see https://forum.snapcraft.io/t/the-personal-files-interface for acceptance criteria)' to 'plugs'

and

= AppArmor =
Time: Mar 14 10:06:51
Log: apparmor="ALLOWED" operation="file_perm" profile="snap.gladupe.gladupe" name="/run/dbus/system_bus_socket" pid=21946 comm="gladupe" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /run/dbus/system_bus_socket (read)
Suggestions:
* adjust program to use $SNAP_DATA
* adjust program to use /run/shm/snap.$SNAP_NAME.*
* adjust program to use /run/snap.$SNAP_NAME.*
* adjust snap to use snap layouts (https://forum.snapcraft.io/t/snap-layouts/7207)

So I changed the configure hook to copy the maps to $SNAP_COMMON (and in the code to getenv(“SNAP_COMMON”), and it worked! The only problem was the program segfaulted when I tried to write files into there. Then I tried changing it to $SNAP_USER_DATA, and the behavior was the same as when I used $HOME.
Are there any permissions I need to add to the hook?

Well, after a couple of google searches, I found that hooks can’t access any of the _USER_ directories because hooks are run by root, but it worked to just change the bin/run:

#! /bin/sh

cd $SNAP
if ! test -d $SNAP_USER_COMMON/maps; then
    echo "Copying default maps to $SNAP_USER_COMMON/maps"
    cp -r maps $SNAP_USER_COMMON/maps
fi
if ! test -d $SNAP_USER_COMMON/settings; then
    echo "Copying default settings to $SNAP_USER_COMMON/settings"
    cp -r settings $SNAP_USER_COMMON/settings
fi
./bin/gladupe "$@"
1 Like