From ce1cb952e8792e7ee11fbd28d80c59f7c9d23688 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 11 Feb 2020 14:09:22 -0500 Subject: [PATCH] Fix PAM authentication It's tricky. On Redhat platforms, we need the CAP_DAC_READ_SEARCH capability. Unfortunately this is one of the nicest capabilities to have. For now add it to ambient set so that PAM can work on redhat platforms. Mitigate this risk by safeguarding the license handling code, which is the only known place that can read a file and send it to somewhere. If we could drop the capability from effective set and add it back in when needed, that would be nice, but that appears not to be possible. Short of that, having a separate authentication process running and dropping privilege would potentially work. --- .../confluent/plugins/hardwaremanagement/ipmi.py | 10 +++++++++- .../confluent/plugins/hardwaremanagement/redfish.py | 8 ++++++++ confluent_server/systemd/confluent.service | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index cf990e1d..934df787 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -1506,7 +1506,15 @@ class IpmiHandler(object): if self.element[-1] == '': self.element = self.element[:-1] if self.op in ('create', 'update'): - self.ipmicmd.apply_license(self.inputdata.nodefile(self.node)) + filename = self.inputdata.nodefile(self.node) + if not os.access(filename, os.R_OK): + errstr = ('{0} is not readable by confluent on {1} ' + '(ensure confluent user or group can access file ' + 'and parent directories)').format( + filename, socket.gethostname()) + self.output.put(msg.ConfluentNodeError(self.node, errstr)) + return + self.ipmicmd.apply_license(filename) if len(self.element) == 3: self.output.put(msg.ChildCollection('all')) i = 1 diff --git a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py index 0f4cc46d..7111f3b9 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py @@ -1354,6 +1354,14 @@ class IpmiHandler(object): if self.element[-1] == '': self.element = self.element[:-1] if self.op in ('create', 'update'): + filename = self.inputdata.nodefile(self.node) + if not os.access(filename, os.R_OK): + errstr = ('{0} is not readable by confluent on {1} ' + '(ensure confluent user or group can access file ' + 'and parent directories)'.format( + filename, socket.gethostname()) + self.output.put(msg.ConfluentNodeError(self.node, errstr)) + return self.ipmicmd.apply_license(self.inputdata.nodefile(self.node)) if len(self.element) == 3: self.output.put(msg.ChildCollection('all')) diff --git a/confluent_server/systemd/confluent.service b/confluent_server/systemd/confluent.service index 3ecf1e11..9f6e51c5 100644 --- a/confluent_server/systemd/confluent.service +++ b/confluent_server/systemd/confluent.service @@ -14,7 +14,7 @@ ConfigurationDirectory=confluent ExecStart=/opt/confluent/bin/confluent ExecStop=/opt/confluent/bin/confetty shutdown / Restart=on-failure -AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_SETUID CAP_CHOWN +AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_SETUID CAP_SETGID CAP_DAC_READ_SEARCH CAP_CHOWN User=confluent Group=confluent DevicePolicy=closed