Author: jsuchome
Date: Thu Mar 11 11:09:48 2010
New Revision: 61256
URL: http://svn.opensuse.org/viewcvs/yast?rev=61256&view=rev
Log:
- YaPI: allow to specify default group by name (bnc#582254)
- YaPI enhanced to return default values
- 2.18.15
Modified:
branches/SuSE-Linux-11_2-Branch/users/VERSION
branches/SuSE-Linux-11_2-Branch/users/package/yast2-users.changes
branches/SuSE-Linux-11_2-Branch/users/src/YaPI/USERS.pm
Modified: branches/SuSE-Linux-11_2-Branch/users/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/users/VERSION?rev=61256&r1=61255&r2=61256&view=diff
==============================================================================
--- branches/SuSE-Linux-11_2-Branch/users/VERSION (original)
+++ branches/SuSE-Linux-11_2-Branch/users/VERSION Thu Mar 11 11:09:48 2010
@@ -1 +1 @@
-2.18.14
+2.18.15
Modified: branches/SuSE-Linux-11_2-Branch/users/package/yast2-users.changes
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/users/package/yast2-users.changes?rev=61256&r1=61255&r2=61256&view=diff
==============================================================================
--- branches/SuSE-Linux-11_2-Branch/users/package/yast2-users.changes (original)
+++ branches/SuSE-Linux-11_2-Branch/users/package/yast2-users.changes Thu Mar 11 11:09:48 2010
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Thu Mar 11 10:59:20 CET 2010 - jsuchome@suse.cz
+
+- YaPI: allow to specify default group by name (bnc#582254)
+- YaPI enhanced to return default values
+- 2.18.15
+
+-------------------------------------------------------------------
Thu Oct 1 14:41:38 CEST 2009 - jsuchome@suse.cz
- add GID to autoYaST group export map in more cases (bnc#540787)
Modified: branches/SuSE-Linux-11_2-Branch/users/src/YaPI/USERS.pm
URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Linux-11_2-Branch/users/src/YaPI/USERS.pm?rev=61256&r1=61255&r2=61256&view=diff
==============================================================================
--- branches/SuSE-Linux-11_2-Branch/users/src/YaPI/USERS.pm (original)
+++ branches/SuSE-Linux-11_2-Branch/users/src/YaPI/USERS.pm Thu Mar 11 11:09:48 2010
@@ -103,15 +103,16 @@
use strict;
use YaST::YCP qw(:LOGGING);
use YaPI;
+use Data::Dumper;
textdomain ("users");
# ------------------- imported modules
-YaST::YCP::Import ("Mode");
-
YaST::YCP::Import ("Ldap");
YaST::YCP::Import ("Users");
+YaST::YCP::Import ("UsersCache");
+YaST::YCP::Import ("UsersPasswd");
YaST::YCP::Import ("UsersLDAP");
# -------------------------------------
@@ -362,6 +363,7 @@
"homeDirectory" Users's home directory
"loginShell" User's login shell
"gidNumber" GID of user's default group
+ "groupname" name of user's default group; YaST itself will look for GID
"grouplist" Hash (of type { => 1 }) with groups
this user should be member of.
"shadowinactive" Days after password expires that account is disabled
@@ -443,7 +445,6 @@
}
Users->SetGUI (0);
- Mode->SetUI ("commandline");
$ret = Users->Read ();
if ($ret ne "") { return $ret; }
@@ -477,6 +478,13 @@
$user->{"type"} = $type;
Users->ResetCurrentUser ();
+
+ # if groupname was specified and not gidNumber, find the GID
+ if (($user->{"groupname"} || "") && ! defined $user->{"gidNumber"}) {
+
+ my $group = Users->GetGroupByName ($user->{"groupname"} || "", "");
+ $user->{"gidNumber"} = $group->{"gidNumber"} if (defined $group->{"gidNumber"});
+ }
$ret = Users->AddUser ($user);
if ($ret ne "") { return $ret; }
@@ -652,6 +660,12 @@
$data->{"dn"} = $user->{"dn"};
}
+ # if groupname was specified and not gidNumber, find the GID
+ if (($data->{"groupname"} || "") && ! defined $data->{"gidNumber"}) {
+ my $group = Users->GetGroupByName ($data->{"groupname"} || "", "");
+ $data->{"gidNumber"} = $group->{"gidNumber"} if (defined $group->{"gidNumber"});
+ }
+
$error = Users->EditUser ($data);
if ($error eq "") {
$error = Users->CheckUser ({});
@@ -1151,9 +1165,7 @@
my $ret = {};
my $error = "";
- # FIXME HACK to prevent setting mode to testsuite (bnc#243624)
- Mode->SetUI ("commandline");
-
+
Users->SetGUI (0);
my $type = $config->{"type"} || "local";
@@ -1272,9 +1284,6 @@
my $config = $_[0];
my $ret = {};
- # FIXME HACK to prevent setting mode to testsuite (bnc#243624)
- Mode->SetUI ("commandline");
-
Users->SetGUI (0);
my $type = $config->{"type"} || "local";
@@ -2479,4 +2488,51 @@
return $ret;
}
+# Read various default values. The argument map defines what should be returned
+# in the return map
+BEGIN{$TYPEINFO{Read} = ["function",
+ [ "map", "string", "any" ],
+ [ "map", "string", "any" ]];
+}
+sub Read {
+
+ my $self = shift;
+ my $args = shift;
+ my $ret = {};
+
+ Users->SetGUI (0);
+
+ my $user_type = $args->{"user_type"} || "local";
+
+ if ($args->{"login_defaults"} || 0) {
+ Users->ReadLoginDefaults ();
+ $ret->{"login_defaults"} = Users->GetLoginDefaults ();
+ }
+ # 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);
+ }
+
+ if ($args->{"uid_limits"} || 0) {
+ Users->ReadSystemDefaults (0);
+ my %configuration = (
+ "max_system_uid" => UsersCache->GetMaxUID ("system"),
+ "max_system_gid" => UsersCache->GetMaxGID ("system")
+ );
+ UsersPasswd->Read (\%configuration); # for filling last UID...
+
+ UsersCache->SetLastUID (UsersPasswd->GetLastUID ($user_type), $user_type);
+ $ret->{"uid_min"} = UsersCache->GetMinUID ($user_type);
+ $ret->{"uid_max"} = UsersCache->GetMaxUID ($user_type);
+ $ret->{"uid_next"} = UsersCache->NextFreeUID ();
+ }
+ if ($args->{"all_shells"} || 0) {
+ Users->ReadAllShells ();
+ $ret->{"all_shells"} = Users->AllShells ();
+ }
+ return $ret;
+}
+
42;
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org