Assignment 3. Installing and modifying software

Laboratory: Installing a small change to a big package

Keep a log in the file lab3.txt of what you do in the lab so that you can reproduce the results later. This should not merely be a transcript of what you typed: it should be more like a true lab notebook, in which you briefly note down what you did and what happened.

You're helping to build an application containing a shell script that invokes the df command to check whether there is enough free disk space. Your application is running atop the Maroon Chapeau 7 distribution. You've been running into the problem that df occassionally fails with a diagnostic that looks like this:

df: `/var/named/chroot/proc': Permission denied

You've been asked to look into the problem and fix it.

You discover that the problem is that in some cases a user won't have any access to a mounted file system, and so df will report that the file system is inaccessible as shown above. The shell command df --version tells you which version of the GNU Core Utilities (coreutils) package that Maroon Chapeau 7 is using; this turns out to be coreutils version 5.92.

You nose around on the net, and discover that the bug has been fixed in more recent versions of coreutils so one option is to upgrade to a newer coreutils; but your boss suggests that you just patch the old version instead. So you look around some more, and find that someone with the pseudonym of n0dalus reported a similar bug on 2005-10-09 and posted a small, purported fix for it on 2005-10-12.

Try n0dalus's fix, as follows:

  1. Grab coreutils 5.92.
  2. Compile and install your copy of coreutils into a temporary directory of your own. Note any problems you run into.
  3. Use emacs or vi to apply n0dalus's patch.
  4. Type the command make at the top level of your source tree, so that you build (but do not install) the fixed version. For each command that gets executed, explain why it needed to be executed (or say that it wasn't neeeded).
  5. If possible, come up with a test case that illustrates the bug mentioned above, e.g., by temporarily changing the permissions on a mount point so that an ordinary user can't access it, and running df as an ordinary user. Make sure your change fixes the bug, by testing that the modified df works on your test case and that the installed df doesn't.
  6. If your company adopts the latest coreutils instead of using this patch, what else should you watch out for? Might this new version of coreutils introduce other problems with your application? How might you reduce the possiblity of confusion here?

Homework: Generating random lines from a file

Consider the Python script randline.py.

What happens when this script is invoked on an empty file like /dev/null, and why?

Currently randline.py outputs lines with replacement; for example, it's possible that it will output the first input line two or more times. Modify randline.py so that it accepts a new option -p which causes it to output lines without replacement. That is, when the user specifies the option -p, the modified program will never output any input line more than once. If the user does not specify -p the program should behave as before (except its usage message should mention -p). With -p it is an error if the input file contains fewer than the number of lines requested, just as it is already an error without -p to invoke randline.py on an empty file and ask it for one or more lines of output. You need not worry about the exact diagnostic you generate for this new error, so long as you generate some diagnostic.

Your modified version of randline.py should use only the modules that randline.py uses (it should not import any other modules), and it should not use the sample function, since we want your solution to be portable to older Python implementations.

Submit

Submit the following files.

All files should be ASCII text files, with no carriage returns, and with no more than 80 columns per line. The shell command:

expand lab3.txt hw3.txt randline.py | awk '/\r/ || 80 < length'

should output nothing.


© 2005, 2007, 2008 Paul Eggert. See copying rules.
$Id: assign3.html,v 1.8 2008/04/14 22:15:12 eggert Exp $