Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unix C, writing to file as non-owner 1

Status
Not open for further replies.

lewisp

Programmer
Aug 5, 2001
1,238
0
0
GB
Is it possible in C on Unix to write to a file not owned by the program executor, and the file has r--r--r-- privileges?

The reason I ask is because this is what SCCS seems to do and I want to do the same thing. All SCCS files are created with r--r--r-- privileges, but anyone using the SCCS commands can write their changes to the files. I had assumed it was to do with setting the effective user ID within the process, but the executor must have privilege to do this as well.
 
It is something to do with the sticky bit but I can't remember what. It gives temporary privileges or allows you to run certain commands as a different usr

eg when you're changing your password: you are not privileged to write to /etc/passwd but it writes your new password to /etc/passwd.
 
Thanks for the replies guys. The sticky bit is probably the professional way to go but the rename/replace option works a treat for me! :)
 
Hello,

SCCS does indeed create it's own file. That is what the s.whatever file is. It contains not the complete file, but a history of all changes applied to for each version (delta) of the original file, and on a 'get' command, creates a new file containing all of the changes for the requested version.

Larry
 
Thats right, and the s.<name> file is owned by the original creator and has r--r--r-- privileges assigned. I needed to know how someone other than the creator could modify the s.<name> file when it has read-only privs, like SCCS does.

The answer for me is exactly as hoinz suggests. Once copied, the new file has its privileges changed to match and then the owner is also set to be the original creator.

Simple really :eek:).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top