>>I have been making a program that acts like a simple filemanager, moving certain files
>>around and stuff like that. One of the operations of the program is to store a file in
>>a write-protected directory, and not allowing the normal user to access the file without
>>using the program.
>>Is it possible to solve this problem using some protection-bits, or do I have to code it
>>into my program? In case of coding, how should I solve the problem?
>>Thanks in advance
>You could store the files under a different ownership. None of those files
>permission masks would allow world and group access. Only through the program
>would access be possible. Of course this idea depends on whether your pro-
>gram has super-user priviledges. If the program were invoked from your login
>it'd need to setuid() the owner of the files in order to manipulate them.
>Jeff
When I came accross that problem thats effectively what I did. The program
run by the user calls a setuid program with argv[0] set to a certain special
string so as to prevent a user running the setuid program directly.
The setuid program could only move, copy or delete certain files so security
in the unlikely event that a user had found the magic argv[0] and called it
was not too much a problem. One thing to watch out for security wise is what
programs your setuid prog calls. If you issue a command like "mv file1 file2"
then all a user need do is put their own version of mv in their path.
I'm sure that there are C libraries to do this. At the time I just made sure
I called /bin/mv .
Another method reccomended to me at the time would have been to use UNIX (not
INET) sockets and run the copying/moving program completely indipendantly.
- Richard
please excuse spelling. With the current load on this computer I'm not going
to run ispell!
--
_/_/_/ _/_/_/ _/_/_/ Richard Corfield. St John's, Cambridge
_/_/_/ _/ _/ World Wide Web: http://club.eng.cam.ac.uk/~93rjc
_/ _/ _/_/ _/_/_/ Disclaimer: My opinions are MINE! ALL MINE!