Skip to content

Commit 0a32946

Browse files
Use klist -s to status credentials cache (#266)
This patch changes `klist` to `klist -s` so that it returns `1` when the credentials cache cannot be read or is expired, thereby triggering kinit. Co-authored-by: Trevor Vaughan <trevor@sicura.us>
1 parent b241d7a commit 0a32946

5 files changed

Lines changed: 10 additions & 6 deletions

File tree

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Thu Dec 16 2021 ke5C2Fin <noreply@github.com> - 4.10.2
2+
- Fixed
3+
- Call `klist -s` instead of `klist` to properly handle cache issues
4+
15
* Thu Sep 23 2021 Trevor Vaughan <tvaughan@onyxpoint.com> - 4.10.1
26
- Fixed
37
- Increased randomization in simplib::gen_random_password

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ group :test do
2424
gem 'puppet-lint-empty_string-check', :require => false
2525
gem 'puppet-lint-trailing_comma-check', :require => false
2626
gem 'simp-rspec-puppet-facts', ENV['SIMP_RSPEC_PUPPET_FACTS_VERSION'] || '~> 3.1'
27-
gem 'simp-rake-helpers', ENV['SIMP_RAKE_HELPERS_VERSION'] || ['>= 5.12.1', '< 6']
27+
gem 'simp-rake-helpers', ENV['SIMP_RAKE_HELPERS_VERSION'] || ['>= 5.12.7', '< 6']
2828
gem( 'pdk', ENV['PDK_VERSION'] || '~> 2.0', :require => false) if major_puppet_version > 5
2929
gem 'pathspec', '~> 0.2' if Gem::Requirement.create('< 2.6').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
3030
end

lib/facter/ipa.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
# We won't know if we are connected to a server until later
7070
defaults['connected'] = false
7171

72-
Facter::Core::Execution.execute(klist)
72+
Facter::Core::Execution.execute("#{klist} -s")
7373
unless $?.success?
7474
# Obtain host Kerberos token so we can use IPA API
7575
kinit_msg = Facter::Core::Execution.execute("#{kinit} -k 2>&1", options = {:timeout => kinit_timeout})

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simp-simplib",
3-
"version": "4.10.1",
3+
"version": "4.10.2",
44
"author": "SIMP Team",
55
"summary": "A collection of common SIMP functions, facts, and types",
66
"license": "Apache-2.0",

spec/unit/facter/ipa_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
it 'should execute only ipa commands and report local env + connected status' do
7777
expect(File).to receive(:exist?).with('/etc/ipa/default.conf').and_return(true)
7878
expect(File).to receive(:read).with('/etc/ipa/default.conf').and_return(default_conf)
79-
expect(Facter::Core::Execution).to receive(:execute).with('/usr/bin/klist')
79+
expect(Facter::Core::Execution).to receive(:execute).with('/usr/bin/klist -s')
8080
allow_any_instance_of(Process::Status).to receive(:success?).and_return(true)
8181
expect(Facter::Core::Execution).to receive(:execute).with(ipa_env_query, ipa_query_options).and_return(ipa_env)
8282
expect(Facter::Core::Execution).to receive(:execute).with(ipa_env_server_query, ipa_query_options).and_return(ipa_server_env)
@@ -94,7 +94,7 @@
9494
it 'should execute kinit + ipa commands and return local env + connected status' do
9595
expect(File).to receive(:exist?).with('/etc/ipa/default.conf').and_return(true)
9696
expect(File).to receive(:read).with('/etc/ipa/default.conf').and_return(default_conf)
97-
expect(Facter::Core::Execution).to receive(:execute).with('/usr/bin/klist')
97+
expect(Facter::Core::Execution).to receive(:execute).with('/usr/bin/klist -s')
9898
allow_any_instance_of(Process::Status).to receive(:success?).and_return(false)
9999
expect(Facter::Core::Execution).to receive(:execute).with('/usr/bin/kinit -k 2>&1', kinit_query_options).and_return('')
100100
expect(Facter::Core::Execution).to receive(:execute).with( ipa_env_query, ipa_query_options).and_return(ipa_env)
@@ -114,7 +114,7 @@
114114
it 'should return defaults from /etc/ipa/default.conf and disconnected status' do
115115
expect(File).to receive(:exist?).with('/etc/ipa/default.conf').and_return(true)
116116
expect(File).to receive(:read).with('/etc/ipa/default.conf').and_return(default_conf)
117-
expect(Facter::Core::Execution).to receive(:execute).with('/usr/bin/klist')
117+
expect(Facter::Core::Execution).to receive(:execute).with('/usr/bin/klist -s')
118118
allow_any_instance_of(Process::Status).to receive(:success?).and_return(false)
119119
expect(Facter::Core::Execution).to receive(:execute).with('/usr/bin/kinit -k 2>&1', kinit_query_options).and_return('some error message')
120120
expect(Facter::Core::Execution).to receive(:execute).with(ipa_env_query, ipa_query_options).and_return('')

0 commit comments

Comments
 (0)