pdfarranger / pdfarranger

Small python-gtk application, which helps the user to merge or split PDF documents and rotate, crop and rearrange their pages using an interactive and intuitive graphical interface.
GNU General Public License v3.0
3.5k stars 212 forks source link

Open with/ drag and drop from mounted location not working (Permission error) #1126

Open atmelino opened 1 week ago

atmelino commented 1 week ago

Describe the bug

When I drag and drop a file that is on a mounted drive, for example a USB drive or a drive mounted via fstab, from the nautilus file manager into the pdfarranger window, nothing happens. The same behavior occurs when I try to use "Open with". If the file is on the Desktop, it works.

I narrowed the problem down to a permission error (see below)

To Reproduce

Steps to reproduce the behavior:

  1. Open nautilus
  2. Navigate to a mounted drive
  3. Right Click on PDF file and select Open with -> pdfarranger

or

  1. Open nautilus
  2. Navigate to a mounted drive
  3. Open pdfarranger
  4. Drag and drop PDF file from nautilus into pdfarranger

To monitor the error:

  1. Open terminal
  2. type "pdfarranger"
  3. Open nautilus
  4. Navigate to a mounted drive
  5. Drag and drop PDF file from nautilus into pdfarranger (or open with)

No error occurs when the PDF file is on the Desktop.

Expected behavior

Drag and drop file into pdfarranger window, expect file to be loaded

Input files

Any PDF file

Screenshots

no screenshots

Terminal output

