From 2a1a136e8f314c25f53ccd2a744ff4aa152b21f8 Mon Sep 17 00:00:00 2001 From: Aria Li Date: Fri, 14 Jun 2024 09:19:28 -0700 Subject: [PATCH 1/2] Revert "Merge pull request #861 from AriaXLi/revert_PA-6549" This reverts commit 01f84b4a5705f39303d5c8d7ac1ef6faccdbc06c, reversing changes made to db00b4c15bc62494c26eb006e2dda09acba12add. --- configs/components/_base-ruby-selinux.rb | 2 ++ .../selinuxswig_ruby_undefining_allocator.patch | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 resources/patches/ruby-selinux/selinuxswig_ruby_undefining_allocator.patch diff --git a/configs/components/_base-ruby-selinux.rb b/configs/components/_base-ruby-selinux.rb index 868565ef3..090deec3f 100644 --- a/configs/components/_base-ruby-selinux.rb +++ b/configs/components/_base-ruby-selinux.rb @@ -4,6 +4,7 @@ # pkg.add_source("file://resources/patches/ruby-selinux/selinuxswig_ruby_wrap.patch") +pkg.add_source("file://resources/patches/ruby-selinux/selinuxswig_ruby_undefining_allocator.patch") # These can be overridden by the including component. ruby_version ||= settings[:ruby_version] @@ -81,6 +82,7 @@ unless platform.name =~ /^(debian-12|ubuntu-24|fedora-40)/ steps << "#{platform.patch} --strip=0 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../selinuxswig_ruby_wrap.patch" end + steps << "#{platform.patch} --strip=0 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../selinuxswig_ruby_undefining_allocator.patch" end # libselinux 3.3 is the minimum version we want to build on RHEL 9, but the diff --git a/resources/patches/ruby-selinux/selinuxswig_ruby_undefining_allocator.patch b/resources/patches/ruby-selinux/selinuxswig_ruby_undefining_allocator.patch new file mode 100644 index 000000000..8a141ff8d --- /dev/null +++ b/resources/patches/ruby-selinux/selinuxswig_ruby_undefining_allocator.patch @@ -0,0 +1,10 @@ +--- selinuxswig_ruby_wrap.c.orig 2024-06-11 20:02:30.112707265 +0000 ++++ selinuxswig_ruby_wrap.c 2024-06-11 22:34:16.000151780 +0000 +@@ -1510,7 +1510,7 @@ + _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); + rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); + } +- rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); ++ rb_undef_alloc_func(rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer)); + free((void *) klass_name); + } From 2cbdf642be908c8df520c9c78b8414884115a526 Mon Sep 17 00:00:00 2001 From: Aria Li Date: Fri, 14 Jun 2024 12:02:11 -0700 Subject: [PATCH 2/2] (PA-6549) Fix warning:undefining the allocator of T_DATA class for RHEL7 This commit adds a patch that patches selinux_ruby_wrap.c in RHEL 7 and RHEL FIPS 7 to fix the warning: undefining the allocator of T_DATA class SWIG::TYPE_p_selabel_handle. These platforms cannot use the original patch (even with increased fuzz values), selinuxswig_ruby_undefining_allocator.patch, that fixed the warning for other platforms. RHEL 7 and RHEL FIPS 7 use an older version of swig and due to that, have an older version of selinux_ruby_wrap.c. --- configs/components/_base-ruby-selinux.rb | 13 ++++++++++++- .../ruby-selinux/undefining_allocator_el_7.patch | 10 ++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 resources/patches/ruby-selinux/undefining_allocator_el_7.patch diff --git a/configs/components/_base-ruby-selinux.rb b/configs/components/_base-ruby-selinux.rb index 090deec3f..2d30fbd50 100644 --- a/configs/components/_base-ruby-selinux.rb +++ b/configs/components/_base-ruby-selinux.rb @@ -5,6 +5,7 @@ pkg.add_source("file://resources/patches/ruby-selinux/selinuxswig_ruby_wrap.patch") pkg.add_source("file://resources/patches/ruby-selinux/selinuxswig_ruby_undefining_allocator.patch") +pkg.add_source("file://resources/patches/ruby-selinux/undefining_allocator_el_7.patch") # These can be overridden by the including component. ruby_version ||= settings[:ruby_version] @@ -82,7 +83,17 @@ unless platform.name =~ /^(debian-12|ubuntu-24|fedora-40)/ steps << "#{platform.patch} --strip=0 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../selinuxswig_ruby_wrap.patch" end - steps << "#{platform.patch} --strip=0 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../selinuxswig_ruby_undefining_allocator.patch" + # EL 7 uses an older version of swig (2.0) so a different patch is needed to + # fix warning:undefining the allocator of T_DATA class + if platform.name =~ /el-7|redhatfips-7/ + steps << "#{platform.patch} --strip=0 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../undefining_allocator_el_7.patch" + else + # Ubuntu 24 & Fedora 40 use a newer swig that already has the fix that's + # being patched + unless platform.name =~ /^(ubuntu-24|fedora-40)/ + steps << "#{platform.patch} --strip=0 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../selinuxswig_ruby_undefining_allocator.patch" + end + end end # libselinux 3.3 is the minimum version we want to build on RHEL 9, but the diff --git a/resources/patches/ruby-selinux/undefining_allocator_el_7.patch b/resources/patches/ruby-selinux/undefining_allocator_el_7.patch new file mode 100644 index 000000000..04b1d93a0 --- /dev/null +++ b/resources/patches/ruby-selinux/undefining_allocator_el_7.patch @@ -0,0 +1,10 @@ +--- selinuxswig_ruby_wrap_orig.c 2024-06-14 18:03:11.946019756 +0000 ++++ selinuxswig_ruby_wrap.c 2024-06-14 18:08:23.057169863 +0000 +@@ -1486,7 +1486,7 @@ + _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); + rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); + } +- klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); ++ rb_undef_alloc_func(rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer)); + free((void *) klass_name); + }