Bug 1441590

Summary: createOrUpdatePath strips text file's contents off of newlines at the end
Product: Red Hat Satellite 5 Reporter: Lukáš Hellebrandt <lhellebr>
Component: APIAssignee: Jan Dobes <jdobes>
Status: CLOSED DUPLICATE QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: low Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: ggainey, tlestach
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-05-03 12:38:12 UTC Type: Bug
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:    
Bug Blocks: 1358815    

Description Lukáš Hellebrandt 2017-04-12 09:38:06 UTC
Description of problem:
createOrUpdatePath strips text file's contents off of newlines at the end. POSIX text files, however, must end with a newline.

How reproducible:
Deterministic

Steps to Reproduce:

In Python:
client.system.config.createOrUpdatePath(session,<SYSID>,"/root/abc",False,{'contents': "test\n", 'owner': "root", 'group': "root", 'permissions': "644", 'binary': False}, 1)

Returns:
[...] 'sha256': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08' [...]

Notice the checksum.

Create a file with string "test" and newline (all sane text editors append it implicitly at the end of file).

# wc -m <file>
5 <file>

# sha256sum <file>
f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 <file>

Notice this checksum differs.

Create a file without the end of line (in Vim: ":set binary", ":set noeol", ":wq").

# wc -m a
4 a

# sha256sum a 
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08  a

Notice the file Saved on Satellite is actually the one without mandatory EOL at EOF.

Expected results:
The API call should append EOL at EOF in text mode or at least not remove it.

Comment 2 Tomas Lestach 2017-04-12 12:10:57 UTC
I think it's the xmlrpc library that trims endlines (trailing whitespaces). I think that was the reason for: https://github.com/spacewalkproject/spacewalk/commit/a532229630ff01b91807236b94016b9eca6200a5

I also think it's not Sat5 that trims the whitespaces in this case. However I'm ok investigate it. If it turns to be the xmlrpc library and we're not able to achieve desired behavior by its configuration, I'd tend to close this bug WONTFIX as we do not plan to replace the underlying xmlrpc library.

Comment 3 Lukáš Hellebrandt 2017-04-12 12:26:16 UTC
How about hard-coding the EOL at EOF for the text files then?
(Just a proposal, it would mean behavior change and might not be worth it.)

Comment 4 Grant Gainey 2017-05-03 12:38:12 UTC
Closing as dup - see discussion in 1423017

*** This bug has been marked as a duplicate of bug 1423017 ***