Hi,

Attached is a patch to implement solution #2 from my previous request.

/usr/share/rhn/actions/script.py now imports some libs for configuration file 
access and reads "script_tmp_dir" parameter from rhncfg-client.conf, if unset 
it will fallback to the previous behavior and use /tmp as usual.

@Mirek
I've made some changed to the rhncfg spec file too to create the new default 
directory, do I need to update the changelog and/or the release number or is 
something you will take care of? This is my first contribution here so forgive 
my ignorance.

Regards.

/Matt
From ae9935f774edca9f6f8e597981531d17f3144d0e Mon Sep 17 00:00:00 2001
From: Matteo Sessa <matteo.se...@dbmsrl.com>
Date: Tue, 31 May 2011 11:04:21 +0200
Subject: [PATCH] temp script file customizable dedicated directory

---
 client/tools/rhncfg/actions/script.py              |    9 +++++++++
 .../tools/rhncfg/config_client/rhncfg-client.conf  |    3 +++
 client/tools/rhncfg/rhncfg.spec                    |    1 +
 3 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/client/tools/rhncfg/actions/script.py b/client/tools/rhncfg/actions/script.py
index 58afb28..957e7ab 100644
--- a/client/tools/rhncfg/actions/script.py
+++ b/client/tools/rhncfg/actions/script.py
@@ -31,6 +31,10 @@ except ImportError:
 
 # this is ugly, hopefully it will be natively supported in up2date
 from configfiles import _local_permission_check, _perm_error
+from config_common import local_config
+
+sys.path.append('/usr/share/rhn')
+from up2date_client import config
 
 
 # this is a list of the methods that get exported by a module
@@ -76,6 +80,11 @@ def _create_script_file(script, uid=None, gid=None):
 
 
 def run(action_id, params, cache_only=None):
+
+    cfg = config.initUp2dateConfig()
+    local_config.init('rhncfg-client', defaults=dict(cfg.items()))
+
+    tempfile.tempdir = local_config.get('script_tmp_dir')
     if cache_only:
         return (0, "no-ops for caching", {})
 
diff --git a/client/tools/rhncfg/config_client/rhncfg-client.conf b/client/tools/rhncfg/config_client/rhncfg-client.conf
index 1a1b93a..be2b3b6 100644
--- a/client/tools/rhncfg/config_client/rhncfg-client.conf
+++ b/client/tools/rhncfg/config_client/rhncfg-client.conf
@@ -7,6 +7,9 @@ systemid = /etc/sysconfig/rhn/systemid
 # increase for debugging output
 debug_level = 0
 
+# Default directory for remote command temporary script file.
+# If not set it will default to None and it will fallback to python's default tempdir search algorithm
+script_tmp_dir = /var/spool/rhn
 
 # don't change this... used in substitutions below.
 # if you get rid of the '%(server_handler)s' bits below,
diff --git a/client/tools/rhncfg/rhncfg.spec b/client/tools/rhncfg/rhncfg.spec
index 20c3e9b..536312f 100644
--- a/client/tools/rhncfg/rhncfg.spec
+++ b/client/tools/rhncfg/rhncfg.spec
@@ -77,6 +77,7 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{_sharedstatedir}
 %endif
 %dir %{_sharedstatedir}/rhncfg
+%dir %{_localstatedir}/spool/rhn
 %{rhnroot}/config_common
 %{_sharedstatedir}/rhncfg/backups
 %doc LICENSE PYTHON-LICENSES.txt
-- 
1.7.4.1

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to