From fd2759be7f73c7b499466cee209bea244bc11fb6 Mon Sep 17 00:00:00 2001
From: Josef Reidinger
Date: Mon, 27 Feb 2017 15:28:02 +0100
Subject: [PATCH 1/3] remove unused methods
---
src/modules/Users.pm | 156 +--------------------------
testsuite/tests/ImportExportUser.err | 0
testsuite/tests/ImportExportUser.out | 7 --
testsuite/tests/ImportExportUser.rb | 76 -------------
4 files changed, 3 insertions(+), 236 deletions(-)
delete mode 100644 testsuite/tests/ImportExportUser.err
delete mode 100644 testsuite/tests/ImportExportUser.out
delete mode 100644 testsuite/tests/ImportExportUser.rb
diff --git a/src/modules/Users.pm b/src/modules/Users.pm
index a4a23dfc8..688d47548 100644
--- a/src/modules/Users.pm
+++ b/src/modules/Users.pm
@@ -352,25 +352,6 @@ sub SetLDAPNotRead {
$ldap_not_read = $_[0];
}
-# OBSOLETE
-BEGIN { $TYPEINFO{GetRootMail} = ["function", "string"]; }
-sub GetRootMail {
- y2warning ("this function is obsolete, use GetRootAliases instead");
- return join (",", keys %root_aliases);
-}
-
-# OBSOLETE
-BEGIN { $TYPEINFO{SetRootMail} = ["function", "void", "string"]; }
-sub SetRootMail {
- my $self = shift;
- my $root_a = shift;
- y2warning ("this function is obsolete, use RemoveRootAlias/AddRootAlias instead");
- foreach my $alias (split (/,/, $root_a)) {
- $alias =~ s/[ \t]//g;
- $root_aliases{$alias} = 1;
- }
-}
-
# return the map with root aliases
BEGIN { $TYPEINFO{GetRootAliases} = ["function", ["map", "string", "integer"]];}
sub GetRootAliases {
@@ -601,35 +582,6 @@ sub AllShells {
return \@shells;
}
-# set the list of users to be imported during installation
-BEGIN { $TYPEINFO{SetUsersForImport} = ["function", "void", ["list","any"]];}
-sub SetUsersForImport {
- my $self = shift;
- my $to_import = shift;
- return if (! defined ($to_import) || ref ($to_import) ne "ARRAY");
- my @u = @$to_import;
- $installation_import{"users"} = \@u;
-}
-
-# return the data of users to be imported during installation
-BEGIN { $TYPEINFO{GetUsersForImport} = ["function", ["list","any"]];}
-sub GetUsersForImport {
- my $self = shift;
- my @ret = ();
- if (defined ($installation_import{"users"}) &&
- ref ($installation_import{"users"}) eq "ARRAY") {
- @ret = @{$installation_import{"users"}};
- }
- return \@ret;
-}
-
-# return the data of users and groups to be imported during installation
-BEGIN { $TYPEINFO{GetDataForImport} = ["function", ["map", "string", "any"]];}
-sub GetDataForImport {
- my $self = shift;
- return \%installation_import;
-}
-
BEGIN { $TYPEINFO{NotAskUppercase} = ["function", "boolean"];}
sub NotAskUppercase {
return $not_ask_uppercase;
@@ -658,10 +610,7 @@ sub SetAskNISServerNotDES {
}
}
-
-
##------------------------------------
-BEGIN { $TYPEINFO{CheckHomeMounted} = ["function", "void"]; }
# Checks if the home directory is properly mounted (bug #20365)
sub CheckHomeMounted {
@@ -823,10 +772,6 @@ sub GetDefaultHome {
return $home;
}
-##------------------------------------
-BEGIN { $TYPEINFO{GetDefaultShadow} = ["function",
- [ "map", "string", "string"],
- "string"];
}
sub GetDefaultShadow {
@@ -1684,10 +1629,6 @@ sub Read {
##------------------------------------
# extract the "shadow" items from user's map
-BEGIN { $TYPEINFO{CreateShadowMap} = ["function",
- ["map", "string", "any" ],
- ["map", "string", "any" ]];
-}
sub CreateShadowMap {
my $self = shift;
@@ -1705,7 +1646,6 @@ sub CreateShadowMap {
##------------------------------------
# Remove user from the list of members of current group
-BEGIN { $TYPEINFO{RemoveUserFromGroup} = ["function", "boolean", "string"]; }
sub RemoveUserFromGroup {
my $self = shift;
@@ -1735,7 +1675,6 @@ sub RemoveUserFromGroup {
##------------------------------------
# Add user to the members list of current group (group_in_work)
-BEGIN { $TYPEINFO{AddUserToGroup} = ["function", "boolean", "string"]; }
sub AddUserToGroup {
my $self = shift;
@@ -1899,7 +1838,6 @@ sub DeleteGroup {
}
##------------------------------------
-BEGIN { $TYPEINFO{GetUserPlugins} = ["function", ["list", "string"], "string"]};
sub GetUserPlugins {
my $self = shift;
@@ -1933,7 +1871,6 @@ sub GetUserPlugins {
}
##------------------------------------
-BEGIN { $TYPEINFO{GetGroupPlugins} = ["function", ["list", "string"], "string"]};
sub GetGroupPlugins {
my $self = shift;
@@ -1946,10 +1883,6 @@ sub GetGroupPlugins {
}
##------------------------------------
-BEGIN { $TYPEINFO{DisableUser} = ["function",
- "string",
- ["map", "string", "any" ]];
-}
sub DisableUser {
my $self = shift;
@@ -2024,10 +1957,6 @@ sub DisableUser {
}
##------------------------------------
-BEGIN { $TYPEINFO{EnableUser} = ["function",
- "string",
- ["map", "string", "any" ]];
-}
sub EnableUser {
my $self = shift;
@@ -3168,36 +3097,6 @@ sub AddUser {
return $plugin_error;
}
-##------------------------------------
-# Simplified version of Add/Edit user: just take arguments and copy them
-# to current user map; doesn't do any checks or default adds
-BEGIN { $TYPEINFO{UpdateUser} = ["function",
- "void",
- ["map", "string", "any" ]]; # data to change in user_in_work
-}
-sub UpdateUser {
-
- my $self = shift;
- my %data = %{$_[0]};
- foreach my $key (keys %data) {
- $user_in_work{$key} = $data{$key};
- }
-}
-
-##------------------------------------
-BEGIN { $TYPEINFO{UpdateGroup} = ["function",
- "void",
- ["map", "string", "any" ]]; # data to change in user_in_work
-}
-sub UpdateGroup {
-
- my $self = shift;
- my %data = %{$_[0]};
- foreach my $key (keys %data) {
- $group_in_work{$key} = $data{$key};
- }
-}
-
##------------------------------------
# Initializes group_in_work map with default values
# @param data group initial data (could be an empty map)
@@ -3979,7 +3878,6 @@ sub WriteLoginDefaults {
##------------------------------------
# Save Security settings (encryption method) if changed in Users module
-BEGIN { $TYPEINFO{WriteSecurity} = ["function", "boolean"]; }
sub WriteSecurity {
my $self = shift;
@@ -4001,7 +3899,6 @@ sub WriteSecurity {
##------------------------------------
-BEGIN { $TYPEINFO{WriteGroup} = ["function", "boolean"]; }
sub WriteGroup {
my $cmd = "/bin/cp $base_directory/group $base_directory/group.YaST2save";
@@ -4021,7 +3918,6 @@ $stdout`");
}
##------------------------------------
-BEGIN { $TYPEINFO{WritePasswd} = ["function", "boolean"]; }
sub WritePasswd {
my $cmd = "/bin/cp $base_directory/passwd $base_directory/passwd.YaST2save";
if (SCR->Execute (".target.bash", $cmd) != 0)
@@ -4040,7 +3936,6 @@ $stdout`");
}
##------------------------------------
-BEGIN { $TYPEINFO{WriteShadow} = ["function", "boolean"]; }
sub WriteShadow {
my $cmd = "/bin/cp $base_directory/shadow $base_directory/shadow.YaST2save";
@@ -4154,7 +4049,6 @@ sub PostDeleteUsers {
# After doing 'Write Changes Now', we must uncheck the 'modified' flags
# of users/groups that were just written.
# Otherwise, user previously added couldn't be deleted after such write...
-BEGIN { $TYPEINFO{UpdateUsersAfterWrite} = ["function", "void", "string"]; }
sub UpdateUsersAfterWrite {
my $self = shift;
@@ -4178,7 +4072,6 @@ sub UpdateUsersAfterWrite {
}
# see UpdateUsersAfterWrite
-BEGIN { $TYPEINFO{UpdateGroupsAfterWrite} = ["function", "void", "string"]; }
sub UpdateGroupsAfterWrite {
my $self = shift;
@@ -4814,30 +4707,6 @@ Encryption support is not installed, home directories will NOT be encrypted."))
##-------------------------------------------------------------------------
##----------------- check routines ----------------------------------------
-##------------------------------------
-BEGIN { $TYPEINFO{ValidLognameChars} = ["function", "string"]; }
-sub ValidLognameChars {
- return UsersSimple->ValidLognameChars ();
-}
-
-##------------------------------------
-BEGIN { $TYPEINFO{ValidPasswordChars} = ["function", "string"]; }
-sub ValidPasswordChars {
- return UsersSimple->ValidPasswordChars ();
-}
-
-##------------------------------------
-BEGIN { $TYPEINFO{ValidHomeChars} = ["function", "string"]; }
-sub ValidHomeChars {
- return UsersSimple->ValidHomeChars ();
-}
-
-##------------------------------------
-BEGIN { $TYPEINFO{ValidPasswordMessage} = ["function", "string"]; }
-sub ValidPasswordMessage {
- return UsersSimple->ValidPasswordMessage ();
-}
-
##------------------------------------
# Return the part of help text about valid password characters
BEGIN { $TYPEINFO{ValidPasswordHelptext} = ["function", "string"]; }
@@ -5008,15 +4877,6 @@ Try another one."), $more);
return "";
}
-##------------------------------------
-# check fullname contents
-BEGIN { $TYPEINFO{CheckFullname} = ["function", "string", "string"]; }
-sub CheckFullname {
-
- my ($self, $fullname) = @_;
- return UsersSimple->CheckFullname ($fullname);
-}
-
##------------------------------------
# check 'additional information': part of gecos field without the fullname
BEGIN { $TYPEINFO{CheckGECOS} = ["function", "string", "string"]; }
@@ -5095,7 +4955,7 @@ sub CheckHome {
my $type = UsersCache->GetUserType ();
my $first = substr ($home, 0, 1);
my $filtered = $home;
- my $valid_home_chars= $self->ValidHomeChars ();
+ my $valid_home_chars= UsersSimple->ValidHomeChars ();
$filtered =~ s/$valid_home_chars//g;
if ($filtered ne "" || $first ne "/" || $home =~ m/\/\./) {
@@ -5457,7 +5317,7 @@ sub CheckUser {
}
if ($error eq "" && $type ne "ldap") {
- $error = $self->CheckFullname ($user{"cn"});
+ $error = UsersSimple->CheckFullname ($user{"cn"});
}
if ($error eq "" && $type ne "ldap") {
@@ -5735,13 +5595,12 @@ sub GetRootPassword {
}
##-------------------------------------------------------------------------
-## -------------------------------------------- nis related routines
+## -------------------------------------------- nis related routines
##------- TODO move to some 'include' file! -------------------------------
##------------------------------------
# Check whether host is NIS master
-BEGIN { $TYPEINFO{ReadNISMaster} = ["function", "boolean"];}
sub ReadNISMaster {
if (! FileUtils->Exists ("/usr/lib/yp/yphelper")) {
return 0;
@@ -5751,7 +5610,6 @@ sub ReadNISMaster {
##------------------------------------
# Checks if set of NIS users is available
-BEGIN { $TYPEINFO{ReadNISAvailable} = ["function", "boolean"];}
sub ReadNISAvailable {
my $passwd_source = SCR->Read (".etc.nsswitch_conf.passwd");
@@ -5802,10 +5660,6 @@ sub RemoveDiskUsersFromGroups {
# Converts autoyast's user's map for users module usage
# @param user map with user data provided by users_auto client
# @return map with user data as defined in Users module
-BEGIN { $TYPEINFO{ImportUser} = ["function",
- [ "map", "string", "any" ],
- [ "map", "string", "any" ]];
-}
sub ImportUser {
my $self = shift;
@@ -6402,10 +6256,6 @@ sub Import {
# Converts user's map for autoyast usage
# @param user map with user data as defined in Users module
# @return map with user data in format used by autoyast
-BEGIN { $TYPEINFO{ExportUser} = ["function",
- [ "map", "string", "any" ],
- [ "map", "string", "any" ]];
-}
sub ExportUser {
my $self = shift;
diff --git a/testsuite/tests/ImportExportUser.err b/testsuite/tests/ImportExportUser.err
deleted file mode 100644
index e69de29bb..000000000
diff --git a/testsuite/tests/ImportExportUser.out b/testsuite/tests/ImportExportUser.out
deleted file mode 100644
index 2920d4661..000000000
--- a/testsuite/tests/ImportExportUser.out
+++ /dev/null
@@ -1,7 +0,0 @@
-Dump ==========================================================
-Dump importing:
-Dump $["encrypted":true, "forename":"aa", "gid":500, "grouplist":"audio", "home":"/home/aaa", "password_settings":$["inact":-1, "max":99999, "min":0, "warn":7], "shell":"/bin/bash", "surname":"A", "uid":500, "user_password":"5OkhN2nLxMfEY", "username":"aaa"]
-Dump ==== processing ImportUser... ============================
-Return $["cn":"aa A", "encrypted":true, "gidNumber":"500", "grouplist":$["audio":"1"], "homeDirectory":"/home/aaa", "loginShell":"/bin/bash", "modified":"imported", "shadowInactive":"-1", "shadowLastChange":"0", "shadowMax":"99999", "shadowMin":"0", "shadowWarning":"7", "type":"local", "uid":"aaa", "uidNumber":"500", "userPassword":"5OkhN2nLxMfEY"]
-Dump ==== processing ExportUser... ============================
-Return $["encrypted":true, "fullname":"aa A", "gid":"500", "home":"/home/aaa", "password_settings":$["inact":"-1", "max":"99999", "min":"0", "warn":"7"], "shell":"/bin/bash", "uid":"500", "user_password":"5OkhN2nLxMfEY", "username":"aaa"]
diff --git a/testsuite/tests/ImportExportUser.rb b/testsuite/tests/ImportExportUser.rb
deleted file mode 100644
index 3be4d147c..000000000
--- a/testsuite/tests/ImportExportUser.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-# encoding: utf-8
-
-# File:
-# ImportExportUser.ycp
-#
-# Module:
-# Users configurator
-#
-# Summary:
-# converting user maps: autoyast -> users module -> autoyast
-#
-# Authors:
-# Jiri Suchomel
-#
-module Yast
- class ImportExportUserClient < Client
- def main
- # testedfiles: Users.pm UsersCache.pm
-
- Yast.import "Users"
- Yast.import "UsersCache"
- Yast.import "Mode"
- Yast.import "Directory"
- Yast.import "Progress"
- Yast.import "Report"
- Yast.import "Testsuite"
-
- Testsuite.Dump(
- "=========================================================="
- )
-
- Mode.SetTest("test")
-
- @importing = {
- "encrypted" => true,
- "forename" => "aa",
- "surname" => "A",
- "uid" => 500,
- "gid" => 500,
- "home" => "/home/aaa",
- "user_password" => "5OkhN2nLxMfEY",
- "password_settings" => {
- "inact" => -1,
- "max" => 99999,
- "min" => 0,
- "warn" => 7
- },
- "grouplist" => "audio",
- "shell" => "/bin/bash",
- "username" => "aaa"
- }
-
- Testsuite.Dump(Builtins.sformat("importing:\n %1", @importing))
-
- Testsuite.Dump(
- "==== processing ImportUser... ============================"
- )
-
- @user = Convert.convert(
- Testsuite.Test(lambda { Users.ImportUser(@importing) }, [], 0),
- :from => "any",
- :to => "map "
- )
-
- Testsuite.Dump(
- "==== processing ExportUser... ============================"
- )
-
- Testsuite.Test(lambda { Users.ExportUser(@user) }, [], 0)
-
- nil
- end
- end
-end
-
-Yast::ImportExportUserClient.new.main
From 970c11760b44d6de1eadf34a897aa78ff21e2168 Mon Sep 17 00:00:00 2001
From: Josef Reidinger
Date: Mon, 27 Feb 2017 15:34:19 +0100
Subject: [PATCH 2/3] remove Users and UsersSimple duplicities
---
src/include/users/helps.rb | 7 ++++---
src/modules/Users.pm | 22 ----------------------
src/modules/YaPI/USERS.pm | 5 +++--
3 files changed, 7 insertions(+), 27 deletions(-)
diff --git a/src/include/users/helps.rb b/src/include/users/helps.rb
index 52952bb3a..d4b4c0121 100644
--- a/src/include/users/helps.rb
+++ b/src/include/users/helps.rb
@@ -40,6 +40,7 @@ def initialize_users_helps(include_target)
Yast.import "UsersCache"
Yast.import "UsersLDAP"
Yast.import "UsersRoutines"
+ Yast.import "UsersSimple"
end
# Password help text.
@@ -77,12 +78,12 @@ def help_password(type)
"
"
),
Ops.get_string(enc_to_string, method, method),
- Users.GetMinPasswordLength(type),
- Users.GetMaxPasswordLength(type)
+ UsersSimple.GetMinPasswordLength(type),
+ UsersSimple.GetMaxPasswordLength(type)
)
)
- help_text = Ops.add(help_text, Users.ValidPasswordHelptext)
+ help_text = Ops.add(help_text, UsersSimple.ValidPasswordHelptext)
#help text 4/4
help_text = Ops.add(
diff --git a/src/modules/Users.pm b/src/modules/Users.pm
index 688d47548..c2e6eca93 100644
--- a/src/modules/Users.pm
+++ b/src/modules/Users.pm
@@ -688,21 +688,6 @@ after you mount correctly. Continue user configuration?"),
##-------------------------------------------------------------------------
##----------------- get routines ------------------------------------------
-##------------------------------------
-BEGIN { $TYPEINFO{GetMinPasswordLength} = ["function", "integer", "string"]; }
-sub GetMinPasswordLength {
-
- my ($self, $type) = @_;
- return UsersSimple->GetMinPasswordLength ($type);
-}
-
-##------------------------------------
-BEGIN { $TYPEINFO{GetMaxPasswordLength} = ["function", "integer", "string"]; }
-sub GetMaxPasswordLength {
- my ($self, $type) = @_;
- return UsersSimple->GetMaxPasswordLength ($type);
-}
-
##------------------------------------
BEGIN { $TYPEINFO{GetDefaultGrouplist} = ["function",
["map", "string", "integer"],
@@ -4707,13 +4692,6 @@ Encryption support is not installed, home directories will NOT be encrypted."))
##-------------------------------------------------------------------------
##----------------- check routines ----------------------------------------
-##------------------------------------
-# Return the part of help text about valid password characters
-BEGIN { $TYPEINFO{ValidPasswordHelptext} = ["function", "string"]; }
-sub ValidPasswordHelptext {
- return UsersSimple->ValidPasswordHelptext ();
-}
-
##------------------------------------
# check the uid of current user
BEGIN { $TYPEINFO{CheckUID} = ["function", "string", "integer"]; }
diff --git a/src/modules/YaPI/USERS.pm b/src/modules/YaPI/USERS.pm
index 3c75845dc..b70d72487 100644
--- a/src/modules/YaPI/USERS.pm
+++ b/src/modules/YaPI/USERS.pm
@@ -134,6 +134,7 @@ YaST::YCP::Import ("Users");
YaST::YCP::Import ("UsersCache");
YaST::YCP::Import ("UsersPasswd");
YaST::YCP::Import ("UsersLDAP");
+YaST::YCP::Import ("UsersSimple");
# -------------------------------------
our $VERSION = '1.0.0';
@@ -2531,8 +2532,8 @@ sub Read {
# return password length limitation for given user ('local' by default)
if ($args->{"password_length"} || 0) {
Users->ReadSystemDefaults (1);
- $ret->{"pw_min"} = Users->GetMinPasswordLength ($user_type);
- $ret->{"pw_max"} = Users->GetMaxPasswordLength ($user_type);
+ $ret->{"pw_min"} = UsersSimple->GetMinPasswordLength ($user_type);
+ $ret->{"pw_max"} = UsersSimple->GetMaxPasswordLength ($user_type);
}
if ($args->{"uid_limits"} || 0) {
From 71c3f17c4f82e651146a08475acba05ad50ece88 Mon Sep 17 00:00:00 2001
From: Josef Reidinger
Date: Mon, 27 Feb 2017 16:19:35 +0100
Subject: [PATCH 3/3] move dialogs flags out of users module
---
src/Makefile.am | 1 +
src/clients/groups.rb | 4 ++-
src/clients/users.rb | 3 ++-
src/include/users/cmdline.rb | 3 ++-
src/include/users/complex.rb | 3 ++-
src/include/users/dialogs.rb | 19 +++++++++------
src/include/users/wizards.rb | 5 ++--
src/modules/Users.pm | 42 +++-----------------------------
src/modules/UsersDialogsFlags.rb | 30 +++++++++++++++++++++++
9 files changed, 59 insertions(+), 51 deletions(-)
create mode 100644 src/modules/UsersDialogsFlags.rb
diff --git a/src/Makefile.am b/src/Makefile.am
index 564b6a82f..558290be1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,7 @@ module_DATA = \
modules/UsersLDAP.pm \
modules/UsersSimple.pm \
modules/UsersCache.pm \
+ modules/UsersDialogsFlags.rb \
modules/UsersPluginLDAPAll.pm \
modules/UsersPluginLDAPPasswordPolicy.pm \
modules/UsersPluginKerberos.pm \
diff --git a/src/clients/groups.rb b/src/clients/groups.rb
index 1c8d06f41..20c3ad9b3 100644
--- a/src/clients/groups.rb
+++ b/src/clients/groups.rb
@@ -33,6 +33,7 @@
# $Id$
#
# Just a shortcut to invoke groups management
+
module Yast
class GroupsClient < Client
def main
@@ -48,6 +49,7 @@ def main
Yast.import "Mode"
Yast.import "Users"
Yast.import "UsersCache"
+ Yast.import "UsersDialogsFlags"
Yast.include self, "users/wizards.rb"
Yast.include self, "users/cmdline.rb"
@@ -82,7 +84,7 @@ def main
@start_dialog,
Mode.test
)
- Users.SetStartDialog(@start_dialog)
+ UsersDialogsFlags.assign_start_dialog(@start_dialog)
@ret = UsersSequence(@start_dialog)
Builtins.y2milestone("Users module finished with %1", @ret)
Builtins.y2milestone("----------------------------------------")
diff --git a/src/clients/users.rb b/src/clients/users.rb
index 1bea1b09b..286ed58e3 100644
--- a/src/clients/users.rb
+++ b/src/clients/users.rb
@@ -43,6 +43,7 @@ def main
Yast.import "Mode"
Yast.import "Users"
Yast.import "UsersCache"
+ Yast.import "UsersDialogsFlags"
Yast.include self, "users/wizards.rb"
Yast.include self, "users/cmdline.rb"
@@ -85,7 +86,7 @@ def main
@start_dialog,
Mode.test
)
- Users.SetStartDialog(@start_dialog)
+ UsersDialogsFlags.assign_start_dialog(@start_dialog)
@ret = UsersSequence(@start_dialog)
Builtins.y2milestone("Users module finished with %1", @ret)
Builtins.y2milestone("----------------------------------------")
diff --git a/src/include/users/cmdline.rb b/src/include/users/cmdline.rb
index b24621491..bac923939 100644
--- a/src/include/users/cmdline.rb
+++ b/src/include/users/cmdline.rb
@@ -36,6 +36,7 @@ def initialize_users_cmdline(include_target)
Yast.import "Ldap"
Yast.import "Users"
Yast.import "UsersCache"
+ Yast.import "UsersDialogsFlags"
Yast.import "UsersLDAP"
Yast.import "UsersSimple"
Yast.import "Report"
@@ -750,7 +751,7 @@ def UsersWrite
end
def UsersGUI
- UsersSequence(Users.GetStartDialog) == :next
+ UsersSequence(UsersDialogsFlags.start_dialog) == :next
end
end
end
diff --git a/src/include/users/complex.rb b/src/include/users/complex.rb
index a87e1f354..29715a90b 100644
--- a/src/include/users/complex.rb
+++ b/src/include/users/complex.rb
@@ -42,6 +42,7 @@ def initialize_users_complex(include_target)
Yast.import "Stage"
Yast.import "Users"
Yast.import "UsersCache"
+ Yast.import "UsersDialogsFlags"
Yast.import "Wizard"
Yast.include include_target, "users/helps.rb"
@@ -101,7 +102,7 @@ def WriteDialog(useUI)
# first dialog for single user addition
# @return [Symbol] for wizard sequencer
def usersInstStart
- Users.SetStartDialog("user_add")
+ UsersDialogsFlags.assign_start_dialog("user_add")
Users.AddUser({})
:next
end
diff --git a/src/include/users/dialogs.rb b/src/include/users/dialogs.rb
index ed2318ddc..93ed35761 100644
--- a/src/include/users/dialogs.rb
+++ b/src/include/users/dialogs.rb
@@ -46,6 +46,7 @@ def initialize_users_dialogs(include_target)
Yast.import "String"
Yast.import "Users"
Yast.import "UsersCache"
+ Yast.import "UsersDialogsFlags"
Yast.import "UsersLDAP"
Yast.import "UsersPlugins"
Yast.import "UsersRoutines"
@@ -160,9 +161,9 @@ def AskForOldPassword
# @return [Symbol] for wizard sequencer
def EditUserDialog(what)
# user has returned to the "add user dialog" during installation workflow:
- if Users.StartDialog("user_add") && installation && Users.UseNextTime
+ if user_add_dialog? && installation && UsersDialogsFlags.use_next_time
Users.RestoreCurrentUser
- Users.SetUseNextTime(false)
+ UsersDialogsFlags.assign_use_next_time(false)
end
display_info = UI.GetDisplayInfo
@@ -256,7 +257,7 @@ def EditUserDialog(what)
(user_type == "ldap" && Ldap.file_server ||
user_type == "local" || user_type == "system")
- complex_layout = installation && Users.StartDialog("user_add")
+ complex_layout = installation && user_add_dialog?
groups = Ops.get_map(user, "grouplist", {})
available_shells = Users.AllShells
@@ -1104,7 +1105,7 @@ def EditUserDialog(what)
username = Convert.to_string(UI.QueryWidget(Id(:username), :Value))
# empty username during installation (-> go to next module)
- if username == "" && ret == :next && Users.StartDialog("user_add")
+ if username == "" && ret == :next && user_add_dialog?
# The user login field is empty, this is allowed if the
# system is part of a network with (e.g.) NIS user management.
# yes-no popup headline
@@ -1363,7 +1364,7 @@ def EditUserDialog(what)
end
end
# --------------------------------- autologin (during installation)
- if Users.StartDialog("user_add") && installation
+ if user_add_dialog? && installation
if Autologin.available
Autologin.user = Convert.to_boolean(
UI.QueryWidget(Id(:autologin), :Value)
@@ -2036,7 +2037,7 @@ def EditUserDialog(what)
# during installation, store the data of first user
# (to show it when clicking `back from Summary dialog)
Users.SaveCurrentUser
- Users.SetStartDialog("users")
+ UsersDialogsFlags.assign_start_dialog("users")
end
ret
end
@@ -2633,7 +2634,7 @@ def EditGroupDialog(what)
def UserSave
Users.CommitUser
# adding only one user during install
- if installation && Users.StartDialog("user_add")
+ if installation && user_add_dialog?
return :save
else
return :next
@@ -2655,5 +2656,9 @@ def GroupSave
Users.CommitGroup
:next
end
+
+ def user_add_dialog?
+ UsersDialogsFlags.start_dialog == "user_add"
+ end
end
end
diff --git a/src/include/users/wizards.rb b/src/include/users/wizards.rb
index bb632d59e..5a4ca1469 100644
--- a/src/include/users/wizards.rb
+++ b/src/include/users/wizards.rb
@@ -42,6 +42,7 @@ def initialize_users_wizards(include_target)
Yast.import "Sequencer"
Yast.import "Stage"
Yast.import "UsersCache"
+ Yast.import "UsersDialogsFlags"
Yast.import "Users"
Yast.import "Wizard"
@@ -125,8 +126,8 @@ def SummaryDialog
end
if Stage.cont && (ret == :back || ret == :abort)
- Users.SetStartDialog("user_add")
- Users.SetUseNextTime(true)
+ UsersDialogsFlags.assign_start_dialog("user_add")
+ UsersDialogsFlags.assign_use_next_time(true)
old_gui = Users.GetGUI
Users.SetGUI(false)
Users.Read
diff --git a/src/modules/Users.pm b/src/modules/Users.pm
index c2e6eca93..d880f41c2 100644
--- a/src/modules/Users.pm
+++ b/src/modules/Users.pm
@@ -179,10 +179,6 @@ my @pluses_passwd = ();
my @pluses_group = ();
my @pluses_shadow = ();
-# starting dialog for installation mode
-my $start_dialog = "summary";
-my $use_next_time = 0;
-
# if user should be warned when using uppercase letters in login name
my $not_ask_uppercase = 0;
@@ -239,6 +235,7 @@ YaST::YCP::Import ("Stage");
YaST::YCP::Import ("String");
YaST::YCP::Import ("Syslog");
YaST::YCP::Import ("UsersCache");
+YaST::YCP::Import ("UsersDialogsFlags");
YaST::YCP::Import ("UsersLDAP");
YaST::YCP::Import ("UsersPasswd");
YaST::YCP::Import ("UsersPlugins");
@@ -388,36 +385,6 @@ sub SetBaseDirectory {
$base_directory = $dir if (defined $dir);
}
-
-BEGIN { $TYPEINFO{GetStartDialog} = ["function", "string"]; }
-sub GetStartDialog {
- return $start_dialog;
-}
-
-BEGIN { $TYPEINFO{StartDialog} = ["function", "boolean", "string"]; }
-sub StartDialog {
- my $self = shift;
- return $start_dialog eq $_[0];
-}
-
-BEGIN { $TYPEINFO{SetStartDialog} = ["function", "void", "string"]; }
-sub SetStartDialog {
- my $self = shift;
- $start_dialog = $_[0];
-}
-
-BEGIN { $TYPEINFO{UseNextTime} = ["function", "boolean"]; }
-sub UseNextTime {
- return $use_next_time;
-}
-
-BEGIN { $TYPEINFO{SetUseNextTime} = ["function", "void", "boolean"]; }
-sub SetUseNextTime {
- my $self = shift;
- $use_next_time = $_[0];
-}
-
-
BEGIN { $TYPEINFO{GetAvailableUserSets} = ["function", ["list", "string"]]; }
sub GetAvailableUserSets {
return \@available_usersets;
@@ -757,7 +724,6 @@ sub GetDefaultHome {
return $home;
}
-}
sub GetDefaultShadow {
my $self = shift;
@@ -1587,11 +1553,11 @@ sub Read {
$self->ReadUsersCache ();
- if (!$use_next_time) {
+ if (!UsersDialogsFlags->use_next_time ()) {
Autologin->Read ();
}
- if ((Stage->cont () || Stage->firstboot ()) && Autologin->available () && !$use_next_time &&
+ if ((Stage->cont () || Stage->firstboot ()) && Autologin->available () && !UsersDialogsFlags->use_next_time () &&
ProductFeatures->GetBooleanFeature ("globals", "enable_autologin")) {
Autologin->Use (YaST::YCP::Boolean (1));
}
@@ -4673,7 +4639,7 @@ Encryption support is not installed, home directories will NOT be encrypted."))
# do not show user in first dialog when all has been writen
if (Stage->cont ()) {
- $use_next_time = 0;
+ UsersDialogsFlags->assign_use_next_time(0);
undef %saved_user;
undef %user_in_work;
}
diff --git a/src/modules/UsersDialogsFlags.rb b/src/modules/UsersDialogsFlags.rb
new file mode 100644
index 000000000..3d6c6e343
--- /dev/null
+++ b/src/modules/UsersDialogsFlags.rb
@@ -0,0 +1,30 @@
+module Yast
+ # TODO: when not called from perl, it can be common ruby lib
+ class UsersDialogsFlagsClass < Module
+ def assign_start_dialog(name)
+ @start_dialog = name
+ end
+
+ # define dialog which should be used as first one, can be modified with {start_dialog=}
+ def start_dialog
+ # summary is starting dialog for installation
+ @start_dialog ||= "summary"
+ end
+
+ def assign_use_next_time(value)
+ @use_next_time = value
+ end
+
+ def use_next_time
+ @use_next_time = false if @use_next_time.nil?
+ @use_next_time
+ end
+
+ publish function: :assign_start_dialog, type: "void (string)"
+ publish function: :start_dialog, type: "string ()"
+ publish function: :assign_use_next_time, type: "void (boolean)"
+ publish function: :use_next_time, type: "boolean ()"
+ end
+
+ UsersDialogsFlags = UsersDialogsFlagsClass.new
+end