Bug 478839

Summary: Strange trash-related warnings in the system journal
Product: [Frameworks and Libraries] frameworks-kio Reporter: Jin Liu <ad.liu.jin>
Component: TrashAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kdelibs-bugs, nate, tagwerk19
Priority: NOR Keywords: qt6
Version: 5.247.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=479399
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Jin Liu 2023-12-21 14:10:38 UTC
SUMMARY
System journal has the following warnings:

kioworker: kf.kio.workers.trash: Root trash dir "/\u0000/.Trash" exists but didn't pass the security checks, can't use it
kioworker: kf.kio.workers.trash: Directory "/\u0000/.Trash-1000" exists but didn't pass the security checks, can't use it

I checked that the dir "/\u0000/.Trash" doesn't exist. So probably KIO actually tries to use the NUL(\u0000)-terminated path "/" as the trash dir.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.91.0
KDE Frameworks Version: 5.247.0
Qt Version: 6.7.0
Kernel Version: 6.6.7-arch1-1 (64-bit)
Graphics Platform: offscreen
Processors: 12 × AMD Ryzen 5 5600H with Radeon Graphics
Memory: 13.5 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Comment 1 Bug Janitor Service 2024-01-04 13:16:22 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/solid/-/merge_requests/154
Comment 2 Jin Liu 2024-01-04 13:25:21 UTC
I've located the source of this bug, but I can't decide how to fix it.

There are two problems:
1. Solid::StorageAccess::filePath() returns `/\u0000` for encrypted root partition. Should be fixed in https://invent.kde.org/frameworks/solid/-/merge_requests/154

2. In KIO:
https://invent.kde.org/frameworks/kio/-/blob/287aa2ab7c3277b5d5033952569c38bb308a6154/src/kioworkers/trash/trashimpl.cpp#L1053
The query to Solid returns both the encryped root partition and the devicemapper. And after the fix above, their filepath() should both resolve to `/`. This doesn't really cause problems here, but is it intentional?

a) Should the `Solid::Device::listFromQuery(QStringLiteral("StorageAccess.accessible == true"))` query, by design, return both devices?
b) If a) is true, then should KIO somehow explicitly filter out the encrypted partition?
Comment 3 Jin Liu 2024-01-09 17:30:32 UTC
Git commit 762c62524c3e91ce21b6dfe7c349eca577269009 by Jin Liu, on behalf of Jin Liu.
Committed on 08/01/2024 at 08:35.
Pushed by genericity into branch 'master'.

Fix: StorageAccess::filePath() returns /\u0000 for encrypted root

M  +5    -1    src/solid/devices/backends/udisks2/udisksstorageaccess.cpp

https://invent.kde.org/frameworks/solid/-/commit/762c62524c3e91ce21b6dfe7c349eca577269009