|
|
95ea96 |
From da98cbda7b61792d956b21f0a9999d91894ae194 Mon Sep 17 00:00:00 2001
|
|
|
95ea96 |
From: Florence Blanc-Renaud <flo@redhat.com>
|
|
|
95ea96 |
Date: Tue, 21 Aug 2018 17:55:45 +0200
|
|
|
95ea96 |
Subject: [PATCH] uninstall -v: remove Tracebacks
|
|
|
95ea96 |
|
|
|
95ea96 |
ipa-server-install --uninstall -v -U prints Traceback in its log file.
|
|
|
95ea96 |
This issue happens because it calls subprocess.Popen with close_fds=True
|
|
|
95ea96 |
(which closes all file descriptors in the child process)
|
|
|
95ea96 |
but it is trying to use the file logger in the child process
|
|
|
95ea96 |
(preexec_fn is called in the child just before the child is executed).
|
|
|
95ea96 |
The fix is using the logger only in the parent process.
|
|
|
95ea96 |
|
|
|
95ea96 |
Fixes: https://pagure.io/freeipa/issue/7681
|
|
|
95ea96 |
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
|
|
|
95ea96 |
---
|
|
|
95ea96 |
ipapython/ipautil.py | 23 ++++++++++++-----------
|
|
|
95ea96 |
1 file changed, 12 insertions(+), 11 deletions(-)
|
|
|
95ea96 |
|
|
|
95ea96 |
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
|
|
|
95ea96 |
index 0de5fe86374429bfb9666a0d257e079883a1c56b..42329ad7c1677ad16c8d3275d79666005571cbc7 100644
|
|
|
95ea96 |
--- a/ipapython/ipautil.py
|
|
|
95ea96 |
+++ b/ipapython/ipautil.py
|
|
|
95ea96 |
@@ -481,20 +481,21 @@ def run(args, stdin=None, raiseonerr=True, nolog=(), env=None,
|
|
|
95ea96 |
logger.debug('Starting external process')
|
|
|
95ea96 |
logger.debug('args=%s', arg_string)
|
|
|
95ea96 |
|
|
|
95ea96 |
- def preexec_fn():
|
|
|
95ea96 |
- if runas is not None:
|
|
|
95ea96 |
- pent = pwd.getpwnam(runas)
|
|
|
95ea96 |
+ if runas is not None:
|
|
|
95ea96 |
+ pent = pwd.getpwnam(runas)
|
|
|
95ea96 |
|
|
|
95ea96 |
- suplementary_gids = [
|
|
|
95ea96 |
- grp.getgrnam(sgroup).gr_gid for sgroup in suplementary_groups
|
|
|
95ea96 |
- ]
|
|
|
95ea96 |
+ suplementary_gids = [
|
|
|
95ea96 |
+ grp.getgrnam(sgroup).gr_gid for sgroup in suplementary_groups
|
|
|
95ea96 |
+ ]
|
|
|
95ea96 |
|
|
|
95ea96 |
- logger.debug('runas=%s (UID %d, GID %s)', runas,
|
|
|
95ea96 |
- pent.pw_uid, pent.pw_gid)
|
|
|
95ea96 |
- if suplementary_groups:
|
|
|
95ea96 |
- for group, gid in zip(suplementary_groups, suplementary_gids):
|
|
|
95ea96 |
- logger.debug('suplementary_group=%s (GID %d)', group, gid)
|
|
|
95ea96 |
+ logger.debug('runas=%s (UID %d, GID %s)', runas,
|
|
|
95ea96 |
+ pent.pw_uid, pent.pw_gid)
|
|
|
95ea96 |
+ if suplementary_groups:
|
|
|
95ea96 |
+ for group, gid in zip(suplementary_groups, suplementary_gids):
|
|
|
95ea96 |
+ logger.debug('suplementary_group=%s (GID %d)', group, gid)
|
|
|
95ea96 |
|
|
|
95ea96 |
+ def preexec_fn():
|
|
|
95ea96 |
+ if runas is not None:
|
|
|
95ea96 |
os.setgroups(suplementary_gids)
|
|
|
95ea96 |
os.setregid(pent.pw_gid, pent.pw_gid)
|
|
|
95ea96 |
os.setreuid(pent.pw_uid, pent.pw_uid)
|
|
|
95ea96 |
--
|
|
|
95ea96 |
2.17.1
|
|
|
95ea96 |
|