2

I have a homework question about kernel programming in Linux. The question is:

What Linux-specific privilege is required to preserve ownership of a file when it's copied, and how do you get it?

Through experimentation, I've found that I need to be root or a superuser to get this to work. Is there a more specific way to explain this effect?

1 Answer 1

3

See the capabilities(7) manual page – you need the CAP_CHOWN capability to change file ownership via chown(). (Root has all capabilities enabled automatically. The manual page explains how to obtain capabilities in other cases.)

There is no separate method/capability to just preserve ownership, as Linux file copies are made by simply reading/writing data to the destination file, then doing the same with metadata. (For comparison, Windows NT has SeBackupPrivilege and SeRestorePrivilege privileges and the BackupRead()/BackupWrite() calls.)

1
  • Sweet, thank you. I had no idea where to look.
    – Anthony
    Aug 21, 2011 at 12:09

You must log in to answer this question.

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