[Solved] cp -p not a bug in Porteus 5.0rc2 and 4.0-i568

Please reproduce your error on a second machine before posting, and check the error by running without saved changes or extra modules (See FAQ No. 13, "How to report a bug"). For unstable Porteus versions (alpha, beta, rc) please use the relevant thread in our "Development" section.
User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

[Solved] cp -p not a bug in Porteus 5.0rc2 and 4.0-i568

Post#1 by Rava » 27 Dec 2020, 13:55

Probably a cp bug not a Porteus one.

Tested on a recent x86-64 and older i586 Porteus:

System Porteus 5.0rc2
cp V 8.32


My cp is aliased to

Code: Select all

guest@porteus:~$ alias cp
alias cp='/bin/cp -pi'
cp --help|grep -- -p tells us -p means

Code: Select all

same as --preserve=mode,ownership,timestamps
Now I copied this script file owned by root
-rwxr-xr-x 1 root root 363 Dec 27 12:27 /usr/bin/ffplay-hide_banner
to a folder on an ext3 partition guest can write to:

Code: Select all

guest@porteus:~$ cp /usr/bin/ffplay-hide_banner /mnt/ext3/porteus/debug/5.0xxx/
guest@porteus:~$ ls -l /usr/bin/ffplay-hide_banner /mnt/ext3/porteus/debug/5.0xxx/ffplay-hide_banner 
-rwxr-xr-x 1 guest users 363 Dec 27 12:27 /mnt/ext3/porteus/debug/5.0xxx/ffplay-hide_banner
-rwxr-xr-x 1 root  root  363 Dec 27 12:27 /usr/bin/ffplay-hide_banner
Same is true for Porteus 4.0 i568
cp V 8.29

Code: Select all

guest@porteus:/mnt/sda3/tmp$ ls -ld .
drwxr-xr-t 5 guest users 4096 Dec 25 21:53 .
guest@porteus:/mnt/sda3/tmp$ alias cp
alias cp='cp -pi'
guest@porteus:/mnt/sda3/tmp$ ls -l /usr/local/bin/aliasset 
-rw-r--r-- 1 root root 7256 Jan 30  2018 /usr/local/bin/aliasset
guest@porteus:/mnt/sda3/tmp$ cp /usr/local/bin/aliasset .
guest@porteus:/mnt/sda3/tmp$ ls -l aliasset
-rw-r--r-- 1 guest users 7256 Jan 30  2018 aliasset
guest@porteus:/mnt/sda3/tmp$ cp --version
cp (GNU coreutils) 8.29
[…]
Unlike what -p should have told cp, ownership and group was changed from root,root to guest,users.
According to cp --help at least the ownership should have been preserved.

Why is cp acting against what its explicitly told?
Last edited by Rava on 28 Dec 2020, 20:29, edited 1 time in total.
Reason: changed title
Cheers!
Yours Rava

User avatar
babam
Warlord
Warlord
Posts: 526
Joined: 16 Nov 2016, 10:30
Distribution: Porteus 5.0rc3 Xfce K6.1.1
Location: Rainy city

cp -p bug in Porteus 5.0rc2 and 4.0-i568

Post#2 by babam » 27 Dec 2020, 16:18

Copy as root

Code: Select all

$ sudo cp -p /usr/bin/ffplay-hide_banner /mnt/ext3/porteus/debug/5.0xxx/
Sorry, my English is bad.

donald
Full of knowledge
Full of knowledge
Posts: 2064
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

cp -p bug in Porteus 5.0rc2 and 4.0-i568

Post#3 by donald » 27 Dec 2020, 19:37

@Rava
You cannot preserve ownerships while copying unless you are root.

non-root users are able to preserve ownership of their files that they own
and are owned by a group that the specific non-root user belongs to.
they cannot preserve ownership of files owned by other users,

root can preserve the ownership of files owned by different users,
because root has full system privileges.

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

cp -p bug in Porteus 5.0rc2 and 4.0-i568

Post#4 by Rava » 28 Dec 2020, 00:48

^
makes sense. I would have liked a warning that as a non-root user ownership of files owned by other users cannot be preserved… and if I want to continue nonetheless.
Cheers!
Yours Rava

Post Reply