4

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

  • It seems that the files on c1 are being created as nobody; what's the result of running sudo whoami on c1? – Anthony G - justice for Monica Sep 15 '15 at 10:35
  • 1
    @AnthonyGeoghegan On both c1 and c2, "sudo whoami" returns root. thanks – S.W. Sep 15 '15 at 11:55
5

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.