mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Apply SELinux context only if cron_file param exists
Use selinux calls in module_utils/basic instead of native selinux bindings Fixes #18768
This commit is contained in:
parent
07a517aebd
commit
ad9c25a54f
1 changed files with 2 additions and 8 deletions
|
@ -237,12 +237,6 @@ import tempfile
|
|||
import platform
|
||||
import pipes
|
||||
|
||||
try:
|
||||
import selinux
|
||||
HAS_SELINUX = True
|
||||
except ImportError:
|
||||
HAS_SELINUX = False
|
||||
|
||||
CRONCMD = "/usr/bin/crontab"
|
||||
|
||||
class CronTabError(Exception):
|
||||
|
@ -345,8 +339,8 @@ class CronTab(object):
|
|||
self.module.fail_json(msg=err)
|
||||
|
||||
# set SELinux permissions
|
||||
if HAS_SELINUX:
|
||||
selinux.selinux_lsetfilecon_default(self.cron_file)
|
||||
if self.module.selinux_enabled() and self.cron_file:
|
||||
self.module.set_default_selinux_context(self.cron_file, False)
|
||||
|
||||
def do_comment(self, name):
|
||||
return "%s%s" % (self.ansible, name)
|
||||
|
|
Loading…
Reference in a new issue