Bug 817370 - spacecmd configchannel_import problems text files without trailing newlines
spacecmd configchannel_import problems text files without trailing newlines
Status: CLOSED NOTABUG
Product: Spacewalk
Classification: Community
Component: Server (Show other bugs)
1.8
x86_64 Linux
unspecified Severity medium
: ---
: ---
Assigned To: Steven Hardy
Red Hat Satellite QA List
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-29 09:51 EDT by Trent Johnson
Modified: 2013-01-28 06:17 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-01-28 06:17:54 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
This file will trigger the problem - make sure it has no newline at the end (208 bytes, application/octet-stream)
2012-05-24 13:40 EDT, Trent Johnson
no flags Details

  None (edit)
Description Trent Johnson 2012-04-29 09:51:00 EDT
Description of problem:

When using spacecmd configchannel_import, if a file in the json did not have a trailing newline it will be imported as some sort of binary garbage.

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

1.8

How reproducible:

Export a config channel that has text files without trailing newlines, import the json into a fresh spacewalk install.   The file will be trashed when viewed in the spacewalk ui.

Steps to Reproduce:
1.  spacecmd configchannel_export
2.  spacecmd configchannel_import
3. view the imported files in the ui
  
Actual results:
File is filled with binary garbage

Expected results:
File is the same as it was when exported

Additional info:
Comment 1 Steven Hardy 2012-05-02 05:07:49 EDT
Thanks for the report - can you please upload an example config file (as an attachment to the bz) which triggers this behaviour?

Note that there are some limitations in the API export of config-channel files - it's not just trailing newlines which require base64 encoding, any file containing characters not-valid in via the XMLRPC API must be exported (and therefore imported) as base64 encoded.  

An example of such a character is the ASCII escape character, which is pretty common in config-files (e.g /etc/vimrc).  This means these files must be export/imported into satellite base64 encoded, which is not ideal but it's a limitation of the API I had to work around.

Can you confirm (the spacewalk web-UI issue aside), does the file get correctly rendered when deployed to a system?

If you can provide further details of your specific issue, then I'll look into possible fixes/workarounds.
Comment 2 Steven Hardy 2012-05-03 17:19:59 EDT
Ok, so I can't reproduce this on recent spacewalk-nightly:

# Create test config-channel, add a couple of files (both actually got uploaded as base64 encoded due to trailing newlines in fstab
spacecmd -- configchannel_create -n foobar -d foobar
spacecmd -- configchannel_addfile -c foobar -p /tmp/vimrc1 -f /etc/vimrc -b
spacecmd -- configchannel_addfile -c foobar -p /tmp/fstab -f /etc/fstab

# Check in web UI - both files are viewable/editable as text in the "file contents" box

# Export/delete/import via spacecmd
spacecmd --debug --  configchannel_export foobar
spacecmd configchannel_delete foobar
spacecmd configchannel_import foobar.json

# Check in web UI - both files are still viewable/editable as text in the "file contents" box

Please re-test on spacewalk-nightly, if you can still reproduce the problem please provide a detailed reproduce procedure
Comment 3 Steven Hardy 2012-05-24 12:17:07 EDT
Ok, no additional information forthcoming, so I'm closing WORKSFORME.

Please reopen if you have more details and a reproduce procedure demonstrating the problem on latest spacewalk.
Comment 4 Trent Johnson 2012-05-24 13:39:21 EDT
Hi Stephen,

I'm still getting the file corruption when I updated to spacecmd-1.8.7-1.el6.noarch.rpm

The bug is triggered if the file is uploaded in plaintext mode, and the file doesn't contain any trailing newline.

I followed your steps above with the attached ssh_host_rsa_key.pub

Thanks for checking into this.

Trent
Comment 5 Trent Johnson 2012-05-24 13:40:41 EDT
Created attachment 586675 [details]
This file will trigger the problem - make sure it has no newline at the end
Comment 6 Tomas Lestach 2012-06-22 07:24:51 EDT
I tried:

spacecmd -- configchannel_addfile -c tml-config -p /tmp/rsa -f /tmp/attachment_586675

with both spacecmd-1.7.7-1.el5 and spacecmd-1.8.9-1.el5

and in both cases a correct file content was uploaded. The same works also with -b option.


Please, provide a reproducer that leads to a faulty behavior.
Comment 7 Steven Hardy 2012-06-25 04:38:16 EDT
My testing also indicates this is not a spacecmd bug - as per comment #2 I suspect an issue with the reporters spacewalk installation
Comment 8 Steven Hardy 2013-01-28 06:17:54 EST
As per comments above, closing NOTABUG

Note You need to log in before you can comment on or make changes to this bug.