Bug 1441590 - createOrUpdatePath strips text file's contents off of newlines at the end
Summary: createOrUpdatePath strips text file's contents off of newlines at the end
Keywords:
Status: CLOSED DUPLICATE of bug 1423017
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: API
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Jan Dobes
QA Contact: Lukáš Hellebrandt
URL:
Whiteboard:
Depends On:
Blocks: sat580-low
TreeView+ depends on / blocked
 
Reported: 2017-04-12 09:38 UTC by Lukáš Hellebrandt
Modified: 2017-05-03 12:38 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-05-03 12:38:12 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

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 ***


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