(#14522) Don't read /proc/self/status on Solaris#421
Closed
haus wants to merge 1 commit intopuppetlabs:1.7.xfrom
haus:ticket/1.7.x/14522_dont_read_proc_on_solaris
Closed
(#14522) Don't read /proc/self/status on Solaris#421haus wants to merge 1 commit intopuppetlabs:1.7.xfrom haus:ticket/1.7.x/14522_dont_read_proc_on_solaris
haus wants to merge 1 commit intopuppetlabs:1.7.xfrom
haus:ticket/1.7.x/14522_dont_read_proc_on_solaris
Conversation
/proc/self/status isn't a standard file on Solaris and can't be read as such. Attempting to read it when using ruby 1.9.3 produces errors such as 'invalid byte sequence in US-ASCII'. According to http://www.ruby-forum.com/topic/163804, /proc/self/status is a sparse file with a map at /proc/self/map to indicate which parts of the file to read. As a stopgap measure, this commit simply returns false on Solaris, rather than trying to read the file.
|
CLA Signed by haus on 2011-07-19 21:00:00 -0700 |
There was a problem hiding this comment.
Haus and I looked at this together and it's not the File.open that's the problem, but rather the comparison of raw data inside of a string Ruby thinks is encoded as UTF-8 being compared against a regular expression that is also UTF-8. When this happens the invalid UTF-8 sequence in the raw data causes the exception.
I think we can filter the raw data and make this work in a general way if we do this:
txt = File.open("/proc/self/status", "rb").read
txt.encode!('UTF-8', 'UTF-8', :invalid => :replace)
return true if txt =~ /^(s_context|VxID):[[:blank:]]*[0-9]/
Contributor
|
@jeffmccune @haus make sure to check if the |
|
summary: Merged into master as 2cadc7c. This should be released in Facter 1.7. Thanks again for the contribution! -Jeff |
florindragos
pushed a commit
that referenced
this pull request
Jun 15, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/proc/self/status isn't a standard file on Solaris and can't be read as such.
Attempting to read it when using ruby 1.9.3 produces errors such as 'invalid
byte sequence in US-ASCII'. According to
http://www.ruby-forum.com/topic/163804, /proc/self/status is a sparse file with
a map at /proc/self/map to indicate which parts of the file to read. As a
stopgap measure, this commit simply returns false on Solaris, rather than
trying to read the file.