Okular snap package cannot access files outside home directory

Bug #1745999 reported by Simon May
38
This bug affects 8 people
Affects Status Importance Assigned to Milestone
okular
New
Undecided
Scarlett Gately Moore
okular (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I’m not sure where the correct place is to report issues in snap packages, so I hope this isn’t completely wrong.

I installed okular on Ubuntu 17.10 via snap (“sudo snap install okular”). “snap info okular” gives me the following output:

name: okular
summary: Universal document viewer
publisher: kde
contact: https://www.kde.org
description: |
  Okular is a universal document viewer developed by KDE. Okular works on
  multiple platforms, including but not limited to Linux, Windows, Mac OS X,
  \*BSD, etc.

  Features:

  - Supported Formats: PDF, PS, Tiff, CHM, DjVu, Images, DVI, XPS, ODT, Fiction
  Book, Comic Book, Plucker, EPub, Fax
  - Sidebar with contents, thumbnails, reviews and bookmarks
  - Annotations support
snap-id: SfUqQ280Y4bJ0k64qtBKTTXq5ml46tvQ
commands:
  - okular
tracking: stable
installed: 16.12.3 (3) 7MB -
refreshed: 2017-03-27 12:56:54 +0200 CEST
channels:
  stable: 16.12.3 (3) 7MB -
  candidate: 17.04.3 (5) 8MB -
  beta: 17.04.3 (5) 8MB -
  edge: master+782a5fe (27) 5MB -

The okular snap seems to use “strict” confinement and is thus unable to access files outside the user’s home directory even for reading. However, for a “viewer”-type application like okular, this is very problematic:

– When downloading a file (e.g. PDF) in a browser like Firefox and choosing to open the file (instead of saving it somewhere in the home directory), the browser will typically place the file in /tmp/ and then open it using the default viewer for that file type. Since /tmp/ is outside the user’s home directory, okular is unable to open the file.

– When opening documentation which is installed to system directories (e.g. /usr/share/…) along with its corresponding application, okular is likewise unable to open the documentation files for viewing. For example, the “texdoc” program for the TeX typesetting system looks up the documentation for a specified package (typically in PDF format) and runs the default (PDF) viewer to show the documentation. This fails if the okular snap application is set as the default PDF viewer.

– Any files on mounted file systems, such as external storage (USB drives, SD cards, external hard drives…), network shares, etc., cannot be viewed with okular.

Attempting to open any such files results in a dialog with the following error message: “Could not open file:///path/to/file”. This does not provide any explanation for the reason of the failure.

Revision history for this message
In , 4aa7f31e (4aa7f31e) wrote :

I installed okular on Ubuntu 17.10 via snap (“sudo snap install okular”). The okular snap seems to use “strict” confinement and is thus unable to access files outside the user’s home directory even for reading. However, for a “viewer”-type application like okular, this is very problematic:

– When downloading a file (e.g. PDF) in a browser like Firefox and choosing to open the file (instead of saving it somewhere in the home directory), the browser will typically place the file in /tmp/ and then open it using the default viewer for that file type. Since /tmp/ is outside the user’s home directory, okular is unable to open the file.

– When opening documentation which is installed to system directories (e.g. /usr/share/…) along with its corresponding application, okular is likewise unable to open the documentation files for viewing. For example, the “texdoc” program for the TeX typesetting system looks up the documentation for a specified package (typically in PDF format) and runs the default (PDF) viewer to show the documentation. This fails if the okular snap application is set as the default PDF viewer.

– Any files on mounted file systems, such as external storage (USB drives, SD cards, external hard drives…), network shares, etc., cannot be viewed with okular.

Attempting to open any such files results in a dialog with the following error message: “Could not open file:///path/to/file”. This does not provide any explanation for the reason of the failure.

Revision history for this message
In , Albert Astals Cid (aacid) wrote :

Where did you download that snap package from?

Revision history for this message
In , 4aa7f31e (4aa7f31e) wrote :

(In reply to Albert Astals Cid from comment #1)
> Where did you download that snap package from?

Um, as I said, on Ubuntu 17.10 using “sudo snap install okular”. So from whatever source “snap” uses by default on a standard Ubuntu installation.

Revision history for this message
In , Nate-b (nate-b) wrote :

Sounds like an issue with how the Snap is packaged. I'd recommend reporting this to Ubuntu.

Revision history for this message
In , 4aa7f31e (4aa7f31e) wrote :

I’m sorry, but I was under the impression that the point of snaps was to have “universal” packages, which work on any distribution and are not customized for any particular one. “snap info okular” gives me the following output:

name: okular
summary: Universal document viewer
publisher: kde
contact: https://www.kde.org
description: |
  Okular is a universal document viewer developed by KDE. Okular works on
  multiple platforms, including but not limited to Linux, Windows, Mac OS X,
  \*BSD, etc.

  Features:

  - Supported Formats: PDF, PS, Tiff, CHM, DjVu, Images, DVI, XPS, ODT, Fiction
  Book, Comic Book, Plucker, EPub, Fax
  - Sidebar with contents, thumbnails, reviews and bookmarks
  - Annotations support
snap-id: SfUqQ280Y4bJ0k64qtBKTTXq5ml46tvQ
commands:
  - okular
tracking: stable
installed: 16.12.3 (3) 7MB -
refreshed: 2017-03-27 12:56:54 +0200 CEST
channels:
  stable: 16.12.3 (3) 7MB -
  candidate: 17.04.3 (5) 8MB -
  beta: 17.04.3 (5) 8MB -
  edge: master+782a5fe (27) 5MB -

I’ve also checked that the .snap file I got through “snap install okular” is identical to the one which can be downloaded here:
https://uappexplorer.com/snap/ubuntu/okular

The snap package lists “contact: https://www.kde.org”, which is why I opened a bug report here. If this is not an “official” okular snap package, then who is responsible for it?

In this bug: https://bugs.kde.org/show_bug.cgi?id=378130
the reporter was in the same situation (“sudo snap install okular” on Ubuntu) and it seems that there was no problem resolving it at this level.

Revision history for this message
In , Nate-b (nate-b) wrote :

Yes, but the devil's in the details. Snaps and Flatpaks are indeed supposed to be universal packages, but who packages them? Since this is a packaging but, that piece of information ins important. If we the developers package them, then we're responsible for the packaging. But if Ubuntu (or someone else) packages them, then they're responsible for the packaging.

Bug 378130 was marked as RESOLVED UPSTREAM, you'll notice.

Changed in kdegraphics:
importance: Unknown → Medium
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in okular (Ubuntu):
status: New → Confirmed
Revision history for this message
Christophe Biwer (yoshegg) wrote :

As the one year anniversary is approaching and this bug still exists, I want to redirect potential visitors of this page to this askubuntu answer where I found valuable information: https://askubuntu.com/a/20161/548635

To summarize, a workaround is to change thunderbirds TMP variable to something the snap version okular can access. Creating a custom .sh file with the following content should help:

#!/bin/sh
TMP=/home/or/media/folder nohup thunderbird &

Revision history for this message
Jimmy (jpaulos) wrote :

This bug report seems to correctly diagnose the issue, which is of course a major problem for a file "viewer"-type application.

As a filthy workaround, I found I could snap refresh with the --devmode switch explained here: <https://snapcraft.io/blog/demystifying-snap-confinement>. Of course, that page also explains "End users should not normally install snaps in devmode as this undoes any protections set out with confinement and interfaces."

Revision history for this message
Nic Brown (nicbrown) wrote :

#!/bin/sh https://goo.gl/MzS6NE
TMP=/home/or/media/folder nohup thunderbird &

Revision history for this message
markling (markling) wrote :

What has Thunderbird got to do with it?

Revision history for this message
markling (markling) wrote :

Numpty user scratches around in the dirt looking for some incy little nut that pinged off when he tried to attach some widget.

Choking and spluttering in all the dust kicked up down there, it's hard to see. There are all these big cowboy boots kicking around. Its a gabble of developers talking amongst themselves: "the nut... yeah the nut... and the bolt as well ... yeah ... and the thread ... yeah, the nut and the bolt and the thread ... no but, don't forget the oil though ... yeah, don't forget the lube ... yeah the nut and the bolt and the thread and the lube ... got that? ... yeah, 'course I've got that - what do you think I'm some sort of numpty or something? ... na-ah, i was just saying ... ".

They communicate by writing messages to one another on little bits of paper. Every now and again, one gets dropped and it floats down into the cloud of dust and boots, down there where the numpty user is scratching for answers. What's this, he says: "lube, bolts, guages ... eh?".

He bumps into some other numpty down there. "What the? ... its nuts innit? ... lube, you mean? ... no, nuts and threads ... what about bolts? ... come again? ... bolts ... never heard of them - don't you mean threads? ... dont ask me - don't you know anyone who knows anything about lube though? ... what's lube got to do with it? ... it says here on this scrap of paper I found in the dirt: 'lube' ... i really think you should be more concerned with nuts ... what nuts?".

Revision history for this message
In , markling (markling) wrote :

I also have this bug.

I installed Okular via snap just a few weeks ago. I am unable to open files that are not under /home.

It is notable that, when I use the Okular > File > Open dialog, I cannot either navigate to other folders or see pdfs in folders other than home.

In particular, the Okular file dialog refuses to enter the /mnt or /media directories. It will go into /tmp, yet when it gets there it cannot see any .pdf file I've put there. In fact, it cannot see any file there.

Nate's contribution implies the problem might be an upstream bug caused by snap failing to manage dependencies. And indeed I did find it necessary to follow the install steps given in Bug 378130 in order to install Okular properly. But fixing the dependencies by the procedure suggested does not fix this particular bug. Okular is still unable to open files that are not in my Home folder.

Revision history for this message
In , markling (markling) wrote :

By the way, Okular will neither open a pdf if I navigate to it from my home folder by way of symbolic link to another drive.

Neither will it open a direct symbolic link to a pdf in my /tmp directory, if i put that symbolic link in my /home folder, and attempt to open it there with Okular.

Changed in kdegraphics:
status: Unknown → Confirmed
Revision history for this message
Leo Zeitler (lezei) wrote :

This bug also affects me. I know older versions did not have this bug (non snap). Not sure what's happening.

Rik Mills (rikmills)
Changed in okular (Ubuntu):
status: Confirmed → Invalid
affects: kdegraphics → okular
Revision history for this message
In , saba46 (hpbiege) wrote :

Exactly the same bug with me after installing Ubuntu 20.04 recently. Okular installed by snap.

Revision history for this message
saba46 (hpbiege) wrote :

I removed snap-version and replaced by distribution-version (20.04) and anything works well!

Revision history for this message
saba46 (hpbiege) wrote :

Same for me!
I installed okular from snap in UBUNTU 20.04.1
Okular cannot open files stored in /tmp – for example downloded from Firefox
I removed okular from snap folder and reinstalled it with synaptic.
Now it works like ever!
So I guess that the snap-version of okular is buggy?!

Revision history for this message
Rik Mills (rikmills) wrote :

The okular snap is not maintained by anyone in Ubuntu, so commenting in this bug is just shouting into the void, as no-one here can fix it. Please use the upstream KDE bug to comment.

Changed in okular:
importance: Medium → Undecided
status: Confirmed → New
Changed in okular:
assignee: nobody → Scarlett Gately Moore (scarlettmoore)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.