commit
0945008e5e
59
basic_test.rb
Normal file
59
basic_test.rb
Normal file
@ -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
|
||||
|
||||
16
ruby-shadow-2.5.0-cflags.patch
Normal file
16
ruby-shadow-2.5.0-cflags.patch
Normal file
@ -0,0 +1,16 @@
|
||||
--- extconf.rb~ 2017-10-05 20:21:59.480315863 +0200
|
||||
+++ extconf.rb 2017-10-05 20:23:55.077931560 +0200
|
||||
@@ -6,12 +6,7 @@
|
||||
|
||||
require 'mkmf'
|
||||
require 'rbconfig'
|
||||
-
|
||||
-$CFLAGS = case RUBY_VERSION
|
||||
- when /^1\.9/; '-DRUBY19'
|
||||
- when /^2\./; '-DRUBY19'
|
||||
- else; ''
|
||||
- end
|
||||
+$CFLAGS = "#{$CFLAGS} -DRUBY19"
|
||||
|
||||
implementation = case CONFIG['host_os']
|
||||
when /linux/i; 'shadow'
|
||||
BIN
ruby-shadow-2.5.0.gem
Normal file
BIN
ruby-shadow-2.5.0.gem
Normal file
Binary file not shown.
74
rubygem-ruby-shadow.spec
Normal file
74
rubygem-ruby-shadow.spec
Normal file
@ -0,0 +1,74 @@
|
||||
%global gem_name ruby-shadow
|
||||
Name: rubygem-%{gem_name}
|
||||
Version: 2.5.0
|
||||
Release: 1
|
||||
Summary: Ruby shadow password module
|
||||
License: Public Domain
|
||||
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
|
||||
Patch0: ruby-shadow-2.5.0-cflags.patch
|
||||
BuildRequires: gcc ruby(release) rubygems-devel ruby-devel 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
|
||||
gem unpack %{SOURCE0}
|
||||
%setup -q -D -T -n %{gem_name}-%{version}
|
||||
gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
|
||||
%patch0 -p0
|
||||
cp %{SOURCE1} .
|
||||
|
||||
%build
|
||||
export CONFIGURE_ARGS="--with-cflags='%{optflags}'"
|
||||
gem build %{gem_name}.gemspec
|
||||
%gem_install
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}%{gem_dir}
|
||||
cp -a .%{gem_dir}/* %{buildroot}%{gem_dir}/
|
||||
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}/
|
||||
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
|
||||
* Tue Jul 28 2020 shaoqiang kang <kangshaoqiang1@huawei.com> - 2.5.0-1
|
||||
- Package init
|
||||
5
rubygem-ruby-shadow.yaml
Normal file
5
rubygem-ruby-shadow.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
git_url: https://github.com/apalmblad/ruby-shadow
|
||||
version_control: github
|
||||
src_repo: apalmblad/ruby-shadow
|
||||
tag_prefix: "^"
|
||||
seperator: "."
|
||||
Loading…
x
Reference in New Issue
Block a user