Snapping get-iplayer

get-iplayer is a Perl script that allows you to download iPlayer programs (there’s no other way to download iPlayer programs on Linux because iPlayer Downloads only runs on Windows and macOS). Obviously you may only download iPlayer programs if you have a TV license and you must delete the programs you’ve downloaded 30 days after they’re shown on TV.

I’ve made good progress on snapping this program thanks to the people in the Perl channel on Freenode and @elopio. I have a working Devmode snap, though I need to silence the locale error and, @wimpress, I can’t seem to just put env LC_ALL=C.UTF-8 in front of scripts/run-cli.pl after command (not that this seems to solve the issue for Neofetch (which I tried this workaround on) anyway).

When trying to run this program confined, I get ERROR: Cannot read options file /etc/get_iplayer/options and I’m not sure what interfaces to give it. If I can’t get it to run confined then I could just try classic confinement. Here’s the output of grep "audit:" /var/log/syslog. As usual, sudo /snap/bin/snappy-debug.security scanlog get-iplayer (use suggested here) seems to just hang for me.

Building this snap won’t work using build.snapcraft.io (which uses Ubuntu 16.04, or has that changed?) because the versions of ffmpeg and atomicparsley are too out-of-date there. So when asking upstream if they want to build this themselves I guess I can just suggest they use Launchpad. Alternatively I need to convert ffmpeg and atomicparsley into parts. This seems easy enough with atomicparsley but I’m not sure what config flags to use for ffmpeg. Peek uses an ffmpeg part which seems to work and at the bottom of this page are the features that get-iplayer needs from ffmpeg.

So:

  • How do I confine this?
  • I need thoughts on whether I should convert atomicparsley and ffmpeg into parts instead of using the Deb packages. If I should convert ffmpeg into a part then what config flags do I use for it?
  • @wimpress I need help with the locale error for this app

For the locale error you might like to try adding:

after:
    - desktop-glib-only

to the part, and launching the script with bin/desktop-launch. Obviously this isn’t an ideal solution, but it might point you in the right direction. I had similar problems with youtube-dl and this removed the locale related errors. I haven’t had a chance to track down a real solution yet.

Cheers,
Alistair

Using

apps:
  get-iplayer:
    command: bin/desktop-launch scripts/run-cli.pl
  server:
    command: scripts/run-server.pl
    daemon: simple

I get /snap/get-iplayer/x48/bin/desktop-launch: line 225: /home/adam/scripts/run-cli.pl: No such file or directory

Before rebooting (not good this happened?):

cannot create lock directory /run/snapd/lock: Permission denied

This error came up for other snaps too. Also got errors like error: cannot find app "telegram-sergiusens" in "telegram-sergiusens"

Note, as invoked, scanlog will tail the file, looking for new denials. If it doesn’t find any, it will look like is it hanging. If this is not working for you, can you give the details of the OS, snapd version, snappy-debug version and exact steps to reproduce (eg, it works fine here with sudo snappy-debug.security scanlog hello-world, then starting hello-world.sh and doing ls /)

As for your denials:

  • apparmor="DENIED" operation="create" profile="snap.get-iplayer.server" pid=20445 comm="perl" family="inet" sock_type="stream" protocol=6 requested_mask="create" denied_mask="create"
  • you need to plugs network
  • apparmor="DENIED" operation="open" profile="snap.get-iplayer.get-iplayer" name="/etc/get_iplayer/options" pid=20487 comm="perl" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
  • you need to adjust your program to look for /etc/get_iplayer/options somewhere else. This file isn’t going to exist on a typical system and your snap needs to provide it in one of the data dirs, eg, $SNAP, $SNAP_DATA, $SNAP_COMMON, $SNAP_USER_DATA or $SNAP_USER_COMMON

(this is actually what snappy-debug scanlog should’ve suggested to you)

2 Likes

Ah, the documentation doesn’t make it clear that the snappy-debug command should be run before the strict snap is run? It does indeed work when I have them both running simultaneously :confused:

How do I do that without rewriting the get-iplayer Perl script? I thought we should be able to snap applications without having to rewrite them? This is the line of the script that sets that directory…

Regarding snappy-debug-- it depends on how it is invoked. The default behavior is to tail and show only new violations.

As for being able to snap applications without having to rewrite them: it depends on the software. If the software uses a lot of hard-coded paths or assumptions about the OS and/or is generally not portable, then it might need updating (this isn’t strictly unique to snappy). Since it is a perl script, you might be able to perform a strategic sed as part of your snapcraft build. Alternatively, you might also be interested in the snapcraft-preload part: https://github.com/sergiusens/snapcraft-preload

if you look just above the line you referred to you’ll see that you can set GETIPLAYERSYSPREFS to point to the options file anywhere you want (e.g. $SNAP_USER_DATA/options).

1 Like

I’m getting the error below on build.snapcraft.io (since I have a separate repo for this now (which I will transfer to snapcrafters if I can get this working and get the locale error fixed…) here’s the GitHub Issue for this issue if you’d rather respond there):

Parts 'atomicparsley' and 'get-iplayer' have the following file paths in common which have different contents:
    README.md

I’ve tried adding organize to both parts to rename README.md, I’ve tried using mv. No luck. Any ideas?

(Here’s my attempts to resolve the issue so far)

try adding $SNAPCRAFT_PART_INSTALL to the target of the mv commands … like:

    install:
      mv README.md $SNAPCRAFT_PART_INSTALL/README-get-iplayer.md

Thanks for the suggestion!
Still get the same error

For future reference, get-iplayer is maintained by snapcrafters GitHub org (commits imply that @popey does the work), not me https://github.com/snapcrafters/get-iplayer
Issues should be filed at https://github.com/snapcrafters/get-iplayer/issues