Traceback (most recent call last):  

  File "/snap/pdfarranger/33/usr/lib/python3.10/dist-packages/pdfarranger/pdfarranger.py", line 2154, in sw_dnd_received_data
    pageadder.addpages(filename)
  File "/snap/pdfarranger/33/usr/lib/python3.10/dist-packages/pdfarranger/core.py", line 499, in addpages
    doc_data = self.get_pdfdoc(filename, basename)
  File "/snap/pdfarranger/33/usr/lib/python3.10/dist-packages/pdfarranger/core.py", line 464, in get_pdfdoc
    pdfdoc = PDFDoc(filename, basename, self.stat_cache[filename],
  File "/snap/pdfarranger/33/usr/lib/python3.10/dist-packages/pdfarranger/core.py", line 370, in __init__
    shutil.copy(self.filename, self.copyname)
  File "/usr/lib/python3.10/shutil.py", line 417, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.10/shutil.py", line 254, in copyfile
    with open(src, 'rb') as fsrc:
PermissionError: [Errno 13] Permission denied: '/media/atmelino/Crucial X6/90062-B-INST-1.pdf'

System and Versions

$ snap version && snap connections pdfarranger  

snap    2.65.3
snapd   2.65.3
series  16
ubuntu  24.04
kernel  6.8.0-45-generic
Interface               Plug                        Slot                            Notes
content[gnome-42-2204]  pdfarranger:gnome-42-2204   gnome-42-2204:gnome-42-2204     -
content[gtk-3-themes]   pdfarranger:gtk-3-themes    gtk-common-themes:gtk-3-themes  -
content[icon-themes]    pdfarranger:icon-themes     gtk-common-themes:icon-themes   -
content[sound-themes]   pdfarranger:sound-themes    gtk-common-themes:sound-themes  -
dbus                    -                           pdfarranger:pdfarranger         -
desktop                 pdfarranger:desktop         :desktop                        -
desktop-legacy          pdfarranger:desktop-legacy  :desktop-legacy                 -
gsettings               pdfarranger:gsettings       :gsettings                      -
home                    pdfarranger:home            :home                           -
opengl                  pdfarranger:opengl          :opengl                         -
shared-memory           pdfarranger:shared-memory   :shared-memory                  -
wayland                 pdfarranger:wayland         :wayland                        -
x11                     pdfarranger:x11             :x11                            -
soumyaDghosh commented 1 week ago

You have 2 options,

Also, @atmelino can you confirm if this 24.04 installation of yours is a clean installation or updated from old installations?

atmelino commented 1 week ago

Didn't help:

sudo snap connect pdfarranger:removable-media causes error error: snap "pdfarranger" has no plug named "removable-media"

sudo apt install xdg-desktop-portal-gnome xdg-desktop-portal-gtk already installed, output: xdg-desktop-portal-gnome is already the newest version (46.2-0ubuntu1). xdg-desktop-portal-gtk is already the newest version (1.15.1-1build2). 0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.

This is on a newly installed Ubuntu 24.04, installed to an empty disk.

More information: This problem did not occur on previous version that were installed via sudo apt install. I have had similar problems with other snap installed programs.

soumyaDghosh commented 1 week ago

Didn't help:

sudo snap connect pdfarranger:removable-media causes error error: snap "pdfarranger" has no plug named "removable-media"

sudo apt install xdg-desktop-portal-gnome xdg-desktop-portal-gtk already installed, output: xdg-desktop-portal-gnome is already the newest version (46.2-0ubuntu1). xdg-desktop-portal-gtk is already the newest version (1.15.1-1build2). 0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.

This is on a newly installed Ubuntu 24.04, installed to an empty disk.

More information: This problem did not occur on previous version that were installed via sudo apt install. I have had similar problems with other snap installed programs.

Actually I also faced some problems today with home plug, may be what you can try is revert snapd, if it's there in your machine

sudo snap revert snapd

This is probably not something with this snap only. Also, try doing a restart, may be what else you can do is

sudo snap disconnect pdfarranger:home

And then try opening it

zyga commented 1 week ago

Could you please show us apparmor denials as listed by

dmesg | grep DENIED

Thanks!

atmelino commented 1 week ago

sudo dmesg | grep DENIED

ouput:

[ 5.115896] audit: type=1400 audit(1728610464.999:174): apparmor="DENIED" operation="open" class="file" profile="snap-update-ns.snapd-desktop-integration" name="/proc/1678/maps" pid=1678 comm="5" requested_mask="r" denied_mask="r" fsuid=120 ouid=0

[ 11.312900] audit: type=1400 audit(1728610471.196:175): apparmor="DENIED" operation="capable" class="cap" profile="/usr/lib/snapd/snap-confine" pid=2152 comm="snap-confine" capability=12 capname="net_admin"

[ 11.312919] audit: type=1400 audit(1728610471.196:176): apparmor="DENIED" operation="capable" class="cap" profile="/usr/lib/snapd/snap-confine" pid=2152 comm="snap-confine" capability=38 capname="perfmon"

[ 11.316431] audit: type=1400 audit(1728610471.199:177): apparmor="DENIED" operation="open" class="file" profile="snap-update-ns.snapd-desktop-integration" name="/proc/2219/maps" pid=2219 comm="5" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

[ 13.844001] audit: type=1400 audit(1728610473.727:178): apparmor="DENIED" operation="capable" class="cap" profile="/usr/lib/snapd/snap-confine" pid=3236 comm="snap-confine" capability=12 capname="net_admin"

[ 13.844628] audit: type=1400 audit(1728610473.727:179): apparmor="DENIED" operation="capable" class="cap" profile="/usr/lib/snapd/snap-confine" pid=3236 comm="snap-confine" capability=38 capname="perfmon"

[ 13.849825] audit: type=1400 audit(1728610473.733:180): apparmor="DENIED" operation="open" class="file" profile="snap-update-ns.snapd-desktop-integration" name="/proc/3251/maps" pid=3251 comm="5" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

[ 1562.871898] audit: type=1400 audit(1728612022.685:181): apparmor="DENIED" operation="capable" class="cap" profile="/usr/lib/snapd/snap-confine" pid=6922 comm="snap-confine" capability=12 capname="net_admin"

[ 1562.871908] audit: type=1400 audit(1728612022.685:182): apparmor="DENIED" operation="capable" class="cap" profile="/usr/lib/snapd/snap-confine" pid=6922 comm="snap-confine" capability=38 capname="perfmon"

[ 1562.945152] audit: type=1400 audit(1728612022.758:183): apparmor="DENIED" operation="open" class="file" profile="snap-update-ns.firmware-updater" name="/proc/6948/maps" pid=6948 comm="5" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

[ 1563.068871] audit: type=1400 audit(1728612022.882:184): apparmor="DENIED" operation="open" class="file" profile="snap.firmware-updater.firmware-notifier" name="/proc/sys/vm/max_map_count" pid=6922 comm="firmware-notifi" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

zyga commented 1 week ago

Thanks, is that all of them? From the ones I see here we can ignore all the snap-confine denials, those are known and caj eb ignored. I wonder what changed between versions though. Do you know if the app is using xdg portals for the folder access?

soumyaDghosh commented 1 week ago

Thanks, is that all of them? From the ones I see here we can ignore all the snap-confine denials, those are known and caj eb ignored. I wonder what changed between versions though. Do you know if the app is using xdg portals for the folder access?

Yes this app uses xdg desktop portals. I guess he has already reverted the snapd snap.

zyga commented 1 week ago

I don't know what may be the problem then :/.

Can I ask the reporter to re-check with snapd snap using latest/edge channel:

sudo snap refresh snapd --edge

You can check if this worked by running snap version.

Thank you!

soumyaDghosh commented 1 week ago

I don't know what may be the problem then :/.

Can I ask the reporter to re-check with snapd snap using latest/edge channel:

sudo snap refresh snapd --edge

You can check if this worked by running snap version.

Thank you!

The problem was probably particularly in 2.65.3 release which was later reverted. I also faced some similar problems