Remove service file even if it isn't link.

(Link to) service file from /etc/systemd/system/ must be removed before masking
systemd service.

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

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
David Kupka 2014-11-06 18:08:58 -05:00 committed by Petr Vobornik
parent 2712b609cb
commit e28eb13907

View File

@ -442,11 +442,9 @@ class SystemdService(PlatformService):
pass
def mask(self, instance_name=""):
if instance_name != "":
srv_tgt = os.path.join(paths.ETC_SYSTEMD_SYSTEM_DIR, instance_name)
# remove instance file or link before masking
if os.path.islink(srv_tgt):
os.unlink(srv_tgt)
srv_tgt = os.path.join(paths.ETC_SYSTEMD_SYSTEM_DIR, self.service_instance(instance_name))
if os.path.exists(srv_tgt):
os.unlink(srv_tgt)
try:
ipautil.run([paths.SYSTEMCTL, "mask",
self.service_instance(instance_name)])