Skip to content

Commit a7fc904

Browse files
authored
Merge pull request #864 from AriaXLi/patch_selinuxswig_ruby_wrap_c
(PA-6549) Patch selinux_ruby_wrap.c to fix warning: undefining the allocator of T_DATA class # SWIG::TYPE_p_selabel_handle
2 parents 967911b + 2cbdf64 commit a7fc904

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Diff for: configs/components/_base-ruby-selinux.rb

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#
55

66
pkg.add_source("file://resources/patches/ruby-selinux/selinuxswig_ruby_wrap.patch")
7+
pkg.add_source("file://resources/patches/ruby-selinux/selinuxswig_ruby_undefining_allocator.patch")
8+
pkg.add_source("file://resources/patches/ruby-selinux/undefining_allocator_el_7.patch")
79

810
# These can be overridden by the including component.
911
ruby_version ||= settings[:ruby_version]
@@ -81,6 +83,17 @@
8183
unless platform.name =~ /^(debian-12|ubuntu-24|fedora-40)/
8284
steps << "#{platform.patch} --strip=0 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../selinuxswig_ruby_wrap.patch"
8385
end
86+
# EL 7 uses an older version of swig (2.0) so a different patch is needed to
87+
# fix warning:undefining the allocator of T_DATA class
88+
if platform.name =~ /el-7|redhatfips-7/
89+
steps << "#{platform.patch} --strip=0 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../undefining_allocator_el_7.patch"
90+
else
91+
# Ubuntu 24 & Fedora 40 use a newer swig that already has the fix that's
92+
# being patched
93+
unless platform.name =~ /^(ubuntu-24|fedora-40)/
94+
steps << "#{platform.patch} --strip=0 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../selinuxswig_ruby_undefining_allocator.patch"
95+
end
96+
end
8497
end
8598

8699
# libselinux 3.3 is the minimum version we want to build on RHEL 9, but the
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- selinuxswig_ruby_wrap.c.orig 2024-06-11 20:02:30.112707265 +0000
2+
+++ selinuxswig_ruby_wrap.c 2024-06-11 22:34:16.000151780 +0000
3+
@@ -1510,7 +1510,7 @@
4+
_cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
5+
rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
6+
}
7+
- rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
8+
+ rb_undef_alloc_func(rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer));
9+
free((void *) klass_name);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- selinuxswig_ruby_wrap_orig.c 2024-06-14 18:03:11.946019756 +0000
2+
+++ selinuxswig_ruby_wrap.c 2024-06-14 18:08:23.057169863 +0000
3+
@@ -1486,7 +1486,7 @@
4+
_cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
5+
rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
6+
}
7+
- klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
8+
+ rb_undef_alloc_func(rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer));
9+
free((void *) klass_name);
10+
}

0 commit comments

Comments
 (0)