Jira (PUP-10122) Only collect checksum metadata for links pointing to files

8 views
Skip to first unread message

Josh Cooper (JIRA)

unread,
Nov 7, 2019, 12:43:04 PM11/7/19
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Puppet / Bug PUP-10122
Only collect checksum metadata for links pointing to files
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2019/11/07 9:42 AM
Priority: Normal Normal
Reporter: Josh Cooper

While researching PE-27428 we discovered that if a symlink refers to a directory, puppet will call Puppet::Util::Checksums.md5_file on the link, and silently rescue if it raises. See https://github.com/puppetlabs/puppet/blob/d579170b0583eed4e9050a8b798574c451f3c2ac/lib/puppet/file_serving/metadata.rb#L120. If the symlink refers to a directory, then Ruby is supposed to raise EISDIR, which it does in MRI ruby.

However, there is a bug in JRuby 9.1.16 which causes File.open to get into an infinite loop.

Since puppet knows the file is a symlink, and reads the link to find what the link points to, then it should probably stat the destination/target to see whether it should checksum it.

/cc Joshua Partlow, Maggie Dreyer

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (JIRA)

unread,
Nov 8, 2019, 1:43:03 PM11/8/19
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10122
 
Re: Only collect checksum metadata for links pointing to files

It seems to hang on ruby MRI too... at least File.read:

require 'tempfile'
 
dir = '/tmp/dir'
link = '/tmp/link'
 
File.unlink(link) if File.exist?(link)
Dir.mkdir(dir) unless File.directory?(dir)
link = File.symlink(dir, link)
 
puts "Opening"
File.open(link, File::RDONLY) do |fh|
  puts "Opened"
  puts fh.read
  puts "Done"
end

# strace -f ruby linkbug.rb
...
[pid 14513] stat("/tmp/link", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 14513] unlink("/tmp/link")         = 0
[pid 14513] stat("/tmp/dir", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
[pid 14513] symlink("/tmp/dir", "/tmp/link") = 0
[pid 14513] writev(1, [{iov_base="Opening", iov_len=7}, {iov_base="\n", iov_len=1}], 2Opening
) = 8
[pid 14513] fcntl(0, F_GETFL)           = 0x2 (flags O_RDWR)
[pid 14513] ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
[pid 14513] writev(1, [{iov_base="Opened", iov_len=6}, {iov_base="\n", iov_len=1}], 2Opened
) = 7
[pid 14513] fstat(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 0), ...}) = 0
[pid 14513] read(0,
# ruby is hung here ^

Joshua Partlow (JIRA)

unread,
Nov 8, 2019, 3:15:02 PM11/8/19
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
May 22, 2020, 3:39:03 PM5/22/20
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Epic Link: PUP-10533
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages