Assignment 1

Due Date: Monday Sept. 28

I. It is often useful for members of a team to be able to exchange files, particularly large binaries, without having to use mail. Of course, someone can make files available by making them world readable and placing them in an accessible directory, but it is sometimes convenient to be able to give someone a file rather than simply tell them were it is and have them get it. In a trusted environment, team memebers can create world writeable directories for file drops.

A. What are risks in doing this in an environment with users who may not be trustworthy?

B. Implement a program that will allow people to give files to a user without that user creating a world writeable directory. If I want to give the file "myfile" to jrandomuser, I would type:

~jrandomuser/copyto myfile

The program should satisfy the following requirement.

i. The file should be placed in a directoy called "incoming" under the destination user's home directory (i.e., ~jrandomuser/incoming in the above example). This directly may be assumed to already exist and to be user writeable and searchable, need not be group or world writeable or searchable.

ii. The source file ("myfile" above) should be readable by the user running 'copyto' but need not be readable by the destination user.

iii. The program should write an entry to a file "incoming.log" in the "incoming" directory logging the copy. This should be a single line with the login name of the user attempting the copy, the time at which the copy was attempted, the file they attempted to copy, and whether or not the copy was successful.

iv. The program should guard against actions taken by a malicious user. No, I'm not going to tell you what those actions might be. Part of the grade for this assignment is anticipating the things a malicious user might try. As part of the assignment, document what you've done to protect the system from malicious users.

II. The second program will have to be done using X, but does not involve X programming. Write a simple shell that reads commands and executes them. You don't have to handle I/O redirection or piping, but should handle putting tasks in the background. This will be done as follows. If the line ends with an ampersand, rather than your shell directly executing the command, your shell should run an xterm that invokes the command as a subprocess. That is, a new window will be created to run the "background" command. In this case, your shell should not wait for the xterm to complete before prompting for the next command, however you should avoid creating zombies that stay around for a long time.

Note: There is code in Practical Unix Programming for breaking a command line into an array of pointer to char.

III. Add I/O redirection and piping to the shell.