sudo mkdir creates directory as nobody nogroup on mounted directory, then chown not permitted
This is a security feature of nfs. You need to export it with flag no_root_squash
so that a remote root will stay root on the filesystem.
Related videos on Youtube
S.W.
Updated on September 18, 2022Comments
-
S.W. over 1 year
Could someone please help with the following?
If I create and "ll" a directory on a mounted disc, I get the following
xyz@c1:/home/Data6:sudo mkdir test xyz@c1:/home/Data6:ll drwxr-xr-x 2 nobody nogroup 4096 Sep 15 2015 test/
Then the following command returns an error
xyz@c1:/home/Data6:sudo chown username test chown: changing ownership of ‘test’: Operation not permitted
"sudo chmod" etc works, but not the "chown" (which I need for "rsync -a").
Why does sudo lose control over the ownership?
relevant background info:
Ubuntu 14.04.3 LTS, disc mounted during boot as follows
xyz@c2:less /etc/fstab /dev/sdc1 /Data6 ext4 defaults,acl 0 2 xyz@c2:less /etc/exports /Data6 *c1*/255.255.255.0(rw,sync,no_subtree_check,acl) xyz@c1:less /etc/fstab *c2*:/Data6 /home/Data6 nfs rw,hard,intr 0 0
The same happens if a file is copied via "sudo cp".
"lsattr" only shows the "e" attribute, no "i".
If login directly on c2 (physical location of Data6) sudo can do everything (i.e. also "chown" of the directory created via "sudo" when on c1). It seems to be about running "sudo" as a logged-in user who has "sudo" privileges on c1 but then loses some of them if working on the disc mounted from c2. User has same name, id and group when running "sudo" on c1 or c2
Is it maybe related to the "acl" option?
Any help very much appreciated. Thanks
-
Lupen over 8 yearsIt seems that the files on c1 are being created as nobody; what's the result of running
sudo whoami
on c1? -
S.W. over 8 years@AnthonyGeoghegan On both c1 and c2, "sudo whoami" returns root. thanks
-