From e1d54dd9076c91977ecb84298868c0b02f5f5f81 Mon Sep 17 00:00:00 2001 From: pmoravec Date: Mon, 26 Aug 2019 17:06:54 +0200 Subject: [policies/amazon] Handle missing /etc/os-release properly Catch use cases when /etc/os-release is missing by returning Amazon policy as disabled. Resolves: #1763 Signed-off-by: pmoravec --- sos/policies/amazon.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sos/policies/amazon.py b/sos/policies/amazon.py index e1bfe1df..ce60c5e3 100644 --- a/sos/policies/amazon.py +++ b/sos/policies/amazon.py @@ -12,6 +12,7 @@ from __future__ import print_function from sos.policies.redhat import RedHatPolicy, OS_RELEASE +import os class AmazonPolicy(RedHatPolicy): @@ -25,6 +26,9 @@ class AmazonPolicy(RedHatPolicy): @classmethod def check(cls): + if not os.path.exists(OS_RELEASE): + return False + with open(OS_RELEASE, 'r') as f: for line in f: if line.startswith('NAME'): -- cgit