-
Committer:
Scott Moser
-
Date:
2011-09-23 18:29:09 UTC
-
Revision ID:
smoser@ubuntu.com-20110923182909-at6og2yvoege04p2
debian/dhclient-script.linux: fix for read-only /etc (LP: #857524)
fix updating of /etc/resolv.conf for read-only
This makes the following changes:
* instead of writing to a temp file in /etc/, write directly to
/etc/resolv.conf
* replace the multiple '>>' with a single '>' and braces. This means
the file will be opened for write once rather than append many times.
* opening for write (truncate) keeps the ownership of the file if it exists,
and correctly follows a symlink.
This makes the chmod and chown --reference un-necessary
* use 'grep -i' rather than 'sed' to get the old nameserver entries from
existing resolv.conf. This is how the linux.udeb does it, and I find it more
clean.
* changes 'wait_for_rw' to take a file argument rather than hard coding /etc
and then actually tests that that file is writable by opening it for append
Note, there is an issue with this patch if /etc/resolv.conf is a symlink and
is the symlink (*not the target*) is not owned by root. To demonstrate:
$ rm -f /tmp/foo /tmp/bar
$ ln -s /tmp/foo /tmp/bar
$ sudo sh -c 'echo hi > /tmp/foo'
$ sudo sh -c 'echo himom > /tmp/bar'
sh: /tmp/bar: Permission denied
The only solution I see for this is to attempt to resolve the target of the
symlink (readlink -f) and writing directly there instead of through the
symlink.