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

bsc#1184131: use /etc/login.defs for shadow configuration #1152

Merged
merged 7 commits into from Apr 13, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions library/general/src/lib/cfa/login_defs.rb
Expand Up @@ -65,6 +65,8 @@ class LoginDefs < BaseModel
:userdel_precmd
].freeze

DEFAULT_PATH = "/etc/login.defs".freeze

class << self
# Returns the list of known attributes
#
Expand All @@ -80,7 +82,7 @@ def known_attributes
# @param file_handler [#read,#write] something able to read/write a string (like File)
# @param file_path [String] File path
# @return [LoginDefs] File with the already loaded content
def load(file_path:, file_handler: Yast::TargetFile)
def load(file_path: DEFAULT_PATH, file_handler: Yast::TargetFile)
new(file_path: file_path, file_handler: file_handler).tap(&:load)
end
end
Expand All @@ -98,7 +100,7 @@ def load(file_path:, file_handler: Yast::TargetFile)
# @param file_path [String] File path
#
# @see CFA::BaseModel#initialize
def initialize(file_path:, file_handler: Yast::TargetFile)
def initialize(file_path: DEFAULT_PATH, file_handler: Yast::TargetFile)
super(AugeasParser.new("login_defs.lns"), file_path, file_handler: file_handler)
end

Expand Down
44 changes: 0 additions & 44 deletions library/general/src/lib/cfa/shadow_config.rb

This file was deleted.

7 changes: 4 additions & 3 deletions library/general/src/modules/ShadowConfig.rb
Expand Up @@ -18,13 +18,14 @@
# find current contact information at www.suse.com.

require "yast"
require "cfa/shadow_config"
require "cfa/login_defs"

module Yast
# This class allows to access the API to handle login.defs attributes from Perl
#
# In SLE 15 SP2, it relies on CFA::LoginDefs instead of CFA::ShadowConfig like later versions.
lslezak marked this conversation as resolved.
Show resolved Hide resolved
#
# @see CFA::LoginDefs
# @see CFA::ShadowConfig
class ShadowConfigClass < Module
include Logger

Expand Down Expand Up @@ -101,7 +102,7 @@ def check_attribute(attr)
def config
return @config if @config

@config = CFA::ShadowConfig.new
@config = CFA::LoginDefs.new
@config.load
@config
end
Expand Down
18 changes: 18 additions & 0 deletions library/general/test/cfa/login_defs_test.rb
Expand Up @@ -90,4 +90,22 @@
end
end
end

describe "#present_attributes" do
it "returns the list of present attributes" do
expect(login_defs.present_attributes).to include(*ATTRS_VALUES.keys)
end
end

describe "#conflicts" do
subject(:other) { described_class.new(file_path: file_path, file_handler: file_handler) }

before do
other.encrypt_method = "SHA256"
end

it "returns the list of attributes with different values" do
expect(login_defs.conflicts(other)).to eq([:encrypt_method])
end
end
end
164 changes: 0 additions & 164 deletions library/general/test/cfa/shadow_config_test.rb

This file was deleted.

1 change: 0 additions & 1 deletion library/general/test/data/login.defs/custom/etc/login.defs

This file was deleted.

This file was deleted.

This file was deleted.