Bug 671112

Summary: rhncfg prints traceback instead of error message when selinux context is invalid
Product: Red Hat Satellite 5 Reporter: Jiri Kastner <jkastner>
Component: ClientAssignee: Michael Mráka <mmraka>
Status: CLOSED DEFERRED QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: medium Docs Contact:
Priority: low    
Version: 540Keywords: Reopened
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-04 13:28:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 462714    

Description Jiri Kastner 2011-01-20 12:27:00 UTC
Description of problem:
rhel5, rhel6 have different selinux contexts, which causes error during deployment when is there selinux context valid only for one platform

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. create cfg. channel with files, links (without selinux context filled) and register rhel5 rhel6 machines to this channel
2. find some selinux context, which is only on one platform and set this context  for those files and links
3. execute 'rhncfg-client get --topdir=/tmp/topdir' or 'rhncfg-manager upload-channel channel-from-step-2 -t /tmp'
  
Actual results:

rhncfg-client get --topdir /tmp/topdir 
Traceback (most recent call last):
  File "/usr/bin/rhncfg-client", line 34, in ?
    sys.exit(Main().main() or 0)
  File "/usr/share/rhn/config_common/rhn_main.py", line 187, in main
    handler.run()
  File "/usr/share/rhn/config_client/rhncfgcli_get.py", line 25, in run
    self.options.exclude)
  File "/usr/share/rhn/config_common/deploy.py", line 53, in deploy_files
    dep_trans.add_preprocessed(path, processed_path, file_info, dirs_created)
  File "/usr/share/rhn/config_common/transactions.py", line 192, in add_preprocessed
    self._chown_chmod_chcon(processed_file_path, dest_path, file_info, strict_ownership=strict_ownership)
  File "/usr/share/rhn/config_common/transactions.py", line 160, in _chown_chmod_chcon
    raise Exception("failed to set selinux context on %s" % dest_path)
Exception: failed to set selinux context on /tmp/topdir/tmp/config.cfg
#################################
rhncfg-manager download-channel test-644985 -t /tmp
Traceback (most recent call last):
  File "/usr/bin/rhncfg-manager", line 46, in <module>
    sys.exit(Main().main() or 0)
  File "/usr/share/rhn/config_common/rhn_main.py", line 187, in main
    handler.run()
  File "/usr/share/rhn/config_management/rhncfg_download_channel.py", line 52, in run
    config_channel=ns)
  File "/usr/share/rhn/config_common/deploy.py", line 53, in deploy_files
    dep_trans.add_preprocessed(path, processed_path, file_info, dirs_created)
  File "/usr/share/rhn/config_common/transactions.py", line 192, in add_preprocessed
    self._chown_chmod_chcon(processed_file_path, dest_path, file_info, strict_ownership=strict_ownership)
  File "/usr/share/rhn/config_common/transactions.py", line 159, in _chown_chmod_chcon
    if lsetfilecon(temp_file_path, sectx) < 0:
Exception: ('failed to set selinux context on /tmp/test-644985/tmp/config.cfg', OSError(22, 'Invalid argument'))

Expected results:
rhncfg-manager download-channel test-644985 -t /tmp
WARNING: skipping invalid selinux context

Additional info:

Comment 1 Michael Mráka 2011-01-20 12:44:26 UTC
It's supposed to work that way.

For different selinux context for RHEL 5 and 6 put separate config files into separate channels for the respective OS.