Introduction
Announcements

Schedule
Labs
Assignments
TA office hours

Tests, exam

Topic videos
Some course notes
Extra problems
Lecture recordings

Discussion board

Grades so far

uidconflict: Checking multiple systems for uid conflicts for NFS

NFS stands for "network file system". It is a facility, oft used in unix these days, which allows (for example) your home directory on the teach.cs machines to be the same on all of the various computers. Instead of a filesystem mount being a disk, you can have an NFS mount, which accesses files over the network from an NFS server.

Unfortunately, NFS has a number of issues, causing various degrees of trouble. The issue relevant to this assignment is that since the file permission and access information is all transmitted in terms of uids, strange things happen when the uids between two systems sharing files via NFS conflict.

It is not a problem if one system sees files owned by a uid which does not exist locally. In this case, ls -l will simply report the uid number rather than a name, and no local user will gain inappropriate permission on that file.

The problem occurs when a uid number is in use on both systems, but in conflicting ways. For example, if user "fred" has uid 1024 on system "hosta", but user "barney" has uid 1024 on system "hostb", then fred's files on a filesystem NFS-mounted on hostb seem to be barney's. Barney has full owner access to these files. This is bad.

Well-maintained systems which share filesystems via NFS such as the teach.cs system employ some mechanism to ensure that uids are compatible between nfs-sharing computers in this way. Other sites may be chaotic and need periodic checking to ensure that there are no conflicts.

In this assignment you will write a tool called uidconflict to perform this conflict check. We are concerned with the first and third fields of /etc/passwd, which contain the logname and uid respectively. Write a shell script, probably using awk, which takes two command-line arguments representing files in the format of /etc/passwd, and diagnoses conflicts between the two files. The first argument can be "-" to indicate standard input. (A common use of your script would be "rsh hostb cat /etc/passwd | uidconflict - /etc/passwd".)

Conflicts are:

Each of these should be diagnosed with an appropriate message which lists all data relevant to the conflict. One run of your script should produce all of the diagnostics. The diagnostics should appear on the standard output, one per line; for example, "uidconflict file1 file2 | wc -l" should correctly report the number of conflicts.

Conflicts do not include:

For easier processing with awk, you might want to use sed to add an extra field to each line of each file saying which of the two files it's from; then you can feed this whole thing as the input to your awk script and it can use $1 to identify which file the line is from.


[solution]
[back to sh problems]