ipaplatform: Add NTPD_OPTS_VAR and NTPD_OPTS_QUOTE to constants

https://fedorahosted.org/freeipa/ticket/5343

Reviewed-By: Tomas Babej <tbabej@redhat.com>
This commit is contained in:
Timo Aaltonen 2015-10-06 18:46:00 +03:00 committed by Tomas Babej
parent 24ebdf90a5
commit 43654c973c
2 changed files with 13 additions and 5 deletions

View File

@ -11,5 +11,9 @@ class BaseConstantsNamespace(object):
HTTPD_USER = "apache"
IPA_DNS_PACKAGE_NAME = "freeipa-server-dns"
NAMED_USER = "named"
# ntpd init variable used for daemon options
NTPD_OPTS_VAR = "OPTIONS"
# quote used for daemon options
NTPD_OPTS_QUOTE = "\""
# nfsd init variable used to enable kerberized NFS
SECURE_NFS_VAR = "SECURE_NFS"

View File

@ -21,9 +21,13 @@
from ipaserver.install import service
from ipapython import sysrestore
from ipapython import ipautil
from ipaplatform.constants import constants
from ipaplatform.paths import paths
from ipapython.ipa_log_manager import *
NTPD_OPTS_VAR = constants.NTPD_OPTS_VAR
NTPD_OPTS_QUOTE = constants.NTPD_OPTS_QUOTE
class NTPInstance(service.Service):
def __init__(self, fstore=None):
service.Service.__init__(self, "ntpd", service_desc="NTP daemon")
@ -106,9 +110,9 @@ class NTPInstance(service.Service):
fd.close()
for line in lines:
sline = line.strip()
if not sline.startswith('OPTIONS'):
if not sline.startswith(NTPD_OPTS_VAR):
continue
sline = sline.replace('"', '')
sline = sline.replace(NTPD_OPTS_QUOTE, '')
for opt in needopts:
if sline.find(opt['val']) != -1:
opt['need'] = False
@ -124,12 +128,12 @@ class NTPInstance(service.Service):
for line in lines:
if not done:
sline = line.strip()
if not sline.startswith('OPTIONS'):
if not sline.startswith(NTPD_OPTS_VAR):
fd.write(line)
continue
sline = sline.replace('"', '')
sline = sline.replace(NTPD_OPTS_QUOTE, '')
(variable, opts) = sline.split('=', 1)
fd.write('OPTIONS="%s %s"\n' % (opts, ' '.join(newopts)))
fd.write(NTPD_OPTS_VAR + '="%s %s"\n' % (opts, ' '.join(newopts)))
done = True
else:
fd.write(line)