[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dhclient-script
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: Re: dhclient-script
- From: Chuck Yerkes <chuck+obsd_(_at_)_2004_(_dot_)_snew_(_dot_)_com>
- Date: Sun, 9 May 2004 00:45:06 -0400
I'd suggest that if you're going to need a temporary
place for things that root owns, then I might be inclined
to use /var/run/ rather than /tmp. Or use a mktemp
derived name and /tmp/.
The issue is that the machine could be multiuser when
this script runs. And there's a race condition.
mktemp and save the name and use THAT variable through
the script.
Quoting Okan Demirmen (okan_(_at_)_demirmen_(_dot_)_com):
> re-addressing read-only /'s, one thing always bothered me about
> dhclient-script(8) - it uses /etc to do it's work. here is a
> suggestion to allow for read-only /'s with /etc/resolv.conf staying
> as a symlink. (mktemp could also be used for .std) - or i'll just
> keep it a local patch or someone tell me why it's a bad idea.
>
> Index: dhclient-script
> ===================================================================
1 > RCS file: /cvs/src/sbin/dhclient/dhclient-script,v
2 > retrieving revision 1.6
3 > diff -u -r1.6 dhclient-script
4 > --- dhclient-script 6 May 2004 18:22:41 -0000 1.6
5 > +++ dhclient-script 8 May 2004 21:07:05 -0000
6 > @@ -100,21 +100,21 @@
7 > # thus broke the script. This code creates the resolv.conf if either
8 > # are provided.
9 >
10 > - rm -f /etc/resolv.conf.std
11 > + rm -f /tmp/resolv.tmp.std
12 >
13 > if [ -n "$new_domain_name" ]; then
14 > - echo "search $new_domain_name" >>/etc/resolv.conf.std
15 > + echo "search $new_domain_name" >>/tmp/resolv.conf.std
16 > fi
17 >
18 > if [ -n "$new_domain_name_servers" ]; then
19 > for nameserver in $new_domain_name_servers; do
20 > - echo "nameserver $nameserver" >>/etc/resolv.conf.std
21 > + echo "nameserver $nameserver" >>/tmp/resolv.conf.std
22 > done
23 > fi
24 >
25 > - if [ -f /etc/resolv.conf.std ]; then
26 > + if [ -f /tmp/resolv.conf.std ]; then
27 > if [ -f /etc/resolv.conf.tail ]; then
28 > - cat /etc/resolv.conf.tail >>/etc/resolv.conf.std
29 > + cat /etc/resolv.conf.tail >>/tmp/resolv.conf.std
30 > fi
31 >
32 > # In case (e.g. during OpenBSD installs) /etc/resolv.conf
33 > @@ -122,10 +122,10 @@
34 > # the new data in the correct location.
35 >
36 > if [ -f /etc/resolv.conf ]; then
37 > - cat /etc/resolv.conf > /etc/resolv.conf.save
38 > + cat /etc/resolv.conf > /var/db/resolv.conf.save
39 > fi
40 > - cat /etc/resolv.conf.std > /etc/resolv.conf
41 > - rm -f /etc/resolv.conf.std
42 > + cat /tmp/resolv.conf.std > /etc/resolv.conf
43 > + rm -f /tmp/resolv.conf.std
44 >
45 > # Try to ensure correct ownership and permissions.
46 > chown -RL root:wheel /etc/resolv.conf
47 > @@ -195,8 +195,8 @@
48 > fi
49 > # XXX Why add alias we just deleted above?
50 > add_new_alias
51 > - if [ -f /etc/resolv.conf.save ]; then
52 > - cat /etc/resolv.conf.save > /etc/resolv.conf
53 > + if [ -f /var/db/resolv.conf.save ]; then
54 > + cat /var/db/resolv.conf.save > /etc/resolv.conf
55 > fi
56 > ;;
Visit your host, monkey.org