diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..08ccffa --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/ruby-shadow-*.gem diff --git a/README.md b/README.md deleted file mode 100644 index 7856f90..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# rubygem-ruby-shadow - -The rubygem-ruby-shadow package \ No newline at end of file diff --git a/basic_test.rb b/basic_test.rb new file mode 100644 index 0000000..34cc580 --- /dev/null +++ b/basic_test.rb @@ -0,0 +1,59 @@ +require 'test/unit' +require 'rubygems' +require 'shadow' +require 'stringio' +class RubyShadowTest < Test::Unit::TestCase + STRUCT_METHODS = %w( sp_namp sp_pwdp sp_lstchg sp_min sp_max sp_warn sp_inact sp_expire sp_loginclass ) + # --------------------------------------------------- test_smoke_test_getspent + def test_smoke_test_getspent + x = Shadow::Passwd.getspent + assert( x, "ensure you have permissions to check this (sudo?)" ) + check_struct( x ) + end + # ----------------------------------------------------- test_getspnam_for_user + def test_getspnam_for_user + user = `whoami`.strip + x = Shadow::Passwd.getspnam( user ) + assert( x, "ensure you have permissions to check this (sudo?)" ) + check_struct( x ) + end + # ---------------------------------------- test_getspnam_for_non_existent_user + def test_getspnam_for_non_existent_user + assert_nil( Shadow::Passwd.getspnam( 'somebadusername' ) ) + end + # -------------------------------------------------------------- test_putspent + def test_putspent + omit_if( Shadow::IMPLEMENTATION != 'SHADOW' ) if respond_to?( :omit_if ) + #result = StringIO.open( '', 'w' ) do |fh| + File.open( 'test_password', 'w' ) do |fh| + Shadow::Passwd.add_password_entry( sample_entry, fh ) + end + assert( File.read( 'test_password' ).match( sample_entry.first ) ) + end + # --------------------------------------------------------------- check_struct + def check_struct( s ) + STRUCT_METHODS.each do |m| + s.send( m ) + end + end + # ----------------------------------------------------------------- test_entry + def sample_entry( &block ) + return ['test_user', # sp_namp + 'new_pass', # sp_pwdp + 0, #sp_lastchg + 0, #sp_min + 0, #sp_max + 0, #sp_warn + 0, #sp_inact + 0, #???? + 0, #sp_expire + 0 # sp_flag + ] + e = Shadow::Passwd::Entry.new + e.sp_namp = 'test_user' + e.sp_pwdp = 'password' + yield e if block_given? + return e + end +end + diff --git a/ruby-shadow-2.5.1-cflags.patch b/ruby-shadow-2.5.1-cflags.patch new file mode 100644 index 0000000..6c0a474 --- /dev/null +++ b/ruby-shadow-2.5.1-cflags.patch @@ -0,0 +1,11 @@ +--- ruby-shadow-2.5.1/extconf.rb.orig 2022-11-30 15:03:24.946310154 +0900 ++++ ruby-shadow-2.5.1/extconf.rb 2022-11-30 15:04:27.984276887 +0900 +@@ -7,7 +7,7 @@ + require 'mkmf' + require 'rbconfig' + +-$CFLAGS = case RUBY_VERSION ++$CFLAGS = "#{$CFLAGS} " + case RUBY_VERSION + when /^1\.9/; '-DRUBY19' + when /^2\./; '-DRUBY19' + when /^[34]\./; '-DRUBY19 -DRUBY30' diff --git a/ruby-shadow-2.5.1-extconf-ruby32-fix.patch b/ruby-shadow-2.5.1-extconf-ruby32-fix.patch new file mode 100644 index 0000000..73cf451 --- /dev/null +++ b/ruby-shadow-2.5.1-extconf-ruby32-fix.patch @@ -0,0 +1,29 @@ +commit eab4aba3f5e06ea8f124d3e5ff6b3fa88c4807cd +Author: Mamoru TASAKA +Date: Thu Dec 1 12:23:05 2022 +0900 + + extconf.rb: use Rbconfig::CONFIG instead of mkmf CONFIG + + In mkmf.rb CONFIG is defined as CONFIG is defined as RbConfig::MAKEFILE_CONFIG + and RbConfig::MAKEFILE_CONFIG is almost same as RbConfig::CONFIG + except that RbConfig::MAKEFILE_CONFIG uses reference for other variables. + + Using CONFIG in extconf.rb causes error with ruby3.2 because now + CONFIG['host_os'] uses reference for target_os variable, and extconf.rb + expects that this variable is all expanded. So instead, use RbConfig::CONFIG . + + Closes #30 + +diff --git a/extconf.rb b/extconf.rb +index d17f926..55dcff5 100644 +--- a/extconf.rb ++++ b/extconf.rb +@@ -14,7 +14,7 @@ $CFLAGS = case RUBY_VERSION + else; '' + end + +-implementation = case CONFIG['host_os'] ++implementation = case RbConfig::CONFIG['host_os'] + when /linux/i; 'shadow' + when /sunos|solaris/i; 'shadow' + when /freebsd|mirbsd|netbsd|openbsd/i; 'pwd' diff --git a/ruby-shadow-2.5.1-taintedness-ruby32-removal.patch b/ruby-shadow-2.5.1-taintedness-ruby32-removal.patch new file mode 100644 index 0000000..737f08b --- /dev/null +++ b/ruby-shadow-2.5.1-taintedness-ruby32-removal.patch @@ -0,0 +1,72 @@ +commit 7b450355b540df43bab2617fe25437dc3dde12af +Author: Mamoru TASAKA +Date: Thu Dec 1 12:54:31 2022 +0900 + + Replace taintedness function with generic one + + Taintedness is deprecated from ruby 2.7.0 and is removed on ruby3.2.0preview3. + To keep compatibility with ruby older than 2.7, introduce -DRUBY30 compilation + flag from ruby3.0 and onwards, and replace taintedness function with generic one + when RUBY30 is defined (i.e. from ruby3.0 and onwards) + +diff --git a/extconf.rb b/extconf.rb +index d17f926..04f8f97 100644 +--- a/extconf.rb ++++ b/extconf.rb +@@ -10,7 +10,7 @@ require 'rbconfig' + $CFLAGS = case RUBY_VERSION + when /^1\.9/; '-DRUBY19' + when /^2\./; '-DRUBY19' +- when /^3\./; '-DRUBY19' ++ when /^[34]\./; '-DRUBY19 -DRUBY30' + else; '' + end + +diff --git a/pwd/shadow.c b/pwd/shadow.c +index eeb96d4..e73e0db 100644 +--- a/pwd/shadow.c ++++ b/pwd/shadow.c +@@ -56,8 +56,13 @@ static VALUE convert_pw_struct( struct passwd *entry ) + { + /* Hmm. Why custom pw_change instead of sp_lstchg? */ + return rb_struct_new(rb_sPasswdEntry, ++#if defined(RUBY30) ++ rb_str_new2(entry->pw_name), /* sp_namp */ ++ rb_str_new2(entry->pw_passwd), /* sp_pwdp, encryped password */ ++#else + rb_tainted_str_new2(entry->pw_name), /* sp_namp */ + rb_tainted_str_new2(entry->pw_passwd), /* sp_pwdp, encryped password */ ++#endif + Qnil, /* sp_lstchg, date when the password was last changed (in days since Jan 1, 1970) */ + Qnil, /* sp_min, days that password must stay same */ + Qnil, /* sp_max, days until password changes. */ +@@ -66,7 +71,11 @@ static VALUE convert_pw_struct( struct passwd *entry ) + INT2FIX(difftime(entry->pw_change, 0) / (24*60*60)), /* pw_change */ + INT2FIX(difftime(entry->pw_expire, 0) / (24*60*60)), /* sp_expire */ + Qnil, /* sp_flag */ ++#if defined(RUBY30) ++ rb_str_new2(entry->pw_class), /* sp_loginclass, user access class */ ++#else + rb_tainted_str_new2(entry->pw_class), /* sp_loginclass, user access class */ ++#endif + NULL); + } + +diff --git a/shadow/shadow.c b/shadow/shadow.c +index 35a77a1..5202ce5 100644 +--- a/shadow/shadow.c ++++ b/shadow/shadow.c +@@ -34,8 +34,13 @@ static VALUE rb_eFileLock; + static VALUE convert_pw_struct( struct spwd *entry ) + { + return rb_struct_new(rb_sPasswdEntry, ++#if defined(RUBY30) ++ rb_str_new2(entry->sp_namp), ++ rb_str_new2(entry->sp_pwdp), ++#else + rb_tainted_str_new2(entry->sp_namp), + rb_tainted_str_new2(entry->sp_pwdp), ++#endif + INT2FIX(entry->sp_lstchg), + INT2FIX(entry->sp_min), + INT2FIX(entry->sp_max), diff --git a/rubygem-ruby-shadow.spec b/rubygem-ruby-shadow.spec new file mode 100644 index 0000000..4d9b04a --- /dev/null +++ b/rubygem-ruby-shadow.spec @@ -0,0 +1,221 @@ +%global gem_name ruby-shadow + +Name: rubygem-%{gem_name} +Version: 2.5.1 +Release: 14%{?dist} +Summary: Ruby shadow password module +License: LicenseRef-Fedora-UltraPermissive OR Unlicense +URL: https://github.com/apalmblad/ruby-shadow +Source0: http://rubygems.org/gems/%{gem_name}-%{version}.gem +Source1: https://raw.githubusercontent.com/apalmblad/ruby-shadow/master/test/basic_test.rb +# https://github.com/apalmblad/ruby-shadow/pull/29 +# Ruby3.2 completely removes taintedness function +Patch0: ruby-shadow-2.5.1-taintedness-ruby32-removal.patch +# https://github.com/apalmblad/ruby-shadow/pull/31 +# Ruby3.2 mkmf CONFIG uses reference for other variables yet more +Patch1: ruby-shadow-2.5.1-extconf-ruby32-fix.patch +Patch2: ruby-shadow-2.5.1-cflags.patch +BuildRequires: gcc +BuildRequires: ruby(release) +BuildRequires: rubygems-devel +BuildRequires: ruby-devel +BuildRequires: rubygem(minitest) +BuildRequires: rubygem(test-unit) +Obsoletes: ruby-shadow < 1.4.1-36 +Provides: ruby-shadow = %{version}-%{release} +Provides: ruby(shadow) = %{version} +%description +This module provides access to shadow passwords on Linux and Solaris. + +%package doc +Summary: Documentation for %{name} +Requires: %{name} = %{version}-%{release} +BuildArch: noarch +%description doc +Documentation for %{name}. + +%prep +%autosetup -p1 -n %{gem_name}-%{version} +cp %{SOURCE1} . + +%build +export CONFIGURE_ARGS="--with-cflags='%{optflags} -Werror=implicit-function-declaration'" +gem build ../%{gem_name}-%{version}.gemspec + +# %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir +# by default, so that we can move it into the buildroot in %%install +%gem_install + +%install +mkdir -p %{buildroot}%{gem_dir} +cp -a .%{gem_dir}/* %{buildroot}%{gem_dir}/ + +# two identical so files confuses rpmbuild +find %{buildroot}%{gem_dir}/ -name \*.so -delete + +mkdir -p %{buildroot}%{gem_extdir_mri} +cp -a .%{gem_extdir_mri}/{gem.build_complete,*.so} %{buildroot}%{gem_extdir_mri}/ + +# Prevent dangling symlink in -debuginfo (rhbz#878863). +rm -rf %{buildroot}%{gem_instdir}/ext/ + +%check +cp %{SOURCE1} .%{gem_instdir} +pushd .%{gem_instdir} +if [ $(id -u) = 0 ]; then + ruby -I. -e 'Dir.glob "*_test.rb", &method(:require)' +else + ruby -I. -e 'Dir.glob "*_test.rb", &method(:require)' || : +fi +popd + +%files +%dir %{gem_instdir} +%{gem_extdir_mri} +%{gem_instdir}/%{gem_name}.gemspec +%exclude %{gem_instdir}/.* +%license %{gem_instdir}/LICENSE +%exclude %{gem_cache} +%{gem_spec} + +%files doc +%doc %{gem_docdir} +%exclude %{gem_instdir}/* +%doc %{gem_instdir}/HISTORY +%doc %{gem_instdir}/README +%doc %{gem_instdir}/README.euc + +%changelog +* Thu Jan 08 2026 Mamoru TASAKA - 2.5.1-14 +- Rebuild for https://fedoraproject.org/wiki/Changes/Ruby_4.0 + +* Sat Nov 08 2025 Mamoru TASAKA - 2.5.1-13 +- Adjust patches for ruby4_0 + +* Fri Jul 25 2025 Fedora Release Engineering - 2.5.1-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Sat Jan 18 2025 Fedora Release Engineering - 2.5.1-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Wed Jan 08 2025 Mamoru TASAKA - 2.5.1-10 +- Rebuild for https://fedoraproject.org/wiki/Changes/Ruby_3.4 + +* Fri Jul 19 2024 Fedora Release Engineering - 2.5.1-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Mon Jul 01 2024 Terje Rosten - 2.5.0-8 +- Use autosetup macro + +* Fri Jan 26 2024 Fedora Release Engineering - 2.5.1-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Wed Jan 03 2024 Vít Ondruch - 2.5.1-6 +- Rebuilt for https://fedoraproject.org/wiki/Changes/Ruby_3.3 + +* Fri Jul 21 2023 Fedora Release Engineering - 2.5.1-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Fri Jan 20 2023 Fedora Release Engineering - 2.5.1-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Wed Jan 04 2023 Mamoru TASAKA - 2.5.1-3 +- Rebuild for https://fedoraproject.org/wiki/Changes/Ruby_3.2 + +* Thu Dec 1 2022 Mamoru TASAKA - 2.5.1-2 +- Backport upstream pull request for ruby3.2 build issue +- Add -Werror=implicit-function explicitly to detect such function + +* Thu Dec 1 2022 Mamoru TASAKA - 2.5.1-1 +- 2.5.1 + +* Sat Jul 23 2022 Fedora Release Engineering - 2.5.0-19 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Wed Jan 26 2022 Vít Ondruch - 2.5.0-18 +- Rebuilt for https://fedoraproject.org/wiki/Changes/Ruby_3.1 + +* Fri Jan 21 2022 Fedora Release Engineering - 2.5.0-17 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Fri Jul 23 2021 Fedora Release Engineering - 2.5.0-16 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Wed Jan 27 2021 Fedora Release Engineering - 2.5.0-15 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Wed Jan 6 2021 Vít Ondruch - 2.5.0-14 +- Rebuilt for https://fedoraproject.org/wiki/Changes/Ruby_3.0 + +* Wed Jul 29 2020 Fedora Release Engineering - 2.5.0-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Thu Jan 30 2020 Fedora Release Engineering - 2.5.0-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Fri Jan 17 2020 Mamoru TASAKA - 2.5.0-11 +- F-32: rebuild against ruby27 + +* Fri Jul 26 2019 Fedora Release Engineering - 2.5.0-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Sat Feb 02 2019 Fedora Release Engineering - 2.5.0-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Thu Jan 17 2019 Vít Ondruch - 2.5.0-8 +- Rebuilt for https://fedoraproject.org/wiki/Changes/Ruby_2.6 + +* Sun Jul 15 2018 Terje Rosten - 2.5.0-7 +- Add C compiler + +* Sat Jul 14 2018 Fedora Release Engineering - 2.5.0-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Fri Feb 09 2018 Fedora Release Engineering - 2.5.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Sat Jan 20 2018 Björn Esser - 2.5.0-4 +- Rebuilt for switch to libxcrypt + +* Thu Jan 04 2018 Mamoru TASAKA - 2.5.0-3 +- F-28: rebuild for ruby25 + +* Mon Oct 09 2017 Terje Rosten - 2.5.0-2 +- Remove group +- Run tests + +* Thu Oct 05 2017 Terje Rosten - 2.5.0-1 +- 2.5.0 +- Remove non Fedora support +- Simplify + +* Fri Mar 01 2013 Moses Mendoza - 2.2.0-1 +- Update to upstream 2.2.0 +- Move gem path macro definitions inside rhel5 macro block +- Install only files we want rather than removing files we dont +- Remove extraneous case in spec for gem_instdir/*.so +- Move gemspec(s) into docs package + +* Mon Nov 05 2012 Moses Mendoza - 2.1.4-1 +- Update to 2.1.4 +- Dynamically define gem_dir macro +- Use ruby_sitearch macro for EPEL, fedora < 17 + +* Tue Apr 17 2012 Todd Zullinger - 2.1.3-2 +- Use gem_extdir macro on F-17 and above + +* Fri Apr 06 2012 Todd Zullinger - 2.1.3-1 +- Update to 2.1.3 +- Fix license tag + +* Sun Apr 01 2012 Todd Zullinger - 2.1.2-3 +- Revert gem repacking until ruby guidelines are finalized +- Only define gem macros for EPEL, all Fedora releases have them +- Add BuildRoot and clean it manually for EL-5 + +* Thu Feb 16 2012 Todd Zullinger - 2.1.2-2 +- Minor cleanups for review +- Changes for building on EL-6 (EL-5s rubygems is too old) + +* Mon Jan 16 2012 Michael Stahnke - 2.1.2-1 +- Initial package diff --git a/sources b/sources new file mode 100644 index 0000000..ca6544d --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (ruby-shadow-2.5.1.gem) = 401ba31f6f87b9b50597e3924c67ef9d0a8f566ea4649735caf59e2b706861babf9b3aa273b7c47ca1cc9c8b4fde79ab21d2e264cd7ba58041fe7b8f9fd87411