Bug 498443 - File copy is preserving SElinux label
Summary: File copy is preserving SElinux label
Status: CONFIRMED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 6.9.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-09 21:16 UTC by Diego
Modified: 2025-10-02 01:11 UTC (History)
5 users (show)

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


Attachments
Screenshot of terminal's results (36.04 KB, image/png)
2025-01-09 21:16 UTC, Diego
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Diego 2025-01-09 21:16:21 UTC
Created attachment 177240 [details]
Screenshot of terminal's results

SUMMARY

Copying a file from my home folder into another drive with a different SElinux label preserves the label of the original file, and not of the destination folder, which is not the same behavior as the terminal cp command.


STEPS TO REPRODUCE
1. Copy a file from the home folder (example, /home/user/Downloads)
2. Paste it into another drive with a distinct SElinux label
3. ls -lZ and compare the labels.

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: Fedora 41
KDE Plasma Version: 6.2.5
KDE Frameworks Version: 6.9.0
Qt Version: 6.8.1
Kernel Version: 6.12.8-200.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5700X3D 8-Core Processor
Memory: 31.2 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 3070/PCIe/SSE2


ADDITIONAL INFORMATION
Comment 1 haveman_cgc 2025-09-20 16:56:43 UTC
Just run into this issue.
Still reproducable on Fedora 42 - dolphin 25.08.0

This makes samba sharing a major pain for normal users who need to run restorecon after copying files to a shared folder. 

The Gnome Filemanager and terminal cp work as expected on the tested folder.
Comment 2 madness742 2025-10-02 01:11:21 UTC
I can reproduce this.

As a workaround, I've created a Dolphin service menu. My use case is very simple: copy or move files to a specific folder that has the `svirt_image_t` label. This folder is used to share files with my Virtual Machines.

1. `mkdir -p ~/.local/share/kio/servicemenus`
2. `touch ~/.local/share/kio/servicemenus/copy-mv-vm.desktop`
3. `sudo chmod +x ~/.local/share/kio/servicemenus/copy-mv-vm.desktop`
4. `nano ~/.local/share/kio/servicemenus/copy-mv-vm.desktop` (make sure to replace user with your username)
[Desktop Entry]
Type=Service
MimeType=all/all;
Actions=CopyToVM;MoveToVM
X-KDE-Submenu=Copy/Move to VM

[Desktop Action CopyToVM]
Name=Copy to VM
Icon=edit-copy
Exec=cp -r %F /home/user/VM; notify-send --app-name Dolphin "Copied files to shared folder."

[Desktop Action MoveToVM]
Name=Move to VM
Icon=edit-move
Exec=cp -r %F /home/user/VM && rm -r %F; notify-send --app-name Dolphin "Moved files to shared folder."

Restart Dolphin and there should be a new context menu entry when selecting files/folders.

Operating System: Fedora Linux 42
KDE Plasma Version: 6.4.5
KDE Frameworks Version: 6.18.0
Qt Version: 6.9.2
Kernel Version: 6.16.8-200.fc42.x86_64 (64-bit)