Bug 620366

Summary: configchannel.createOrUpdatePath cuts off newlines
Product: Red Hat Satellite 5 Reporter: Vishal Gaikwad <vgaikwad>
Component: APIAssignee: Lukas Zapletal <lzap>
Status: CLOSED CURRENTRELEASE QA Contact: Michael Mráka <mmraka>
Severity: medium Docs Contact:
Priority: medium    
Version: 530CC: cperry, jhutar, joshkayse, lzap, marcus.moeller, mmraka, pnovotny, roysjosh, stanislav.polasek
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: spacewalk-java-1.2.39-5-sat Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 595500 Environment:
Last Closed: 2010-10-28 15:00:45 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 595500    
Bug Blocks: 608752    

Description Vishal Gaikwad 2010-08-02 10:44:55 UTC
+++ This bug was initially created as a clone of Bug #595500 +++

Description of problem:
using the createOrUpdatePath xmlrpc command API results in newlines being removed from the end of the file

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

How reproducible:
Always

Steps to Reproduce:
1. configchannel.createOrUpdatePath()
2. Log in to web ui, see that the file has a missing newline.
3.
  
Actual results:
ending newlines are removed

Expected results:
ending newlines are preserved

Additional info:
have not tested against 1.0 yet

--- Additional comment from roysjosh on 2010-05-25 15:56:21 EDT ---

Created an attachment (id=416499)
api verbose output

1.0 has the bug still.

Comment 6 Lukas Zapletal 2010-09-16 11:30:33 UTC
Commited in spacewalk, will cherry pick into sat later today.

Comment 7 Lukas Zapletal 2010-09-16 14:20:20 UTC
Fixed in 9c3bbcfc6cac71b6abc1056495882383a5bd2072

Comment 8 Lukas Zapletal 2010-09-16 14:25:30 UTC
Added new parameter named "contents_enc64" to the filestruct of client.system.config.createOrUpdatePath API call. When this parameter is set to true the server expects to have the content in base64 encoding. This prevents from any whitespace stripping that takes place while
parsing XML. Example:

# login etc

content = base64.b64encode(open("/my/config/file.conf").read())

file_struct = { 'contents':content,
        'owner':owner,
        'group':group,
        'permissions':permissions,
        'macro-start-delimiter':'',
        'macro-end-delimiter':'',
        'contents_enc64':'true' }

# call createOrUpdatePath and logout

Comment 9 Lukas Zapletal 2010-09-24 06:20:38 UTC
Setting ON_QA on Cliff's request. This should be already in 2010-09-19 respin.

Comment 10 Michael Mráka 2010-10-08 08:10:42 UTC
# cat >/tmp/emptylines <EOF


3rd line


EOF

# cat >/tmp/test.py <<EOF
import xmlrpclib
import base64

DEFAULT_USER = "admin"
DEFAULT_PASSWORD = "XXXXX"
DEFAULT_SERVER = "localhost"

server_url = "http://%s/rpc/api" % DEFAULT_SERVER
client   = xmlrpclib.Server(server_url)
key      = client.auth.login(DEFAULT_USER, DEFAULT_PASSWORD)

content = base64.b64encode(open("/tmp/emptylines").read())

file_struct = { 'contents':content,
        'owner':'apache',
        'group':'apache',
        'permissions':'444',
        'selinux_ctx': 'unconfined_u:object_r:user_tmp_t:s0',
        'macro-start-delimiter':'',
        'macro-end-delimiter':'',
        'contents_enc64':'true' }

print client.configchannel.createOrUpdatePath(key, 'configch', '/etc/blabla', False, file_struct)
EOF

* created 'configch' config channel in webUI

# python /tmp/test.py
{'binary': False, 'group': 'apache', 'creation': <DateTime '20101008T04:04:12' at 855d08c>, 'modified': <DateTime '20101008T04:04:12' at 855d10c>, 'permissions_mode': '444', 'selinux_ctx': 'unconfined_u:object_r:user_tmp_t:s0', 'channel': 'configch', 'md5': 'cccab077d3cc88bd55d98933cdaa0c98', 'owner': 'apache', 'path': '/etc/blabla', 'permissions': 444, 'type': 'file', 'contents': '\n\n3rd line\n\n', 'revision': 1}

* https://amd-ma78gm-01.rhts.eng.bos.redhat.com/rhn/configuration/file/FileDetails.do?cfid=1
 file has empty lines at the begining and the end


Verified.
Satellite-5.4.0-RHEL5-re20101001.1

Comment 13 Clifford Perry 2010-10-28 14:55:40 UTC
The 5.4.0 RHN Satellite and RHN Proxy release has occurred. This issue has been resolved with this release. 


RHEA-2010:0801 - RHN Satellite Server 5.4.0 Upgrade
https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10332

RHEA-2010:0803 - RHN Tools enhancement update
https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10333

RHEA-2010:0802 - RHN Proxy Server 5.4.0 bug fix update
https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10334

RHEA-2010:0800 - RHN Satellite Server 5.4.0
https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10335

Docs are available:

http://docs.redhat.com/docs/en-US/Red_Hat_Network_Satellite/index.html 

Regards,
Clifford

Comment 14 Tomas Lestach 2012-08-13 16:35:28 UTC
*** Bug 533828 has been marked as a duplicate of this bug. ***