diff --git a/VERSION b/VERSION index fd2a01863..94ff29cc4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.0 +3.1.1 diff --git a/package/yast2-users.changes b/package/yast2-users.changes index 137aad6c0..7d16827b9 100644 --- a/package/yast2-users.changes +++ b/package/yast2-users.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Oct 30 14:09:52 UTC 2013 - lslezak@suse.cz + +- do not save the data for the 2nd stage, create the users + in the 1st stage directly +- 3.1.1 + ------------------------------------------------------------------- Thu Sep 19 17:45:35 UTC 2013 - lslezak@suse.cz diff --git a/src/clients/users_finish.rb b/src/clients/users_finish.rb index 6b4ac4c4e..3ebbe2bc5 100644 --- a/src/clients/users_finish.rb +++ b/src/clients/users_finish.rb @@ -31,9 +31,12 @@ class UsersFinishClient < Client def main textdomain "users" + Yast.import "Users" Yast.import "UsersSimple" - @ret = nil + # GetInt() + Yast.include self, "users/routines.rb" + @func = "" @param = {} @@ -59,15 +62,53 @@ def main "when" => [:installation, :live_installation, :autoinst] } elsif @func == "Write" + # disable UI (progress) + Users.SetGUI(false) + + # write the root password UsersSimple.Write + + # import the users (TODO FIXME: taken from inst_user.rb, share the code somehow??) + @users = UsersSimple.GetUsers + + if !@users.empty? + Users.Read + Users.ResetCurrentUser + Builtins.y2milestone("There are %1 users to import", @users.size) + + @users.each do |user| + Ops.set(user, "encrypted", true) + # check if default group exists + if Builtins.haskey(user, "gidNumber") + g = Users.GetGroup(GetInt(Ops.get(user, "gidNumber"), -1), "") + if g == {} + g = Users.GetGroupByName( + Ops.get_string(user, "groupname", ""), + "" + ) + if g != {} + Ops.set(user, "gidNumber", Ops.get_integer(g, "gidNumber", -1)) + else + user = Builtins.remove(user, "gidNumber") + end + end + end + + error = Users.AddUser(user) + Builtins.y2error("error while adding user: %1", error) if error != "" + error = Users.CheckUser({}) + Builtins.y2error("error while adding user: %1", error) if error != "" + Users.CommitUser + end + + Users.Write + end else Builtins.y2error("unknown function: %1", @func) - @ret = nil end - Builtins.y2debug("ret=%1", @ret) Builtins.y2milestone("users_finish finished") - deep_copy(@ret) + nil end end end diff --git a/src/modules/Users.pm b/src/modules/Users.pm index 2f93575d6..25e515d36 100644 --- a/src/modules/Users.pm +++ b/src/modules/Users.pm @@ -4803,8 +4803,6 @@ sub Write { $users_modified = 0; $groups_modified = 0; - sleep (1); - return $ret; } diff --git a/src/modules/UsersSimple.pm b/src/modules/UsersSimple.pm index 1a0c2b818..4bf4d4147 100644 --- a/src/modules/UsersSimple.pm +++ b/src/modules/UsersSimple.pm @@ -125,9 +125,6 @@ my $import_available; # if check for LDAP/Kerberos via DNS was done my $network_methods_checked = 0; -# prevent re-reading data map with 1st stage settingss -my $first_stage_data_not_read = 1; - # note if users configuration should be run or skipped in 2nd stage (bnc#450231) my $skip_user_creation = 0; @@ -901,107 +898,27 @@ sub GetSystemUserNames { ##--------------------------------------------------------------------------- ## Read/Write functions -# Writes the settings configured in 1st stage +# Writes the root password configured in the 1st stage BEGIN { $TYPEINFO{Write} = ["function", "boolean"];} sub Write { - my $self = shift; - my $user_defined = 0; - foreach my $user (@users) { - if (defined $user->{"userPassword"}) { - if (!defined $user->{"__imported"}) { - $user->{"userPassword"} = - $self->CryptPassword($user->{"userPassword"}); - } - $user->{"encrypted"} = YaST::YCP::Integer (1); - } - $user_defined = 1; - } - my %data = ( - "after_auth" => $after_auth, - "run_krb_config" => YaST::YCP::Integer ($run_krb_config), - "users" => \@users, - "encryption_method" => $encryption_method, - "root_alias" => $root_alias, - "autologin_user" => $autologin_user - ); - if ($root_password) { - # indication to inst_root - $data{"root_password_written"} = YaST::YCP::Integer (1); - } - my $file = Directory->vardir()."/users_first_stage.ycp"; - my $ret = SCR->Write (".target.ycp", $file, \%data); - - y2milestone ("1st stage user information written: ", $ret); - # make the file root only readable - SCR->Execute (".target.bash", "chmod 600 $file") if ($ret); - - my $redraw = 0; if ($root_password) { # write root password now - $self->WriteRootPassword (); - } - else { - y2milestone ("enabling step 'root' for second stage"); - ProductControl->EnableModule ("root"); - } - # enable inst_user to either run auth client or write first user - if ($after_auth ne "users" || $user_defined) { - # do not let both steps to run (bnc#672139) - if ($user_defined) { - y2milestone ("enabling 'user_non_interactive', disabling 'user' for second stage"); - ProductControl->EnableModule ("user_non_interactive"); - ProductControl->DisableModule ("user"); - } - else { - y2milestone ("enabling 'user', disabling 'user_non_interactive' for second stage"); - ProductControl->EnableModule ("user"); - ProductControl->DisableModule ("user_non_interactive"); - } - } - # no user entered + 2nd stage visible => enable clients (bnc#393722) - elsif (!ProductControl->GetUseAutomaticConfiguration ()) { - y2milestone ("enabling steps 'auth' and 'user' for second stage"); - ProductControl->EnableModule ("auth"); - ProductControl->EnableModule ("user"); + return $self->WriteRootPassword (); } - return $ret; + return bool (1); } -# Read the settings configured in 1st stage +# Empty function (kept for backward compatibility) BEGIN { $TYPEINFO{Read} = ["function", "boolean", "boolean"];} sub Read { my $self = shift; my $force = shift; - my $file = Directory->vardir()."/users_first_stage.ycp"; - my $ret = 0; - if (Stage->cont () && FileUtils->Exists ($file) && - ($force || $first_stage_data_not_read)) - { - my $data = SCR->Read (".target.ycp", $file); - $first_stage_data_not_read = 0; - if (defined $data && ref ($data) eq "HASH") { - - $autologin_user = $data->{"autologin_user"} || ""; - $root_alias = $data->{"root_alias"} || ""; - $after_auth = $data->{"after_auth"} || $after_auth; - $encryption_method = - $data->{"encryption_method"} || $encryption_method; - $run_krb_config = bool ($data->{"run_krb_config"}); - if (ref ($data->{"users"}) eq "ARRAY") { - @users = @{$data->{"users"}}; - } - $root_password_written = bool ($data->{"root_password_written"}); - $users_written = bool ($data->{"users_written"}); - $ret = 1; - } -# SCR->Execute (".target.remove", $file); - } - return bool ($ret); + return bool (1); } # Remove the private data from users_first_stage.ycp after they were