Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

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.)

share|improve this answer
    
Sweet, thank you. I had no idea where to look. –  anthony-arnold Aug 21 '11 at 12:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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