Blame SOURCES/0088-policies-redhat-automatically-set-tmp_dir-in-contain.patch

0cd6dc
From 81cda098bae00968091d50596d14880a78b893fb Mon Sep 17 00:00:00 2001
0cd6dc
From: "Bryn M. Reeves" <bmr@redhat.com>
0cd6dc
Date: Tue, 27 Jan 2015 12:54:31 -0500
0cd6dc
Subject: [PATCH 88/93] [policies/redhat] automatically set tmp_dir in
0cd6dc
 containers
0cd6dc
0cd6dc
Now that policies have the infrastructure to detect that they
0cd6dc
are running in a container and to use the HOST environment
0cd6dc
variable if present enable automatic setting of self._tmp_dir in
0cd6dc
appriate container environments.
0cd6dc
0cd6dc
This causes reports to be automatically written to $HOST/var/tmp
0cd6dc
when $HOST is set while still allowing users to override the tmp
0cd6dc
path manually by specificying --tmp-dir=PATH.
0cd6dc
0cd6dc
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
0cd6dc
---
0cd6dc
 sos/policies/redhat.py | 7 +++++--
0cd6dc
 1 file changed, 5 insertions(+), 2 deletions(-)
0cd6dc
0cd6dc
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py
0cd6dc
index 81ed8ad..c057e6e 100644
0cd6dc
--- a/sos/policies/redhat.py
0cd6dc
+++ b/sos/policies/redhat.py
0cd6dc
@@ -71,14 +71,17 @@ class RedHatPolicy(LinuxPolicy):
0cd6dc
         return False
0cd6dc
 
0cd6dc
     def _container_init(self):
0cd6dc
-        """Check if sos is running in a container and if a host sysroot
0cd6dc
-        has been passed in the environment.
0cd6dc
+        """Check if sos is running in a container and perform container
0cd6dc
+        specific initialisation based on ENV_HOST_SYSROOT.
0cd6dc
         """
0cd6dc
         if ENV_CONTAINER_UUID in os.environ:
0cd6dc
             self._in_container = True
0cd6dc
         if ENV_HOST_SYSROOT in os.environ:
0cd6dc
             self._host_sysroot = os.environ[ENV_HOST_SYSROOT]
0cd6dc
         use_sysroot = self._in_container and self._host_sysroot != '/'
0cd6dc
+        if use_sysroot:
0cd6dc
+            host_tmp_dir = os.path.abspath(self._host_sysroot + self._tmp_dir)
0cd6dc
+            self._tmp_dir = host_tmp_dir
0cd6dc
         return self._host_sysroot if use_sysroot else None
0cd6dc
 
0cd6dc
     def runlevel_by_service(self, name):
0cd6dc
-- 
0cd6dc
1.9.3
0cd6dc