0

Using SSH from my Windows 10 Notebook I copied the folder SichTmp02122022_Profiles to the directory schr (both residing on the same Share of my NAS, a My Cloud EX2 Ultra) according to:

cp --no-dereference --preserve=all -r SichTmp02122022_Profiles schr/

SichTmp02122022_Profiles holds itself directories and a lot of files. When trying to change the name of SichTmp02122022_Profiles (copy) in the directory schr with Windows Explorer from the Notebook, I receive an error message saying that I needed credentials from MYCLOUDEX2ULTRA\admin (i.e. the NAS device) to be able to make changes. However, I can rename its subdirectory just like that and also the parent directory schr.

Here are the folder credentials from the Shell output:

root@MyCloudEX2Ultra Thunderbird_kS # ls -l
drwxrwxrwx    3 admin    share         4096 Jul  8 16:01 Orig02122022_Profiles
drwxr-xr-x    3 root     root          4096 Dec  2 21:33 schr
root@MyCloudEX2Ultra Thunderbird_kS # ls -l schr/
drwxrwxrwx    3 admin    share         4096 Dec  2 18:00 SichTmp02122022_Profiles

(schr was created via SSH, hence the different owner(s), root.)

As to Samba, using Windows Explorer from the Notebook I access as a member of the group nobody. Using SSH I am root (in contrast to admin which is not but rather an ordinary user account with access to particular configuration settings by use of the NAS web interface). SMB2 is apparently used, SMB3 should be possible both with NAS/Samba and Notebook either but seems not engaged according to Wireshark capture. Linux version of the NAS is 4.14.22.

I would dearly like to know the reason behind to get things clean and right as the copy is intended as a backup and I have to rely on the data all functioning in the future. I want to point out that I am not looking for a workaround, but want to fix the matter properly. I have already given a glance to Samba, but couldn´t find an obvious flaw (I am no pro by the way). I also tried to get a clue with regard to file permissions. I can´t think of a logical reason myself, try as I might. I would be grateful for any hints or ideas.

EDIT:

In order to dissolve possible doubts with respect to what I have experienced, I reproduced the procedure and will subsequently describe everything in descending time order as they happened. Only one thing will be in addition to the explanations already given above, which is I compare the original copy command to one with less optional arguments.

root@MyCloudEX2Ultra Thunderbird_kS # mkdir A_SSH
root@MyCloudEX2Ultra Thunderbird_kS # ls -l
drwxr-xr-x    3 root     root          4096 Dec  5 11:43 A_SSH
drwxrwxrwx    3 admin    share         4096 Jul  8 16:01 Orig02122022_Profiles

Different cp arguments:

root@MyCloudEX2Ultra Thunderbird_kS # cp -r Orig02122022_Profiles A_SSH/
root@MyCloudEX2Ultra Thunderbird_kS # ls -l A_SSH/
drwxr-xr-x    3 root     root          4096 Dec  5 11:43 Orig02122022_Profiles
root@MyCloudEX2Ultra Thunderbird_kS # ls -l A_SSH/Orig02122022_Profiles/
drwxr-xr-x   21 root     root          4096 Dec  5 11:46 f39s819w.sdfh
root@MyCloudEX2Ultra Thunderbird_kS # ls A_SSH/Orig02122022_Profiles/f39s819w.sdfh/
AlternateServices.txt
SecurityPreloadState.txt
abook.mab.bak
abook.sqlite
abook.v2.sqlite
blist.sqlite
blocklist-addons.json
blocklist-gfx.json
blocklist-plugins.json

Renaming A_SSH as C_SSH_Expl with Windows Explorer successful (WHY THIS?):

root@MyCloudEX2Ultra Thunderbird_kS # ls -l
drwxr-xr-x    3 root     root          4096 Dec  5 11:43 C_SSH_Expl
drwxrwxrwx    3 admin    share         4096 Jul  8 16:01 Orig02122022_Profiles

Error when trying to rename directory Orig02122022_Profiles with Windows Explorer.

Error when trying to rename subdirectory C_SSH_Expl/Orig02122022_Profiles/f39s819w.sdfh with Windows Explorer.

When using copy command cp --no-dereference --preserve=all -r instead, everything as described above, EXCEPTING that renaming of subdirectory C_SSH_Expl/Orig02122022_Profiles/f39s819w.sdfh as [...]/o39s819w.sdfh with Windows Explorer successful:

root@MyCloudEX2Ultra Thunderbird_kS # ls -l C_SSH_Expl/
drwxrwxrwx    3 admin    share         4096 Dec  5 12:24 Orig02122022_Profiles
root@MyCloudEX2Ultra Thunderbird_kS # ls -l C_SSH_Expl/Orig02122022_Profiles/
drwxrwxrwx   21 admin    share         4096 Dec  4 14:25 o39s819w.sdfh

The thing that, with me, does not fit is, why can I rename the root-owned directory as nobody?

3
  • Thank you for your answer, which I am quite happy with.
    – Complexor
    Dec 4, 2022 at 20:13
  • But why is it I got write permission for the subdirectories and especially the root-owned directory schr itself? Is that due to particular settings for copying and creating files (like umask for instance)?
    – Complexor
    Dec 4, 2022 at 20:43
  • If you need additional information on an answer, make sure to add comments on the answer. Otherwise, the answer author will not receive a notification. // The backup folder is owned by the regular user. Inside, you can do what you want. I doubt you could create new content in the schr directory while it is owned by root:root.
    – Daniel B
    Dec 4, 2022 at 21:39

1 Answer 1

0

(schr was created via SSH, hence the different owner(s), root.)

And this is the cause of your problem. Renaming a directory entry (file, dir, whatever) is modifying the directory it resides in. You are not permitted to do that.

Fix the ownership on schr and you’re good.

3
  • Thanks for the guideline, I didn´t notice I was not commenting to your answer as I was somewhat taken aback when I tried to upload my edited first comment and got informed that one can only make changes within the first 5 min. // In editing my post I have tried to overcome your doubts regarding changes to schr (which in the EDIT conforms with A_SSH resp. C_SSH_Expl. Maybe I got something wrong. Looking forward to your opinion once again, if you mind.
    – Complexor
    Dec 5, 2022 at 13:14
  • You can rename anything in a directory where you have write access. Ownership/permissions on the item being renamed do not come into play. The opposite is also true: You cannot rename anything in a directory where you do not have write access. Your new attempt confirms this. cp -r does not preserve ownership, but with --preserve=all it does, of course.
    – Daniel B
    Dec 6, 2022 at 12:45
  • Many thanks to you for your much appreciate answers! Thanks to your support I got it now. Due to your explanations I dived into directory permissions some in addition. It all makes sense now to me. I wish you a pleasant Christmas time.
    – Complexor
    Dec 6, 2022 at 19:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .