Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevorturk/25108 to your computer and use it in GitHub Desktop.
Save trevorturk/25108 to your computer and use it in GitHub Desktop.
require 'etc'
class Group
def foo
"hello"
end
end
class WTF < Struct.new(:var)
def foo
puts Group.new.foo
end
end
puts Group.new.foo
WTF.new.foo
### OUTPUT ###
# NoMethodError: undefined method ‘foo’ for #<struct Struct::Group name=nil, passwd=nil, gid=nil, mem=nil>
#
# So... when you require 'etc' you get a Struct::Group and Struct::Passwd
#
# For Rails apps, the offender is in rails/railties/lib/rails/mongrel_server
# ... which requires 'etc'
# http://www.ruby-doc.org/stdlib/libdoc/etc/rdoc/classes/Etc.html
#
# Awesome!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment