[Freeipa-devel] [PATCH] #319 better cope with ntp config files
Rob Crittenden
rcritten at redhat.com
Fri Oct 15 14:05:50 UTC 2010
Simo Sorce wrote:
>
> Instead of replacing the files altogether parse them and add only the
> options we care about.
>
> For ntp.conf those are the server related options.
> For sysconfig/ntpd we care of adding just -x and -g if missing
>
> Simo.
>
nack, I don't think this will work.
A few comments on the python. You use some C-like syntax with match = 0,
should probably be match = False (as you use elsewhere, with file_changed).
You don't need the string module to use split, so instead of:
opt = string.split(line, " ")
You can do:
opt = line.split(" ")
But what you really want, I think is:
opt = line.split()
If you split on None it splits on white space, not a single space. The
different is:
>>> line = 'server 127.127.1.0 # local clock'
>>> line.split()
['server', '127.127.1.0', '#', 'local', 'clock']
>>> line.split(' ')
['server', '', '127.127.1.0', '', '', '', '', '#', 'local', 'clock']
Note the extra space after server in the last entry. This would cause
your conditional to fail (if opt[1] == srv).
I'm not sure your loop for srv actually does the right thing. I wonder
if you wanted to set match = 0 within the for loop.
rob
More information about the Freeipa-devel
mailing list