Issue #4466 has been updated by James Turnbull.

Status changed from Accepted to Closed

Red Hat ticket - https://bugzilla.redhat.com/show_bug.cgi?id=751214.  Closing 
as an upstream issue.
----------------------------------------
Bug #4466: Files in /proc should not be read directly by Ruby
https://projects.puppetlabs.com/issues/4466

Author: Rein Henrichs
Status: Closed
Priority: Normal
Assignee: 
Category: 
Target version: 
Keywords: 
Branch: 
Affected Facter version: 


Per a thread on the dev mailing list, Ruby reads files in /proc unreliably. The 
current solution in some places is to use `/bin/cat`, for example `%x{ /bin/cat 
/proc/uptime }`, instead of using `File.read` or variants. We should make sure 
files in /proc are never read by Ruby directly.

>From Paul Berry:

> Correct me if I'm wrong, but it looks like the core problem is that reading
> from /proc files directly in Ruby is unreliable, because those files don't
> always respond to select() calls the way the Ruby interpreter expects.
>  Sadly, the Linux kernel maintainers don't appear to have any intention of
> fixing this behavior (https://bugzilla.kernel.org/show_bug.cgi?id=11014), so
> we're stuck with it.
> 
> There are other places in Facter that read directly from /proc.  We should
> probably fix them too:
> 
>     ./lib/facter/processor.rb:14:    File.readlines("/proc/cpuinfo").each do 
> |l|
>     ./lib/facter/selinux.rb:11:      if (File.read("/proc/self/attr/current") 
> != "kernel\0")
>     ./lib/facter/util/ip.rb:135:     bondinfo = 
> IO.readlines("/proc/net/bonding/#{bonddev}")
>     ./lib/facter/util/memory.rb:23:  File.readlines("/proc/meminfo").each do 
> |l|
>     ./lib/facter/util/virtual.rb:24: txt = File.read("/proc/self/status")
>     ./lib/facter/util/virtual.rb:47: txt = File.read("/proc/cpuinfo")
>     ./lib/facter/util/vlans.rb:7:    output = 
> File.open('/proc/net/vlan/config').read


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to