Bug 432271 - Can't save a file out of Okular
Summary: Can't save a file out of Okular
Status: REPORTED
Alias: None
Product: okular
Classification: Applications
Component: general (other bugs)
Version First Reported In: 1.10.2
Platform: openSUSE Linux
: NOR major
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-29 10:30 UTC by Joerg
Modified: 2025-04-10 07:24 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Picture of saving it (12.90 KB, image/png)
2025-04-10 07:24 UTC, raul_ct_
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joerg 2021-01-29 10:30:54 UTC
SUMMARY
every time i try to save a file out of Okular to a folder in my home-directory, i get the reply "Datei kann nicht in „/tmp/okular.Lufxxf“ gespeichert werden." (file can't save in /tmp/okular.Lufxxf). 
Out of other applications i can save files without any problem.

STEPS TO REPRODUCE
1. I choose menue |file|save| (or |save as|) and select a sub folder in my home directory
2. When I confirm to save the file, i get the reply, that i can't save in /tmp/...
3. 

OBSERVED RESULT
It is not possible to save any file from okular.

EXPECTED RESULT


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 5.18.6
KDE Frameworks Version: 5.71.0
Qt Version: 5.12.7
OS: Opensuse Leap 15.2

ADDITIONAL INFORMATION
Comment 1 Yuri Chornoivan 2021-01-29 10:37:38 UTC

*** This bug has been marked as a duplicate of bug 402017 ***
Comment 2 Laura David Hurka 2021-01-29 16:14:19 UTC
Why is this a duplicate of bug 402017?

This bug report describes that Okular attempts to save in a wrong place. Bug 402017 describes that Okular attempts to read a file from a not existing place.

The given example is /tmp/okular.Lufxxf, which does not look like the user opened a file from e. g. KMail, because the filename contains “okular”, not “kmail”.

@Joerg: Can you describe how you opened the file?
Comment 3 Yuri Chornoivan 2021-01-29 16:26:26 UTC
(In reply to David Hurka from comment #2)
> Why is this a duplicate of bug 402017?

Because the above-mentioned file names are typical for the browser-opened PDFs.
Comment 4 Joerg 2021-01-30 18:42:37 UTC
(In reply to David Hurka from comment #2)
> Why is this a duplicate of bug 402017?
> 
> This bug report describes that Okular attempts to save in a wrong place. Bug
> 402017 describes that Okular attempts to read a file from a not existing
> place.
> 
> The given example is /tmp/okular.Lufxxf, which does not look like the user
> opened a file from e. g. KMail, because the filename contains “okular”, not
> “kmail”.
> 
> @Joerg: Can you describe how you opened the file?

@David: thanks for your reply. I agree with you. 
 It's the same result, whether I open a local file and try to save it or i try to save a browser-opend file. Both don't work and i'm asked to choose another directory than /tmp/..., although i selected a folder in my home-directory.
Comment 5 Yuri Chornoivan 2021-01-30 18:44:50 UTC
Change the status for further investigation (cannot reproduce it btw).
Comment 6 Joerg 2021-02-01 19:29:52 UTC
An other problem with Okular occured today. I can't print from Okular. To get an error-report, i started Okular from console. When i tried to print, the reply on console was "/usr/bin/lpr: Fehler - Zugriff auf »/tmp/okular_IhOqaH.ps« nicht möglich - Keine Berechtigung" witch means: no access to /tmp ... - no authorization.
Comment 7 Albert Astals Cid 2021-02-01 21:02:40 UTC
This really smells like your system is broken/badly configured.
Comment 8 Joerg 2021-02-04 21:14:29 UTC
(In reply to Albert Astals Cid from comment #7)
> This really smells like your system is broken/badly configured.

I don't think so, because only okular shows the problems mentioned above. Other applications work without any problems.
Comment 9 Albert Astals Cid 2021-02-04 22:25:24 UTC
You're not authorized to write to /tmp, sorry but that means your system is broken.
Comment 10 Joerg 2021-02-05 21:27:41 UTC
(In reply to Albert Astals Cid from comment #9)
> You're not authorized to write to /tmp, sorry but that means your system is
> broken.

That's not the reason for my problem. I can write to /tmp (I just tested it and saved a file out of kate in /tmp). In the directory access control owner and group are set to root, all others are allowed to read and change. Only okular has some kind of problem with it. 
Anyway, I don't want to save in /tmp, when I try to save out of okular (I select my home directory), but okular complains, that it can't save to /tmp.
Comment 11 gggeri91 2024-06-01 10:18:16 UTC
The very same thing happened to me today. It happened to me several times in the past, but today I decided to google about this issue more and found this bug report. This ticket describes the bug very well.  

What lead to the issue in my case:
STEPS TO REPRODUCE
1. Open a PDF file in Okular
2. Make annotations, then press "Save" button. 
3. Make annotations, add text with the type tool, then press "Save" button. 
4. Repeat steps 2 and 3, keep doing modifications and then save the file. After some time you will run into the bug. 



OBSERVED RESULT
When pressing the "Save" button an error is shown: "File could not be saved in '/tmp/okular.bvEIkY'. Try to save it to another location."
The "Save As..." button also does not work, the file cannot be saved to any other location (for example, any folder in my home folder). 

As a work-around, to not loose an hour of work I had to print into PDF, that works but it is far from the ideal solution.

EXPECTED RESULT
File is saved, no data loss.
Comment 12 gggeri91 2024-06-01 10:24:08 UTC
This may be relevant: The issue happens to me only when I open files from a CIFS mount. If I copy over the file to my local home directory it never crashes. Maybe Okular uses the tmp files when opening from a CIFS file system?
Comment 13 dmaier 2024-06-25 12:34:59 UTC
Same here:
Pdf opened from samba share, after annotating 2-3 times, save/save as fail (file can't save in /tmp/okular.xyz).
Same pdf opened from the local file system, after annotation 2-3 times, save/save as work as expected.
Archlinux, i3wm, Okular version 24.05.1
Comment 14 Albert Astals Cid 2024-06-27 21:41:05 UTC
For when someone has time, please explain exactly how to setup that scenario you're describing, knowing about developing okular is a totally different skill to knowing what CIFS is or how to set it up.
Comment 15 dmaier 2024-06-28 09:11:35 UTC
(In reply to Albert Astals Cid from comment #14)
Hi, first of all thanks your code care efforts, cifs means a samba share, where files are offered within a network for a plenty of users. I suggest you set up a virtual machine for it, for example an Ubuntu Server 20.04 LTS. 

Samba setup on the server:
sudo apt install samba
sudo adduser --no-create-home --disabled-login --shell /bin/false testuser
sudo smbpasswd -a testuser
sudo mkdir /srv/data/all
sudo vim /etc/samba/smb.cnf
  ...
  workgroup = team
  ...
  [testusershare]
  comment = Testuser Directories
  path = /srv/data/all
  browsable = yes
  read only = no
  create mask = 0770
  force create mode = 0770
  directory mask = 0770
  force directory mode = 0770
  inherit permissions = yes
  inherit acls = yes
sudo systemctl restart smbd

On the client side, i. e. a current Ubuntu:
sudo mkdir /media/testusershare
sudo apt install cifs-utils 
vim /home/<localuser>/.smbcredentials
  username=testuser
  password=<secret>
chmod 600 /home/<localuser>/.smbcredentials 

vim /etc/fstab
  ...
  //<IP virtual server>/testusershare /media/testusershare cifs credentials=/home/<localuser>/.smbcredentials, uid=<uid localuser>,gid=<gid localuser>,vers=3.1.1,nobrl  0 0
...

sudo mount -a

Voilà, then you should be able to save pdf files on /media/testusershare for testing purpose.

Regards,
dm
Comment 16 John 2025-04-04 20:19:02 UTC
I'm encountering this issue as well; it's an older version of Okular (1.9.3) but the symptoms seem pretty similar and I've got some extra context that might be helpful; for me, the issue is (so far, unfortunately) 100% reproducible.

I have a PDF with forms that I downloaded from the Internet (specifically, an MS Teams DM but the relevancy there seems like a real stretch, heh), saved to my home directory (first to `~/Downloads`, and then relocated to `~` directly just to see if it would help as a workaround), and then opened as a local file with Okular.  In both cases, neither "Save" nor "Save As..." works (they both give the same error about not being able to write to `/tmp/okular.*`, regardless of the destination directory I actually select.

Here's the interesting bit: I looked at the file in question (the suffix changes every time) and that file _is_ getting created in `/tmp` (the parent `/tmp` directory has mode `1777` AKA `drwxrwxrwt`) BUT it's being given mode `0` itself and is empty.  So, that's why the write error: the `okular` process has write permissions to `/tmp`, so it can create the empty file, but it has no write permissions _to the file itself_ so it can't actually save.  Theoretically if one could beat the race condition, one could fix the mode on `/tmp/okular.xxxxx` before it tries to write the PDF data...any theories on how to accomplish that are welcome.

Just as a "visual aid", this is what it looks like if you list the files in question while the alert dialog is open (Okular will delete the temp file as soon as you click OK):

```
% ls -ld /tmp /tmp/okular.*
drwxrwxrwt 58 root root 12288 Apr  4 15:05 /tmp
----------  0 john john     0 Apr  4 15:05 /tmp/okular.hfaxHW
```

I checked my umask value just as a precaution, but it's `077` as expected.  Besides, it doesn't look like that's it:

```
% umask
077
% grep '^Umask:' /proc/$(pgrep okular)/status
Umask:  0077
```

I can't even print the PDF to PDF because the temp file for that (`/tmp/okular_eDMEMB.ps` in this case) is also being created with `0` permissions, so the GhostScript conversion fails.
Comment 17 raul_ct_ 2025-04-10 07:24:22 UTC
Created attachment 180144 [details]
Picture of saving it

Can confirm, editing a file via 
sftp://[user]@[ip]/srv/[routetofile] 

and saving it, it saves into this route:


Soft locks okular, and you have to unlock it by using some hotkey, for example Ctrl+o(opening a file) opens a prompt, after closing the prompt, Okular its responsive again