Skip to content

Commit

Permalink
WIP: do not empty home when reusing
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Sep 24, 2021
1 parent 94c84a7 commit dcfdd07
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/lib/y2users/commit_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CommitConfig
# Whether the home should be empty after the creation (i.e., do not use skels)
#
# @return [Boolean]
attr_writer :empty_home
attr_writer :home_without_skel

# Whether to move the content of the current home directory to the new location
#
Expand All @@ -46,8 +46,8 @@ class CommitConfig
attr_writer :adapt_home_ownership

# @return [Boolean]
def empty_home?
!!@empty_home
def home_without_skel?
!!@home_without_skel
end

# @return [Boolean]
Expand Down
3 changes: 2 additions & 1 deletion src/lib/y2users/linux/users_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ def create_user(user, issues)
# @param user [User] the user to be created on the system
# @param issues [Y2Issues::List] a collection for adding an issue if something goes wrong
def try_create_user(user, issues)
reusing_home = exist_user_home?(user)
Yast::Execute.on_target!(USERADD, *useradd_options(user))
clear_home(user, issues) if commit_config(user).empty_home?
clear_home(user, issues) if !reusing_home && commit_config(user).home_without_skel?
chown_home(user, issues) if commit_config(user).adapt_home_ownership?
rescue Cheetah::ExecutionFailed => e
raise(e) unless e.status.exitstatus == USERADD_E_HOMEDIR
Expand Down
2 changes: 1 addition & 1 deletion src/lib/y2users/users_module/commit_config_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def users
def commit_config(user)
CommitConfig.new.tap do |config|
config.username = user["uid"]
config.empty_home = user["no_skeleton"]
config.home_without_skel = user["no_skeleton"]
config.move_home = move_home?(user)
config.adapt_home_ownership = user["chown_home"]
end
Expand Down

0 comments on commit dcfdd07

Please sign in to comment.