On Tue, 2011-04-26 at 17:08 -0400, Rob Crittenden wrote:
> Simo Sorce wrote:
> > With this patch we stop clearing the environment variables when running
> > binaries allowing for env variables to be passed down by default.
> >
> > This fixes also the init script against Fedora 15 and systemd
> >
> > Simo.
> >
> 
> I think it would be better to import copy and use:
> 
> if env is None:
>      env = copy.deepcopy(os.environ)
>      env["PATH"] = "/bin:/sbin:..."
> 
> rob

Updated patch attached.

Simo.

-- 
Simo Sorce * Red Hat, Inc * New York
>From 99479272dfa3d9a7ba8e593f72ec61da1d851752 Mon Sep 17 00:00:00 2001
From: Simo Sorce <sso...@redhat.com>
Date: Tue, 26 Apr 2011 15:51:34 -0400
Subject: [PATCH] ipautil: Preserve environment unless explicitly overridden
 by caller.

Fixes: https://fedorahosted.org/freeipa/ticket/1193
---
 ipapython/ipautil.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 81719ccaedcc9b01dccc3d01098830bcdc6aa087..b5a0b9105800b55296bb36877e9b98666426c7cc 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -28,6 +28,7 @@ import logging
 import subprocess
 import random
 import os, sys, traceback, readline
+import copy
 import stat
 import shutil
 import urllib2
@@ -119,7 +120,9 @@ def run(args, stdin=None, raiseonerr=True,
     p_err = None
 
     if env is None:
-        env={"PATH": "/bin:/sbin:/usr/kerberos/bin:/usr/kerberos/sbin:/usr/bin:/usr/sbin"}
+        # copy default env
+        env = copy.deepcopy(os.environ)
+        env["PATH"] = "/bin:/sbin:/usr/kerberos/bin:/usr/kerberos/sbin:/usr/bin:/usr/sbin"
     if stdin:
         p_in = subprocess.PIPE
     if capture_output:
-- 
1.7.4.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to