Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid double logging removal of non-mach-o libs #988

Merged
merged 1 commit into from Jan 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 10 additions & 12 deletions lib/omnibus/packagers/pkg.rb
Expand Up @@ -431,23 +431,21 @@ def sign_binary(bin, hardened_runtime = false)
end

def is_binary?(bin)
is_binary = File.file?(bin) &&
File.executable?(bin) &&
!File.symlink?(bin)
log.debug(log_key) { " removing non-binary file from signing: #{bin}" } unless is_binary
is_binary
return false unless File.file?(bin) && File.executable?(bin) && !File.symlink?(bin)

log.debug(log_key) { " skipping non-binary file from signing: #{bin}" }
true
end

def is_macho?(lib)
is_macho = false
if is_binary?(lib)
command = "file #{lib}"
return false unless File.file?(bin) && File.executable?(bin) && !File.symlink?(bin)

stdout = shellout!(command).stdout
is_macho = stdout.match?(/Mach-O.*(library|bundle)/)
if shellout!("file #{lib}").stdout.match?(/Mach-O.*(library|bundle)/) # https://rubular.com/r/nRgaQlAbkM9wHL
log.debug(log_key) { " skipping non-Mach-O library file from signing: #{lib}" }
return true
end
log.debug(log_key) { " removing non-Mach-O library file from signing: #{lib}" } unless is_macho
is_macho

false
end
end
end