The goal of this exercise is to determine whether the system enforces the Principle of Complete Mediation. It will also get you used to writing a program on this system, if you have not used it before. To start, create a readable text file, called testfile. Write a short program that does the following: Open testfile for reading; Use either chown(2) or (preferably) fchown(2) to turn off read permissions for testfile; and Use read(2) and write(2) to copy the contents of the file to the standard output (file descriptor 1). Then run the program. Do you see the contents of the file? If so, after you run your program, try to display the contents of the file using cat(1), less(1), or some similar program. What happens? Turn in your program and your answers to the questions in the preceding paragrph.
The goal of this exercise is to determine whether the system enforces the Principle of Complete Mediation. It will also get you used to writing a
To start, create a readable text file, called testfile. Write a short program that does the following:
- Open testfile for reading;
- Use either chown(2) or (preferably) fchown(2) to turn off read permissions for testfile; and
- Use read(2) and write(2) to copy the contents of the file to the standard output (file descriptor 1).
Then run the program. Do you see the contents of the file? If so, after you run your program, try to display the contents of the file using cat(1), less(1), or some similar program. What happens?
Turn in your program and your answers to the questions in the preceding paragrph.
\note If you run your program a second time, be sure testfile is still readable; otherwise, your program will fail.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps