Author: jsuchome Date: Thu Jan 31 16:31:16 2008 New Revision: 44075 URL: http://svn.opensuse.org/viewcvs/yast?rev=44075&view=rev Log: - unified function names for RootAlias handling - first steps for implementation of FATE 302980, "Simplified user config during installation" : - added inst_user_first.ycp, client for user configuration in first stage of installation - UsersSimple.pm is module for saving the data gathered from firs stage - inst_root, inst_auth, inst_user updated to check for first stage configuration data - 2.16.7 Added: trunk/users/src/UsersSimple.pm trunk/users/src/inst_user_first.ycp (with props) trunk/users/src/users_finish.ycp (with props) Modified: trunk/users/VERSION trunk/users/package/yast2-users.changes trunk/users/src/Makefile.am trunk/users/src/Users.pm trunk/users/src/dialogs.ycp trunk/users/src/inst_auth.ycp trunk/users/src/inst_root.ycp trunk/users/src/inst_user.ycp Modified: trunk/users/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/VERSION?rev=44075&r1=44074&r2=44075&view=diff ============================================================================== --- trunk/users/VERSION (original) +++ trunk/users/VERSION Thu Jan 31 16:31:16 2008 @@ -1 +1 @@ -2.16.7 +2.16.8 Modified: trunk/users/package/yast2-users.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/package/yast2-users.changes?rev=44075&r1=44074&r2=44075&view=diff ============================================================================== --- trunk/users/package/yast2-users.changes (original) +++ trunk/users/package/yast2-users.changes Thu Jan 31 16:31:16 2008 @@ -1,4 +1,18 @@ ------------------------------------------------------------------- +Thu Jan 31 16:11:28 CET 2008 - jsuchome@suse.cz + +- unified function names for RootAlias handling +- first steps for implementation of FATE 302980, + "Simplified user config during installation" : +- added inst_user_first.ycp, client for user configuration in first + stage of installation +- UsersSimple.pm is module for saving the data gathered from firs + stage +- inst_root, inst_auth, inst_user updated to check for first stage + configuration data +- 2.16.7 + +------------------------------------------------------------------- Tue Jan 29 14:56:17 CET 2008 - jsuchome@suse.cz - "User Management" is "User and Group Management" now in control Modified: trunk/users/src/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/Makefile.am?rev=44075&r1=44074&r2=44075&view=diff ============================================================================== --- trunk/users/src/Makefile.am (original) +++ trunk/users/src/Makefile.am Thu Jan 31 16:31:16 2008 @@ -18,6 +18,7 @@ UsersUI.ycp \ UsersPasswd.pm \ UsersPlugins.pm \ + UsersSimple.pm \ UsersPluginLDAPAll.pm \ UsersPluginLDAPShadowAccount.pm \ UsersPluginLDAPPasswordPolicy.pm \ @@ -37,6 +38,8 @@ groups.ycp \ inst_root.ycp \ inst_user.ycp \ + inst_user_first.ycp \ + users_finish.ycp \ inst_auth.ycp \ users_auto.ycp \ users_plugin_ldap_all.ycp \ Modified: trunk/users/src/Users.pm URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/Users.pm?rev=44075&r1=44074&r2=44075&view=diff ============================================================================== --- trunk/users/src/Users.pm (original) +++ trunk/users/src/Users.pm Thu Jan 31 16:31:16 2008 @@ -238,6 +238,7 @@ YaST::YCP::Import ("UsersPasswd"); YaST::YCP::Import ("UsersPlugins"); YaST::YCP::Import ("UsersRoutines"); +YaST::YCP::Import ("UsersSimple"); YaST::YCP::Import ("UsersUI"); ##------------------------------------------------------------------------- @@ -351,7 +352,7 @@ sub SetRootMail { my $self = shift; my $root_a = shift; - y2warning ("this function is obsolete, use RemoveRootMail/AddRootMail instead"); + y2warning ("this function is obsolete, use RemoveRootAlias/AddRootAlias instead"); foreach my $alias (split (/,/, $root_a)) { $alias =~ s/[ \t]//g; $root_aliases{$alias} = 1; @@ -365,16 +366,16 @@ } # remove the given user from root's aliases set -BEGIN { $TYPEINFO{RemoveRootMail} = ["function", "void", "string"]; } -sub RemoveRootMail { +BEGIN { $TYPEINFO{RemoveRootAlias} = ["function", "void", "string"]; } +sub RemoveRootAlias { my $self = shift; my $u = shift; delete $root_aliases{$u} if (defined $root_aliases{$u}); } # add the given user to root's aliases set -BEGIN { $TYPEINFO{AddRootMail} = ["function", "void", "string"]; } -sub AddRootMail { +BEGIN { $TYPEINFO{AddRootAlias} = ["function", "void", "string"]; } +sub AddRootAlias { my $self = shift; my $u = shift; $root_aliases{$u} = 1; @@ -1873,7 +1874,7 @@ if (Autologin->user () eq $username) { Autologin->Disable (); } - $self->RemoveRootMail ($username); + $self->RemoveRootAlias ($username); my $type = $user_in_work{"type"}; my $plugins = $user_in_work{"plugins"}; @@ -4710,49 +4711,37 @@ } ##------------------------------------------------------------------------- -##----------------- check routines (TODO move outside...) --------- - -# "-" means range! -> at the begining or at the end! -# now CHARACTER_CLASS from /etc/login.defs is used -my $valid_logname_chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-"; - -my $valid_password_chars = "[-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#\$%^&*() ,;:._+/|?{}=\['\"`~<>]|]";# the ']' is or-ed... - -# error popup -my $valid_password_message = __("The password may only contain the following characters: -0-9, a-z, A-Z, and any of \"`~!\@#\$%^&* ,.;:._-+/|\?='{[(<>)]}\\\". -Try again."); - -my $valid_home_chars = "[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/_.-]"; +##----------------- check routines ---------------------------------------- ##------------------------------------ BEGIN { $TYPEINFO{ValidLognameChars} = ["function", "string"]; } sub ValidLognameChars { - return $valid_logname_chars; + return UsersSimple->ValidLognameChars (); } ##------------------------------------ BEGIN { $TYPEINFO{ValidPasswordChars} = ["function", "string"]; } sub ValidPasswordChars { - return $valid_password_chars; + return UsersSimple->ValidPasswordChars (); +} + +##------------------------------------ +BEGIN { $TYPEINFO{ValidHomeChars} = ["function", "string"]; } +sub ValidHomeChars { + return UsersSimple->ValidHomeChars (); } ##------------------------------------ BEGIN { $TYPEINFO{ValidPasswordMessage} = ["function", "string"]; } sub ValidPasswordMessage { - return $valid_password_message; + return UsersSimple->ValidPasswordMessage (); } ##------------------------------------ # Return the part of help text about valid password characters BEGIN { $TYPEINFO{ValidPasswordHelptext} = ["function", "string"]; } sub ValidPasswordHelptext { - # help text (default part shown in more places) - return __("<p> -For the password, use only characters that can be found on an English keyboard -layout. In cases of system error, it may be necessary to log in without a -localized keyboard layout. -</p>"); + return UsersSimple->ValidPasswordHelptext (); } ##------------------------------------ @@ -5006,11 +4995,12 @@ } my $filtered = $pw; + my $valid_password_chars = $self->ValidPasswordChars (); $filtered =~ s/$valid_password_chars//g; $filtered =~ s/\\//g; # bug 175706 if ($filtered ne "") { - return $valid_password_message; + return $self->ValidPasswordMessage (); } return ""; } @@ -5228,6 +5218,7 @@ my $type = UsersCache->GetUserType (); my $first = substr ($home, 0, 1); my $filtered = $home; + my $valid_home_chars= $self->ValidHomeChars (); $filtered =~ s/$valid_home_chars//g; if ($filtered ne "" || $first ne "/" || $home =~ m/\/\./) { Added: trunk/users/src/UsersSimple.pm URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/UsersSimple.pm?rev=44075&view=auto ============================================================================== --- trunk/users/src/UsersSimple.pm (added) +++ trunk/users/src/UsersSimple.pm Thu Jan 31 16:31:16 2008 @@ -0,0 +1,362 @@ +#! /usr/bin/perl -w +# +# File: modules/UsersSimple.pm +# Package: Configuration of users and groups +# Summary: module for first stage user configuration +# +# $Id$ +# + +package UsersSimple; + +use strict; + +use YaST::YCP qw(:LOGGING sformat); +use YaPI; + +textdomain("users"); + +our %TYPEINFO; + +# What client to call after authentication dialog during installation: +# could be "users","nis" or "ldap", for more see inst_auth.ycp +my $after_auth = "users"; + +# If kerberos configuration should be called after authentication +# during installation (F120214) +my $run_krb_config = 0; + +my $root_password = ""; + +my $root_password_written = 0; + +# data of user configured during installation +my %user = (); + + +# password encryption method +my $encryption_method = "md5"; + +# mail alias for root +my $root_alias = ""; + +my %min_pass_length = ( + "local" => 5, + "system" => 5 +); + +my %max_pass_length = ( + "local" => 8, + "system" => 8 +); + +# Number of sigificant characters in the password for given encryption method +my %max_lengths = ( + "des" => 8, + "md5" => 127, + "blowfish" => 72, +); + +# name of user that should be logged in automatically +my $autologin_user = ""; + +##------------------------------------ +##------------------- global imports + +YaST::YCP::Import ("Directory"); +YaST::YCP::Import ("SCR"); +YaST::YCP::Import ("UsersUI"); + +# check the boolean value, return 0 or 1 +sub bool { + + my $param = $_[0]; + if (!defined $param) { + return 0; + } + if (ref ($param) eq "YaST::YCP::Boolean") { + return $param->value(); + } + return $param; +} + +##------------------------------------ +# return the value of current encryption method +BEGIN { $TYPEINFO{EncryptionMethod} = ["function", "string"];} +sub EncryptionMethod { + return $encryption_method; +} + +##------------------------------------ +# set new encryption method +BEGIN { $TYPEINFO{SetEncryptionMethod} = ["function", "void", "string"];} +sub SetEncryptionMethod { + + my $self = shift; + my $method = shift; + if ($encryption_method ne $method) { + $encryption_method = $method; + if (defined $max_lengths{$encryption_method}) { + $max_pass_length{"local"} = $max_lengths{$encryption_method}; + } + } +} + +BEGIN { $TYPEINFO{GetAutologinUser} = ["function", "string"]; } +sub GetAutologinUser { + return $autologin_user; +} + +BEGIN { $TYPEINFO{AutologinUsed} = ["function", "boolean"]; } +sub AutologinUsed { + return bool ($autologin_user ne ""); +} + +BEGIN { $TYPEINFO{SetAutologinUser} = ["function", "void", "string"]; } +sub SetAutologinUser { + my $self = shift; + $autologin_user = shift; +} + +BEGIN { $TYPEINFO{GetRootAlias} = ["function", "string"]; } +sub GetRootAlias { + return $root_alias; +} + +BEGIN { $TYPEINFO{SetRootAlias} = ["function", "void", "string"]; } +sub SetRootAlias { + my $self = shift; + $root_alias = shift; +} + +BEGIN { $TYPEINFO{AfterAuth} = ["function", "string"];} +sub AfterAuth { + return $after_auth; +} + +BEGIN { $TYPEINFO{SetAfterAuth} = ["function", "void", "string"];} +sub SetAfterAuth { + my $self = shift; + $after_auth = $_[0]; +} + +# return the value of run_krb_config (should the kerberos config be run?) +BEGIN { $TYPEINFO{KerberosConfiguration} = ["function", "boolean"];} +sub KerberosConfiguration { + return bool ($run_krb_config); +} + +# set the new value for run_krb_config +BEGIN { $TYPEINFO{SetKerberosConfiguration} = ["function", "void", "boolean"];} +sub SetKerberosConfiguration { + my $self = shift; + my $krb = shift; + $run_krb_config = bool ($krb) if (defined $krb); +} + + + +##------------------------------------ +# Returns the map of user configured during installation +# @return the map of user +BEGIN { $TYPEINFO{GetUser} = [ "function", + ["map", "string", "any" ]]; +} +sub GetUser { + + return \%user; +} + +##------------------------------------ +# Saves the user data into the map +# @param data user initial data (could be an empty map) +BEGIN { $TYPEINFO{SetUser} = ["function", + "string", + ["map", "string", "any" ]]; # data to fill in +} +sub SetUser { + + my $self = shift; + my $data = shift; + if (defined $data && (ref ($data) eq "HASH")) { + %user = %{$data}; + } + return ""; +} + +# was root password written in 1st stage? +BEGIN { $TYPEINFO{RootPasswordWritten} = ["function", "boolean"];} +sub RootPasswordWritten { + return bool ($root_password_written); +} + +##------------------------------------ +# save the root password into variable +BEGIN { $TYPEINFO{SetRootPassword} = ["function", "void", "string"];} +sub SetRootPassword { + + my $self = shift; + $root_password = $_[0]; +} + +##------------------------------------ +# crypt given password +BEGIN { $TYPEINFO{CryptPassword} = ["function", + "string", "string"]; +} +sub CryptPassword { + + my $self = shift; + my $pw = shift; + + return $pw if (!defined $pw); + return UsersUI->HashPassword (lc ($encryption_method), $pw); +} + +##------------------------------------ +# Writes password of superuser +# This is called during install +# @return true on success +BEGIN { $TYPEINFO{WriteRootPassword} = ["function", "boolean"];} +sub WriteRootPassword { + + my $self = shift; + my $crypted = $self->CryptPassword ($root_password, "system"); + return SCR->Write (".target.passwd.root", $crypted); +} + +# "-" means range! -> at the begining or at the end! +# now CHARACTER_CLASS from /etc/login.defs is used +my $valid_logname_chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-"; + +my $valid_password_chars = "[-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#\$%^&*() ,;:._+/|?{}=\['\"`~<>]|]";# the ']' is or-ed... + +# error popup +my $valid_password_message = __("The password may only contain the following characters: +0-9, a-z, A-Z, and any of \"`~!\@#\$%^&* ,.;:._-+/|\?='{[(<>)]}\\\". +Try again."); + +my $valid_home_chars = "[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/_.-]"; + +##------------------------------------ +BEGIN { $TYPEINFO{ValidLognameChars} = ["function", "string"]; } +sub ValidLognameChars { + return $valid_logname_chars; +} + +##------------------------------------ +BEGIN { $TYPEINFO{ValidPasswordChars} = ["function", "string"]; } +sub ValidPasswordChars { + return $valid_password_chars; +} + +##------------------------------------ +BEGIN { $TYPEINFO{ValidHomeChars} = ["function", "string"]; } +sub ValidHomeChars { + return $valid_home_chars; +} + +##------------------------------------ +BEGIN { $TYPEINFO{ValidPasswordMessage} = ["function", "string"]; } +sub ValidPasswordMessage { + return $valid_password_message; +} + +##------------------------------------ +# Return the part of help text about valid password characters +BEGIN { $TYPEINFO{ValidPasswordHelptext} = ["function", "string"]; } +sub ValidPasswordHelptext { + # help text (default part shown in more places) + return __("<p> +For the password, use only characters that can be found on an English keyboard +layout. In cases of system error, it may be necessary to log in without a +localized keyboard layout. +</p>"); +} + +##------------------------------------ +BEGIN { $TYPEINFO{GetMinPasswordLength} = ["function", "integer", "string"]; } +sub GetMinPasswordLength { + + my $self = shift; + if (defined ($min_pass_length{$_[0]})) { + return $min_pass_length{$_[0]}; + } + else { return 5;} +} + +##------------------------------------ +BEGIN { $TYPEINFO{GetMaxPasswordLength} = ["function", "integer", "string"]; } +sub GetMaxPasswordLength { + my $self = shift; + if (defined ($max_pass_length{$_[0]})) { + return $max_pass_length{$_[0]}; + } + else { return 8; } +} + +# Writes the settings configured in 1st stage +BEGIN { $TYPEINFO{Write} = ["function", "boolean"];} +sub Write { + + my $self = shift; + if (defined $user{"userpassword"}) { + $user{"userpassword"} = $self->CryptPassword ($user{"userpassword"}); + $user{"encrypted"} = YaST::YCP::Integer (1); + } + my %data = ( + "after_auth" => $after_auth, + "run_krb_config" => YaST::YCP::Integer ($run_krb_config), + "user" => \%user, + "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); + + # write root password now + $self->WriteRootPassword () if ($root_password); + + return $ret; +} + +# Read the settings configured in 1st stage +BEGIN { $TYPEINFO{Read} = ["function", "boolean"];} +sub Read { + + my $self = shift; + my $file = Directory->vardir()."/users_first_stage.ycp"; + my $ret = 0; + + if (FileUtils->Exists ($file)) { + my $data = SCR->Read (".target.ycp", $file); + 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->{"user"}) eq "HASH") { + %user = %{$data->{"user"}}; + } + $root_password_written = bool ($data->{"root_password_written"}); + $ret = 1; + } +# SCR->Execute (".target.remove", $file); TODO + } + return bool ($ret); +} +1 +# EOF Modified: trunk/users/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/dialogs.ycp?rev=44075&r1=44074&r2=44075&view=diff ============================================================================== --- trunk/users/src/dialogs.ycp (original) +++ trunk/users/src/dialogs.ycp Thu Jan 31 16:31:16 2008 @@ -1644,15 +1644,15 @@ if (root_mail_checked) { if (username != org_username) - Users::RemoveRootMail (org_username); - Users::AddRootMail (username); + Users::RemoveRootAlias (org_username); + Users::AddRootAlias (username); } else if (root_mail) // not checked now, but checked before { if (username != org_username) - Users::RemoveRootMail (org_username); + Users::RemoveRootAlias (org_username); else - Users::RemoveRootMail (username); + Users::RemoveRootAlias (username); } } Modified: trunk/users/src/inst_auth.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/inst_auth.ycp?rev=44075&r1=44074&r2=44075&view=diff ============================================================================== --- trunk/users/src/inst_auth.ycp (original) +++ trunk/users/src/inst_auth.ycp Thu Jan 31 16:31:16 2008 @@ -14,6 +14,7 @@ import "Directory"; import "FileUtils"; +import "GetInstArgs"; import "Label"; import "Ldap"; import "NetworkInterfaces"; @@ -22,9 +23,8 @@ import "Popup"; import "Users"; import "UsersCache"; +import "UsersSimple"; import "Wizard"; -import "GetInstArgs"; - /** @@ -80,6 +80,17 @@ return ret == `ok ? selected : nil; } +//----------------------------------------- main body ---------------------- + +// first check if some settings were written in first stage +if (!GetInstArgs::going_back()) { + + Users::SetKerberosConfiguration (UsersSimple::KerberosConfiguration ()); + Users::SetAfterAuth (UsersSimple::AfterAuth ()); + y2milestone ("skipping authentication dialog..."); + return `next; + // TODO: actually, this could be all for this client... +} // Check if lan is configured list<string> net_devices = NetworkInterfaces::ListDevicesExcept("dialup"); Modified: trunk/users/src/inst_root.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/inst_root.ycp?rev=44075&r1=44074&r2=44075&view=diff ============================================================================== --- trunk/users/src/inst_root.ycp (original) +++ trunk/users/src/inst_root.ycp Thu Jan 31 16:31:16 2008 @@ -30,10 +30,21 @@ import "Stage"; import "Users"; import "UsersCache"; +import "UsersSimple"; import "Wizard"; include "users/widgets.ycp"; // for EncryptionPopup() + UsersSimple::Read (); + if (!GetInstArgs::going_back() && UsersSimple::RootPasswordWritten ()) + { + y2milestone ("root password was already written..."); + // write encryption method (makes sense even if no local user is set) + Users::SetEncryptionMethod (UsersSimple::EncryptionMethod ()); + Users::WriteSecurity (); + return `auto; + } + boolean check_CA_constraints = ProductFeatures::GetBooleanFeature ("globals","root_password_ca_check"); Modified: trunk/users/src/inst_user.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/inst_user.ycp?rev=44075&r1=44074&r2=44075&view=diff ============================================================================== --- trunk/users/src/inst_user.ycp (original) +++ trunk/users/src/inst_user.ycp Thu Jan 31 16:31:16 2008 @@ -12,17 +12,49 @@ textdomain "users"; + import "Autologin"; import "GetInstArgs"; import "Package"; import "Label"; import "Ldap"; + import "Progress"; import "Users"; import "UsersCache"; + import "UsersSimple"; import "Wizard"; include "users/wizards.ycp"; - any ret = `back; + symbol ret = `back; + if (!GetInstArgs::going_back() && + UsersSimple::AfterAuth () == "users" && + UsersSimple::GetUser () != $[]) + { + map<string,any> user = UsersSimple::GetUser (); + y2milestone ("user defined in 1st stage, let's save now..."); + boolean progress_orig = Progress::set (false); + Users::Read (); + string error = Users::AddUser (user); //TODO check ret values + error = Users::CheckUser ($[]); + if (Users::CommitUser ()) + { + if (UsersSimple::AutologinUsed ()) // TODO check available? + { + Autologin::user = UsersSimple::GetAutologinUser (); + Autologin::used = true; + Autologin::modified = true; + } + string root_alias = UsersSimple::GetRootAlias (); + if (root_alias != "") + { + Users::AddRootAlias (root_alias); + } + error = Users::Write (); + UsersSimple::SetUser ($[]); + } + Progress::set (progress_orig); + return `next; + } // dialog caption string caption = _("User Authentication Method"); Added: trunk/users/src/inst_user_first.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/inst_user_first.ycp?rev=44075&view=auto ============================================================================== --- trunk/users/src/inst_user_first.ycp (added) +++ trunk/users/src/inst_user_first.ycp Thu Jan 31 16:31:16 2008 @@ -0,0 +1,452 @@ +{ + import "GetInstArgs"; + import "Label"; + import "Mode"; + import "Stage"; + import "Report"; + import "String"; + import "UsersSimple"; + import "Wizard"; + + textdomain "users"; + + string auth_method = UsersSimple::AfterAuth (); + + string encryption_method = UsersSimple::EncryptionMethod (); + + boolean use_kerberos = UsersSimple::KerberosConfiguration (); + + map button_labels = $[ + // radiobutton to select ldap user auth. + "ldap": _("&LDAP"), + // radiobutton to select nis user auth. + "nis": _("N&IS"), + // radiobutton to select samba user auth. + "samba": _("&Windows Domain"), + // radiobutton to select local user auth. + "users": _("L&ocal (/etc/passwd)"), + // radiobutton to select local user auth. + "edir_ldap": _("&eDirectory LDAP"), + // radiobutton to select local user auth. + "users": _("L&ocal (/etc/passwd)"), + ]; + + map auth2label = $[ + // authentication type + "ldap": _("LDAP"), + // authentication type + "nis": _("NIS"), + // authentication type + "samba": _("Samba (Windows Domain)"), + // authentication type + "edir_ldap": _("eDirectory LDAP"), + ]; + + map<string,string> encoding2label = $[ + // encryption type + "des" : _("DES"), + // encryption type + "md5" : _("MD5"), + // encryption type + "blowfish" : _("Blowfish"), + ]; + + term buttons = `VBox (`VSpacing(0.5)); + list<string> available_clients = [ + "users", "ldap", "nis", "samba", "edir_ldap" ]; + + foreach (string client, available_clients, { + buttons = add (buttons, `Left (`RadioButton ( + `id(client), `opt (`notify), button_labels[client]:"") + )); + }); +// FIXME 'import previous user' is missing + + buttons = add (buttons, `VSpacing(0.5)); + + term auth_term = `VBox ( + `Frame (_("Authentication Method"), + `RadioButtonGroup (`id (`auth_method), buttons) + ), + `VSpacing (), + // check box label + `Left (`CheckBox (`id(`krb), _("Set Up &Kerberos Authentication"))) + ); + + // frame label + term encryption_term = `Frame (_("Password Encryption Type"), + `RadioButtonGroup (`id (`encryption_method), `VBox ( + `VSpacing (0.5), + // Radio button label: password encryption type + `Left (`RadioButton (`id ("des"), _("&DES (Linux default)"))), + // Radio button label: password encryption type + `Left (`RadioButton (`id ("md5"), _("&MD5"))), + // Radio button label: password encryption type + `Left (`RadioButton (`id ("blowfish"), _("&Blowfish"))), + `VSpacing (0.5) + )) + ); + + // help text for dialog "User Authentication Method" 1/3 + string auth_help = _("<p> +<b>Authentication</b><br> +Select the authentication method to use for users on your system. +</p>") + + +// helptext 2/3 +_("<p>Select <b>Local</b> to authenticate users only by using the local files <i>/etc/passwd</i> and <i>/etc/shadow</i>.</p>"); + + auth_help = auth_help + + // helptext 3/3 -- nis & samba & ldap avialable +_("<p>If you are using a NIS or LDAP server to store user data or if you want +to authenticate users against an NT server, choose the appropriate value.</p>") + + + // helptext: additional kerberos support + _("<p>Check <b>Set Up Kerberos Authentication</b> to configure Kerberos after configuring the user data source.</p>"); + + // Help text for password expert dialog + string encryption_help = _("<p> +Choose a password encryption method for local and system users. +<b>DES</b>, the Linux default method, works in all network environments, but it +restricts passwords to eight characters or less. +</p> +") + + // Help text for password expert dialog + _("<p> +<b>MD5</b> allows longer passwords, so provides more security, but some +network protocols do not support this and you may have problems with NIS. +</p>") + + + // Help text for password expert dialog + _("<p> +<b>Blowfish</b> is similar to MD5, but uses a different algorithm +to encrypt passwords. +</P>"); + + // help text for main add user dialog + string main_help () { + // help text for main add user dialog + string help = _("<p> +Enter the <b>User's Full Name</b>, <b>Username</b>, and <b>Password</b> to +assign to this user account. +</p> +") + + // help text for main add user dialog + _("<p> +When entering a password, distinguish between uppercase and +lowercase. Passwords should not contain any special characters, such as +accented characters. +</p> +") + + // help text %1 is encryption type, %2,%3 numbers + sformat (_("<p> +With the current password encryption (%1), the password length should be between + %2 and %3 characters. +</p>"), + encoding2label[encryption_method]:encryption_method, + UsersSimple::GetMinPasswordLength ("local"), + UsersSimple::GetMaxPasswordLength ("local") + ) + + + UsersSimple::ValidPasswordHelptext () + + + // help text for main add user dialog + _("<p> +To ensure that the password was entered correctly, +repeat it exactly in a second field. Do not forget your password. +</p> +") + + // help text for main add user dialog + _("<p> +Create the <b>Username</b> from components of the full name by +clicking <b>Suggestion</b>. It may be modified, but use only +letters (no accented characters), digits, and <tt>._-</tt>. +Do not use uppercase letters in this entry unless you know what you are doing. +Usernames have stricter restrictions than passwords. You can redefine the +restrictions in the /etc/login.defs file. Read its man page for information. +</p> +") + + + // help text for main add user dialog + _("<p> +The username and password created here are needed to log in and work with your Linux system. With <b>Automatic Login</b> enabled, the login procedure is skipped. This user is logged in automatically.</p> +") + + + // help text for main add user dialog + _("<p> +Have mail for root forwarded to this user by checking <b>Receive System Mail</b>.</p> +"); + return help; + } + + /** + * Dialog for expert user settings: authentication method as well + * as password encryption (see fate 302980) + * @return true if user accepted expert settings + */ + boolean ExpertDialog () { + + term contents = `HBox ( + `HWeight (1, `HBox ()), + `HWeight (9, `HBox (`VBox ( + `VStretch (), + auth_term, + `VSpacing (), + encryption_term, + `VStretch () + ))), + `HWeight (1, `HBox ()) + ); + + + Wizard::OpenAcceptDialog (); + Wizard::SetContents (_("Expert Settings"), contents, + auth_help + encryption_help, true, true + ); + UI::ChangeWidget (`id (`auth_method), `CurrentButton, auth_method); + UI::ChangeWidget (`id (`encryption_method), `CurrentButton, + encryption_method); + UI::ChangeWidget (`id (`krb), `Value, use_kerberos); + UI::ChangeWidget (`id (`krb), `Enabled, + auth_method != "users" && auth_method != "samba"); + foreach (string enc, string l, encoding2label, { + UI::ChangeWidget (`id(enc),`Enabled, auth_method == "users"); + }); + any retval = `cancel; + while (true) + { + retval = UI::UserInput (); + if (is (retval, string) && haskey (button_labels, (string)retval)) + { + UI::ChangeWidget (`id(`krb),`Enabled, + retval != "users" && retval != "samba"); + foreach (string enc, string l, encoding2label, { + UI::ChangeWidget (`id(enc),`Enabled, retval == "users"); + }); + } + if (retval == `cancel || retval == `accept || retval == `back) + break; + } + if (retval == `accept) + { + auth_method = (string) + UI::QueryWidget (`id (`auth_method), `CurrentButton); + encryption_method = (string) + UI::QueryWidget (`id(`encryption_method), `CurrentButton); + UsersSimple::SetEncryptionMethod (encryption_method); + if (auth_method == "users" || auth_method == "samba") + use_kerberos = false; + else + use_kerberos = (boolean) UI::QueryWidget (`id(`krb), `Value); + } + Wizard::CloseDialog (); + return (retval == `accept); + } + + // build the term with current user configuration status + term get_status_term () { + if (auth_method == "users") + return `VBox ( + `Left (`Label ( + // summary label + _("The authentication method is local /etc/passwd."))), + `Left (`Label ( + // summary label + sformat (_("The password encryption method is %1."), + encoding2label[encryption_method]:encryption_method) + )) + ); + else + { + // summary line: %1 is LDAP/NIS etc. + string auth_line = sformat (_("The authentication method is %1."), + auth2label[auth_method]:auth_method); + if (use_kerberos) + // summary line: %1 is LDAP/NIS etc. + auth_line = sformat (_("The authentication method is %1 and Kerberos."), auth2label[auth_method]:auth_method); + term cont = `VBox ( + `Left (`Label (auth_line)), + `Left (`Label ( + // summary label FIXME too long for ncurses + _("The configuration will be available later during the installation.") + )) + ); + return cont; + } + } + + map<string,any>user = UsersSimple::GetUser (); + + string user_type = user["type"]:"local"; + string username = user["uid"]:""; + string cn = user["cn"]:""; + string password = (string)user["userpassword"]:nil; + + // this user gets root's mail + boolean root_mail = + (username != "" && UsersSimple::GetRootAlias () == username); + + map display_info = UI::GetDisplayInfo (); + boolean text_mode = display_info["TextMode"]:false; + + term fields = `VBox( + // text entry + `TextEntry (`id(`cn), `opt (`notify), _("User's &Full Name"), cn), + // input field for login name + `TextEntry (`id(`username), `opt (`notify),_("&Username"),username), + `Password(`id(`pw1), Label::Password(), ""), + `Password(`id(`pw2), Label::ConfirmPassword(), "") + ); + + term optionbox = `VBox ( + `Left (`CheckBox (`id (`root_pw), + // checkbox label + _("U&se this password for system administrator"), false) +// FIXME no help text + ), + `Left ( + // checkbox label + `CheckBox (`id (`root_mail), _("Receive S&ystem Mail"), root_mail) + ), + // checkbox label + `Left (`CheckBox (`id (`autologin),_("&Automatic Login"), + UsersSimple::AutologinUsed ()) + ) + ); + term contents = `HBox ( + `HWeight (1, `HBox ()), + `HWeight (9, `HBox ( + `VBox ( + `VStretch (), + `ReplacePoint (`id (`rp_user), `VBox ( + fields, + `VSpacing (0.2), + optionbox + )), + `VSpacing (), + // frame label + `Frame (_("Summary"), `HBox (`HSpacing (0.2), `VBox ( + `ReplacePoint (`id (`rp_status), get_status_term ()), + // pushbutton label + `HBox (`Right (`PushButton (`id(`change),_("&Change...")))), + `VSpacing (0.2) + ))), + `VStretch () + ))), + `HWeight (1, `HBox ()) + ); + + if (Mode::normal ()) Wizard::CreateDialog (); // for testing only + + Wizard::SetDesktopIcon("users"); + // dialog caption + Wizard::SetContents (_("Create New User"), contents, + main_help (), + GetInstArgs::enable_back(), GetInstArgs::enable_next() + ); + string proposed_login = ""; + boolean login_modified = false; + symbol ret = `back; + while (true) + { + ret = (symbol) UI::UserInput (); + if (ret == `change) + { + if (ExpertDialog ()) + { + // show correct values now + UI::ReplaceWidget (`id (`rp_status), get_status_term ()); + foreach (symbol w, [`cn, `username, `pw1, `pw2, `root_pw, + `root_mail, `autologin ], { + UI::ChangeWidget (`id (w), `Enabled,auth_method == "users"); + }); + Wizard::RestoreHelp (main_help ()); + } + } + if (ret == `cn) + { + string uname = (string)UI::QueryWidget (`id (`username), `Value); + if (login_modified && uname == "") + login_modified = false; // reenable suggestion + if (!login_modified) + { + string full = (string)UI::QueryWidget (`id (`cn), `Value); + UI::ChangeWidget (`id (`username), `Value, tolower ( + filterchars (full, UsersSimple::ValidLognameChars ())) + ); + } + } + if (ret == `username) + { + login_modified = true; + } + if (ret == `next) + { + // TODO do all the checks + username = (string) UI::QueryWidget(`id(`username), `Value); + if (username == "" || auth_method != "users") + { + break; + } + string pw1 = (string) UI::QueryWidget(`id(`pw1), `Value); + string pw2 = (string) UI::QueryWidget(`id(`pw2),`Value); + + // --------------------------------- password checks + if (pw1 != pw2) + { + // The two group password information do not match + // error popup + Report::Error(_("The passwords do not match. +Try again.")) ; + + continue; + } + // all the checks are done, we can save the data + password = pw1; + } + if (contains ([`back, `abort, `cancel, `next], ret)) + break; + } + if (ret == `next) + { + UsersSimple::SetAfterAuth (auth_method); + UsersSimple::SetKerberosConfiguration (use_kerberos); + if (auth_method == "users" && username != "") + { + // save the first user data + UsersSimple::SetUser ($[ + "uid" : username, + "userpassword" : password, + "cn" : cn + ]); + if ((boolean) UI::QueryWidget (`id (`root_pw), `Value)) + { + UsersSimple::SetRootPassword (password); + } + UsersSimple::SetAutologinUser ( + (UI::QueryWidget(`id (`autologin),`Value)==true) ? username : "" + ); + UsersSimple::SetRootAlias ( + (UI::QueryWidget (`id (`root_mail), `Value) == true) ? + username : "" + ); + } + else if (auth_method != "users") + { + // TODO: preselect the required packages for installation + y2internal ("TODO: preselect required packages for installation"); + } + } + else if (ret == `back) + { + // reset to defaults + UsersSimple::SetAutologinUser (""); + UsersSimple::SetRootAlias (""); + UsersSimple::SetRootPassword (password); + UsersSimple::SetUser ($[]); + } + + + if (Mode::normal ()) Wizard::CloseDialog (); + return ret; +} Added: trunk/users/src/users_finish.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/users/src/users_finish.ycp?rev=44075&view=auto ============================================================================== --- trunk/users/src/users_finish.ycp (added) +++ trunk/users/src/users_finish.ycp Thu Jan 31 16:31:16 2008 @@ -0,0 +1,53 @@ +/** + * File: include/users/users_finish.ycp + * Package: Configuration of users and groups + * Summary: Installation client for writing users configuration + * at the end of 1st stage + * Authors: Jiri Suchomel <jsuchome@suse.cz> + * + * $Id$ + */ +{ +textdomain "users"; + +import "UsersSimple"; + +any ret = nil; +string func = ""; +map param = $[]; + +/* Check arguments */ +if(size(WFM::Args()) > 0 && is(WFM::Args(0), string)) { + func = (string)WFM::Args(0); + if(size(WFM::Args()) > 1 && is(WFM::Args(1), map)) + param = (map)WFM::Args(1); +} + +y2milestone ("starting users_finish"); +y2debug("func=%1", func); +y2debug("param=%1", param); + +if (func == "Info") +{ + return (any)$[ + "steps" : 1, + // progress step title + "title" : _("Writing Users Configuration..."), + "when" : [ `installation, `autoinst ], + ]; +} +else if (func == "Write") +{ + UsersSimple::Write (); +} +else +{ + y2error ("unknown function: %1", func); + ret = nil; +} + +y2debug("ret=%1", ret); +y2milestone("users_finish finished"); +return ret; + +} -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org