I don't know if doing something in a %pre script is appropriate for your situation, but even if it is, "chmod a-w /etc/resolv.conf" might not prevent NetworkManager from changing the file. I believe NetworkManager runs as root, and if as root you try such a chmod command on a file, you'll find that root has no problem changing the file. But root doing "chattr +i /etc/resolv.conf" should protect resolv.conf. After that chattr command even root can't change resolv.conf without first doing "chattr -i /etc/resolv.conf".

Steven Yellin

On Thu, 7 Apr 2011, Ahmed El Zein wrote:

Nico,
Thanks for that. I don't have NetworkManger installed in by base system.
My problem is how do I stop NetworkManger running during the anaconda
install process while kickstarting? From what I can gather everything
works fine until it starts. one it starts it ruins the /etc/resolv.conf
file and all my %post scripts fail.

can I do something in a %pre script that will prevent NetworkManger from
editing anything. maybe a "chmod a-w /etc/resolv.conf"?

Thanks,
Ahmed




On Thu, 2011-04-07 at 00:07 -0400, Nico Kadel-Garcia wrote:
On Wed, Apr 6, 2011 at 2:50 AM, Ahmed El Zein <[email protected]> wrote:

I am looking at the logs and the only network related log that coincides
with the resolv.conf file changing is:
<29> Arp 6 06:40:49 NetworkManager[542]:    ifcfg-rh:
updating /etc/sysconfig/network-scripts/ifcfg-eth0

at that point /etc/sysconfig/network-scripts/ifcfg-eth0 changes and gets
an NM_CONTROLLED="yes" added to it and the /etc/resolv.conf file is
replaced with the single lined one.

NetworkManager, frankly, has no use on a typical server. Its dynamic
manipulations of network configuration are unpredictable, unintuitive,
and far more suited to a laptop or traveling desktop in an environment
where upstream DHCP is reliably configured. It is a complex and
powerful tool that *STILL* has no way to configure pair-bonding,
'bridged' connections for KVM supporting hosts, or DHCP client
configuration with client identifiers except to use a text editor and
turn off NetworkManager by one means or another. It's one of the
upstream vendors least useful development efforts.

Unfortunately, we're now pretty much stuck with it, due to all the
recent system dependencies on it. Ripping it out by the roots became
infeasible with Scientific :Linux 6. Fortunately, pre-configuring
'NM_CONTROLLED=no' is a new capability, and doing so early in the
kickstart '%post' scripts seems to be very helpful in preventing such
issues. In syntax:

      grep -q ^NM_CONTROLLED= [filename] || \
           echo 'NM_CONTROLLED=no' >> [filename]
      sed -i 's/NM_CONTROLLED=.*/NM_CONTROLLED=no/g' [filename]

Deducing the files to do this to is a bit more awkward, since you
don't want to touch '.bak' files or '~' files, but there are functions
to do that already available in the /etc/sysconfig/network-scripts/
utiliti4es. Do you need help with that?

--
Ahmed H. El Zein
Data Services Specialist
ANU Supercomputer Facility
Room 315, Leonard Huxley Building (#56), Mills Road
The Australian National University
Canberra ACT 0200 Australia

T: +61 2 6125 0539
F: +61 2 6125 8199
M: +61 4 4913 5073
W: http://anusf.anu.edu.au/

CRICOS Provider #00120C
--------------------------------------------

Reply via email to