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

Use rb_io_descriptor() API to fix deprecated message #11

Merged
merged 7 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ '2.5', '2.6' , '2.7', '3.0' ]
ruby: [ '2.5', '2.6' , '2.7', '3.0', '3.1', '3.2', '3.3', '3.4' ]
os:
- ubuntu-latest
name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
Expand All @@ -25,6 +25,5 @@ jobs:
env:
CI: true
run: |
gem install bundler rake
bundle install --jobs 4 --retry 3
bundle exec rake
14 changes: 7 additions & 7 deletions .github/workflows/yum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:
fail-fast: false
matrix:
label:
- CentOS 7 x86_64
- CentOS 8 x86_64
- RockyLinux 8 x86_64
- AlmaLinux 9 x86_64
- Fedora 33 x86_64
- AmazonLinux 2 x86_64
include:
- label: CentOS 7 x86_64
test-docker-image: centos:7
- label: RockyLinux 8 x86_64
test-docker-image: rockylinux:8
test-script: ci/yum-test.sh
- label: CentOS 8 x86_64
test-docker-image: centos:8
- label: AlmaLinux 9 x86_64
test-docker-image: almalinux:9
test-script: ci/yum-test.sh
- label: Fedora 33 x86_64
test-docker-image: fedora:33
Expand All @@ -36,4 +36,4 @@ jobs:
--tty \
--volume ${PWD}:/capng \
${{ matrix.test-docker-image }} \
/capng/${{ matrix.test-script }}
/capng/${{ matrix.test-script }}
4 changes: 1 addition & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ end

require "rake/extensiontask"

spec = eval File.read("capng_c.gemspec")

Rake::ExtensionTask.new("capng", spec) do |ext|
Rake::ExtensionTask.new("capng") do |ext|
ext.lib_dir = "lib/capng"
end

Expand Down
4 changes: 2 additions & 2 deletions ci/apt-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export DEBIAN_FRONTEND=noninteractive
apt update
apt install -V -y lsb-release

apt install -V -y ruby-dev git build-essential pkg-config
apt install -V -y ruby-dev git build-essential pkg-config libyaml-dev
apt install -V -y libcap-ng-dev
cd /capng && \
gem install bundler --no-document && \
gem install bundler -v 2.3.27 --no-document && \
bundle install && \
bundle exec rake
9 changes: 8 additions & 1 deletion ci/yum-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ case ${distribution} in
;;
esac
;;
rocky)
DNF="dnf --enablerepo=powertools"
;;
almalinux)
DNF="dnf --enablerepo=crb"
;;
esac

${DNF} groupinstall -y "Development Tools"
Expand All @@ -53,12 +59,13 @@ else
rubygems \
rpm-build
fi
${DNF} install -y libyaml-devel
${DNF} install -y libcap-ng-devel

if [ $USE_SCL -eq 1 ]; then
# For unbound variable error
export MANPATH=
cd /capng && source /opt/rh/rh-ruby26/enable && gem install bundler --no-document && bundle install && bundle exec rake
else
cd /capng && gem install bundler --no-document && bundle install && bundle exec rake
cd /capng && gem install bundler -v 2.3.27 --no-document && bundle install && bundle exec rake
fi
21 changes: 15 additions & 6 deletions ext/capng/capng.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ rb_capng_alloc(VALUE klass)
return obj;
}

static int
capng_get_file_descriptor(VALUE rb_file)
{
#ifdef HAVE_RB_IO_DESCRIPTOR
return rb_io_descriptor(rb_file);
#else
rb_io_t* fptr = NULL;

fptr = RFILE(rb_file)->fptr;
return fptr->fd;
#endif
}

/*
* Initalize CapNG class.
*
Expand Down Expand Up @@ -500,15 +513,13 @@ static VALUE
rb_capng_get_caps_file(VALUE self, VALUE rb_file)
{
int result = 0, fd = 0;
rb_io_t* fptr = NULL;

Check_Type(rb_file, T_FILE);

if (NIL_P(rb_file)) {
return Qfalse;
}
fptr = RFILE(rb_file)->fptr;
fd = fptr->fd;
fd = capng_get_file_descriptor(rb_file);
result = capng_get_caps_fd(fd);

if (result == 0)
Expand All @@ -529,16 +540,14 @@ static VALUE
rb_capng_apply_caps_file(VALUE self, VALUE rb_file)
{
int result = 0, fd = 0;
rb_io_t* fptr = NULL;

Check_Type(rb_file, T_FILE);

if (NIL_P(rb_file)) {
return Qfalse;
}

fptr = RFILE(rb_file)->fptr;
fd = fptr->fd;
fd = capng_get_file_descriptor(rb_file);
result = capng_apply_caps_fd(fd);

if (result == 0)
Expand Down
1 change: 1 addition & 0 deletions ext/capng/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
have_const("CAPNG_AMBIENT", "cap-ng.h")
have_const("CAPNG_INIT_SUPP_GRP", "cap-ng.h")
have_func("rb_sym2str", "ruby.h")
have_func("rb_io_descriptor", "ruby.h")
have_func("capng_get_caps_fd", "cap-ng.h")
create_makefile("capng/capng")
Loading