Hello team,

Follow attached 2 patches which introduces to rhncfg-manager a new functionality to allow a file to be uploaded to Spacewalk server overwriting the SELinux context at command line.

   The second patch adds the option into the rhncfg-manager man page.

Best Regards,
Marcelo Moreira de Mello

--
Marcelo Moreira de Mello
RHCA RHCSS RHCVA
Senior Software Maintenance Engineer/SEG

gpg id: 2048R/FDB110E5
gpg fingerprint: 3BE7 EF71 4DD7 6812 D309  8F18 BD42 D095 FDB1 10E5

From: Marcelo Moreira de Mello <mme...@redhat.com>
Date: Mon, 12 Dec 2011 15:53:23 -0200
Subject: [PATCH 1/2] 765816 - Added the option --selinux-context to 
rhncfg-manager which
 allows to overwrite the SELinux context from a file

---
 .../tools/rhncfg/config_management/rhncfg_add.py   |   13 ++++++++++++-
 .../rhncfg/config_management/rpc_repository.py     |    7 ++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/client/tools/rhncfg/config_management/rhncfg_add.py 
b/client/tools/rhncfg/config_management/rhncfg_add.py
index b88fbc1..ec68a86 100644
--- a/client/tools/rhncfg/config_management/rhncfg_add.py
+++ b/client/tools/rhncfg/config_management/rhncfg_add.py
@@ -48,6 +48,10 @@ class Handler(handler_base.HandlerBase):
             '-i', '--ignore-missing',       action="store_true",
              help="Ignore missing local files",
          ),
+        handler_base.HandlerBase._option_class(
+            '--selinux-context',       action="store_true",
+             help="Overwrite the SELinux context",
+         ),
     ]
                                                     
     def run(self):
@@ -110,13 +114,20 @@ class Handler(handler_base.HandlerBase):
 
         delim_start = self.options.delim_start
         delim_end = self.options.delim_end
+
+        selinux_ctx = None
+        if type(self.options.selinux_context) != None:
+            selinux_ctx = self.options.selinux_context
+        else:
+            selinux_ctx = ''
         
         for (local_file, remote_file) in files_to_push:
             try:
                 r.put_file(channel, remote_file, local_file, 
                     is_first_revision=self.is_first_revision,
                     delim_start=delim_start,
-                    delim_end=delim_end)
+                    delim_end=delim_end,
+                    selinux_ctx=selinux_ctx)
             except cfg_exceptions.RepositoryFileExistsError, e:
                 log_error("Error: %s is already in channel %s" %
                           (remote_file, channel))
diff --git a/client/tools/rhncfg/config_management/rpc_repository.py 
b/client/tools/rhncfg/config_management/rpc_repository.py
index 2206db1..907ff89 100644
--- a/client/tools/rhncfg/config_management/rpc_repository.py
+++ b/client/tools/rhncfg/config_management/rpc_repository.py
@@ -135,7 +135,7 @@ class Repository(repository.RPC_Repository):
 
     def put_file(self, config_channel, repopath, localfile=None, 
             is_first_revision=None, old_revision=None, delim_start=None, 
-            delim_end=None):
+            delim_end=None, selinux_ctx=None):
         """
         Insert a given file into the repo, overwriting if necessary.
         localfile defaults to the repopath
@@ -151,6 +151,11 @@ class Repository(repository.RPC_Repository):
             error_msg = "%s too large (%s bytes, %s bytes max allowed)"  
             raise cfg_exceptions.ConfigFileTooLargeError(error_msg % 
(localfile, params['size'], max_file_size))
 
+        if type(selinux_ctx) == str:
+            params.update({
+                'selinux_ctx'   : selinux_ctx,
+            )}
+
         params.update({
             'session'           : self.session,
             'config_channel'    : config_channel,
-- 
1.7.7.4

From: Marcelo Moreira de Mello <mme...@redhat.com>
Date: Mon, 12 Dec 2011 16:05:26 -0200
Subject: [PATCH 2/2] 765816 - Added to the rhncfg-manager man page the option 
--selinux-context

---
 .../rhncfg/config_management/rhncfg-manager.sgml   |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/client/tools/rhncfg/config_management/rhncfg-manager.sgml 
b/client/tools/rhncfg/config_management/rhncfg-manager.sgml
index 9b2a2e5..125ab21 100644
--- a/client/tools/rhncfg/config_management/rhncfg-manager.sgml
+++ b/client/tools/rhncfg/config_management/rhncfg-manager.sgml
@@ -96,6 +96,7 @@
             <para>-t<replaceable>TOPDIR</replaceable>, 
--topdir=<replaceable>TOPDIR</replaceable> -- make all files relative to this 
string</para>
             <para>--delim-start=<replaceable>DELIM_START</replaceable> -- 
start delimiter for variable interpolation</para>
             <para>--delim-end=<replaceable>DELIM_END</replaceable> -- end 
delimiter for variable interpolation</para>
+            <para>--selinux-context=<replaceable>SELINUX_CONTEXT</replaceable> 
-- overwrite the SELinux context label to this string</para>
         </listitem>
     </varlistentry>
     <varlistentry>
@@ -209,6 +210,7 @@
             <para>-t<replaceable>TOPDIR</replaceable>, 
--topdir=<replaceable>TOPDIR</replaceable> -- make all files relative to this 
string</para>
             <para>--delim-start=<replaceable>DELIM_START</replaceable> -- 
start delimiter for variable interpolation</para>
             <para>--delim-end=<replaceable>DELIM_END</replaceable> -- end 
delimiter for variable interpolation</para>
+            <para>--selinux-context=<replaceable>SELINUX_CONTEXT</replaceable> 
-- overwrite the SELinux to this context</para>
         </listitem>
     </varlistentry>
     <varlistentry>
-- 
1.7.7.4

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

Reply via email to