Summary: | File copying ignores setgid bit for files (but not directories) | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-kio | Reporter: | Geert Janssens <info> |
Component: | general | Assignee: | KIO Bugs <kio-bugs-null> |
Status: | CONFIRMED --- | ||
Severity: | normal | CC: | a.samirh78, elvis.angelaccio, kde, kdelibs-bugs, nate, vse.stopchanskyi |
Priority: | NOR | ||
Version: | 6.12.0 | ||
Target Milestone: | --- | ||
Platform: | Fedora RPMs | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Geert Janssens
2018-10-01 09:55:41 UTC
It's faster to just show the shell output: [~/test-setgid]>$ mkdir ~/test-setgid [~/test-setgid]>$ cd ~/test-setgid/ [~/test-setgid]>$ sudo chown ahmad:users ./ [~/test-setgid]>$ sudo chmod g+s ./ [~/test-setgid]>$ ls -ld drwxr-sr-x 2 ahmad users 4096 Sep 24 00:14 . Creating a new file and dir from the cli: [~/test-setgid]>$ touch file [~/test-setgid]>$ mkdir dir [~/test-setgid]>$ ls -l total 4 drwxr-sr-x 2 ahmad users 4096 Sep 24 00:15 dir -rw-r--r-- 1 ahmad users 0 Sep 24 00:15 file [~/test-setgid]>$ ls -l ~/copied-file -rw-r--r-- 1 ahmad ahmad 10 Sep 24 00:16 /home/ahmad/copied-file [~/test-setgid]>$ cp ~/copied-file . [~/test-setgid]>$ ls -l total 8 drwxr-sr-x 2 ahmad users 4096 Sep 24 00:15 dir -rw-r--r-- 1 ahmad users 10 Sep 24 00:16 copied-file -rw-r--r-- 1 ahmad users 0 Sep 24 00:15 file [~/test-setgid]>$ ls -ld ~/copied-dir drwxr-xr-x 2 ahmad ahmad 4096 Sep 24 00:16 /home/ahmad/copied-dir [~/test-setgid]>$ cp -r ~/copied-dir . [~/test-setgid]>$ ls -l total 12 drwxr-sr-x 2 ahmad users 4096 Sep 24 00:16 copied-dir drwxr-sr-x 2 ahmad users 4096 Sep 24 00:15 dir -rw-r--r-- 1 ahmad users 10 Sep 24 00:16 copied-file -rw-r--r-- 1 ahmad users 0 Sep 24 00:15 file Now with dolphin: [~/test-setgid]>$ ls -ld ~/copied-file-with-dolphin ~/copied-dir-from-dolphin/ drwxr-xr-x 2 ahmad ahmad 4096 Sep 24 00:27 /home/ahmad/copied-dir-from-dolphin/ -rw-r--r-- 1 ahmad ahmad 6 Sep 24 00:26 /home/ahmad/copied-file-with-dolphin Copied the the two above items using dolphin, and the result: [~/test-setgid]>$ ls -l copied-file-with-dolphin -rw-r--r-- 1 ahmad ahmad 6 Sep 24 00:26 copied-file-with-dolphin [~/test-setgid]>$ ls -ld copied-dir-from-dolphin/ drwxr-sr-x 2 ahmad users 4096 Sep 24 00:27 copied-dir-from-dolphin/ So it looks like it's the same behaviour as using cp from the cli. Can you still reproduce this issue? (In reply to Ahmad Samir from comment #1) > Copied the the two above items using dolphin, and the result: > [~/test-setgid]>$ ls -l copied-file-with-dolphin > -rw-r--r-- 1 ahmad ahmad 6 Sep 24 00:26 copied-file-with-dolphin > [~/test-setgid]>$ ls -ld copied-dir-from-dolphin/ > drwxr-sr-x 2 ahmad users 4096 Sep 24 00:27 copied-dir-from-dolphin/ > > So it looks like it's the same behaviour as using cp from the cli. > > Can you still reproduce this issue? The file "copied-file-with-dolphin" in your output above shows exactly the issue I'm pointing out: its primary group is still ahmad instead of users. So it seems you are equally able to reproduce this issue... And I have just tested, it still happens for me as well. Interestingly it seems to go wrong for files only. The group id is set correctly on directories. I'll add that since I reported this I have upgraded to frameworks-kio-5.59.0 (which is current on Fedora 30). It's the same with copied-file which was copied with cp. So it isn't specific to KIO/dolphin. From the chomd man page: <quote> SETUID AND SETGID BITS chmod clears the set-group-ID bit of a regular file if the file's group ID does not match the user's effective group ID or one of the user's supplementary group IDs, unless the user has appropriate privileges. Additional restrictions may cause the set-user-ID and set-group-ID bits of MODE or RFILE to be ignored. This behavior depends on the policy and functionality of the underlying chmod system call. When in doubt, check the underlying system behavior. </quote> I don't fully understand that, but it may explain the issue. I don't agree it's the same. Your file generated using cp is this: -rw-r--r-- 1 ahmad users 10 Sep 24 00:16 copied-file Your file generated using copy in dolphin is this: -rw-r--r-- 1 ahmad ahmad 6 Sep 24 00:26 copied-file-with-dolphin Note the difference in group id! copied-file is owned by group "users", where copied-file-with-dolphin is owned by group "ahmad". Considering the group setuid bit was set on the containing directory, the command line copy's behaviour is the proper one. Dolphin's copy ignores this group setuid bit. However as we have both established, it only does so for files, not for directories. Hmm, I'll test again, it seems I either missed it when I tested, or I copy pasted wrongly when posting here... You're correct, I must have gone blind when I tested the first time around... Hey. Sorry for necro bumping (kinda), but this is still a thing. Copied through Dolphin files don't respect setgid, but folders do. Could this please be fixed? Operating System: Arch Linux KDE Plasma Version: 6.3.3 KDE Frameworks Version: 6.12.0 Qt Version: 6.8.2 Kernel Version: 6.14.0-zen1-1-zen (64-bit) Graphics Platform: Wayland Processors: 12 × AMD Ryzen 5 5600H with Radeon Graphics Memory: 13.5 GiB of RAM Graphics Processor 1: AMD Radeon Graphics Graphics Processor 2: NVIDIA GeForce RTX 3060 Laptop GPU |