[yast-commit] r58870 - in /branches/SuSE-Code-11-SP1-Branch/users: VERSION package/yast2-users.changes src/Makefile.am src/YaPI/ADMINISTRATOR.pm src/YaPI/USERS.pm yast2-users.spec.in
Author: jsuchome Date: Thu Oct 1 12:58:47 2009 New Revision: 58870 URL: http://svn.opensuse.org/viewcvs/yast?rev=58870&view=rev Log: - YaPI: added ADMINISTRATOR.pm (root password, mail aliases) - YaPI: enable returning set of attributes (UsersGet, UserGet) - 2.17.29 Added: branches/SuSE-Code-11-SP1-Branch/users/src/YaPI/ADMINISTRATOR.pm Modified: branches/SuSE-Code-11-SP1-Branch/users/VERSION branches/SuSE-Code-11-SP1-Branch/users/package/yast2-users.changes branches/SuSE-Code-11-SP1-Branch/users/src/Makefile.am branches/SuSE-Code-11-SP1-Branch/users/src/YaPI/USERS.pm branches/SuSE-Code-11-SP1-Branch/users/yast2-users.spec.in Modified: branches/SuSE-Code-11-SP1-Branch/users/VERSION URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/users/VERSION?rev=58870&r1=58869&r2=58870&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/users/VERSION (original) +++ branches/SuSE-Code-11-SP1-Branch/users/VERSION Thu Oct 1 12:58:47 2009 @@ -1 +1 @@ -2.17.28 +2.17.29 Modified: branches/SuSE-Code-11-SP1-Branch/users/package/yast2-users.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/users/package/yast2-users.changes?rev=58870&r1=58869&r2=58870&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/users/package/yast2-users.changes (original) +++ branches/SuSE-Code-11-SP1-Branch/users/package/yast2-users.changes Thu Oct 1 12:58:47 2009 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Thu Oct 1 12:38:00 CEST 2009 - jsuchome@suse.cz + +- YaPI: added ADMINISTRATOR.pm (root password, mail aliases) +- YaPI: enable returning set of attributes (UsersGet, UserGet) +- 2.17.29 + +------------------------------------------------------------------- Tue Dec 16 19:41:55 CET 2008 - jsuchome@suse.cz - do not try to detect network authentication methods during Modified: branches/SuSE-Code-11-SP1-Branch/users/src/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/users/src/Makefile.am?rev=58870&r1=58869&r2=58870&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/users/src/Makefile.am (original) +++ branches/SuSE-Code-11-SP1-Branch/users/src/Makefile.am Thu Oct 1 12:58:47 2009 @@ -58,6 +58,7 @@ YaPI_perldir = @moduledir@/YaPI YaPI_perl_DATA = \ + YaPI/ADMINISTRATOR.pm \ YaPI/USERS.pm Added: branches/SuSE-Code-11-SP1-Branch/users/src/YaPI/ADMINISTRATOR.pm URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/users/src/YaPI/ADMINISTRATOR.pm?rev=58870&view=auto ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/users/src/YaPI/ADMINISTRATOR.pm (added) +++ branches/SuSE-Code-11-SP1-Branch/users/src/YaPI/ADMINISTRATOR.pm Thu Oct 1 12:58:47 2009 @@ -0,0 +1,90 @@ +package YaPI::ADMINISTRATOR; + +use strict; +use YaST::YCP qw(:LOGGING); +use YaPI; + +textdomain ("users"); + +# ------------------- imported modules +YaST::YCP::Import ("MailAliases"); +YaST::YCP::Import ("Mode"); +YaST::YCP::Import ("Users"); +# ------------------------------------- + +our $VERSION = '1.0.0'; +our @CAPABILITIES = ('SLES11'); +our %TYPEINFO; + +=item * +C<$hash Read ();> + +Returns the information about system administrator (root). +Currently return hash contains the list of mail aliases. + +=cut + +BEGIN{$TYPEINFO{Read} = ["function", + [ "map", "string", "any" ]]; +} +sub Read { + + my $self = shift; + + # FIXME HACK to prevent setting mode to testsuite (bnc#243624) + Mode->SetUI ("commandline"); + + my $root_mail = MailAliases->GetRootAlias (); + return {} if !defined $root_mail; + + my @root_aliases = (); + foreach my $alias (split (/,/, $root_mail)) { + $alias =~ s/[ \t]//g; + push @root_aliases, $alias; + } + + return { + "aliases" => \@root_aliases + } +} + +=item * +C<$string Write ($argument_hash);> + +write the system adminstrator data. Supported keys of the argument hash are: + + "aliases" => list of mail aliases + "password" => new password + +Returns error message on error. + +=cut + +BEGIN{$TYPEINFO{Write} = ["function", + "string", + [ "map", "string", "any" ]]; +} +sub Write { + + my $self = shift; + my $args = shift; + my $ret = ""; + + Mode->SetUI ("commandline"); + + if ($args->{"aliases"} && ref ($args->{"aliases"}) eq "ARRAY") { + + my $root_mail = join (", ", @{$args->{"aliases"}}); + if (!MailAliases->SetRootAlias ($root_mail)) { + # error popup + $ret = __("An error occurred while setting forwarding for root's mail."); + return $ret; + } + } + if ($args->{"password"}) { + Users->SetRootPassword ($args->{"password"}); + Users->WriteRootPassword (); + } + return $ret; +} + Modified: branches/SuSE-Code-11-SP1-Branch/users/src/YaPI/USERS.pm URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/users/src/YaPI/USERS.pm?rev=58870&r1=58869&r2=58870&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/users/src/YaPI/USERS.pm (original) +++ branches/SuSE-Code-11-SP1-Branch/users/src/YaPI/USERS.pm Thu Oct 1 12:58:47 2009 @@ -108,6 +108,8 @@ # ------------------- imported modules +YaST::YCP::Import ("Mode"); + YaST::YCP::Import ("Ldap"); YaST::YCP::Import ("Users"); YaST::YCP::Import ("UsersLDAP"); @@ -441,6 +443,7 @@ } Users->SetGUI (0); + Mode->SetUI ("commandline"); $ret = Users->Read (); if ($ret ne "") { return $ret; } @@ -1148,6 +1151,9 @@ 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"; @@ -1212,6 +1218,16 @@ } } } + # return only requested attributes... + if ($type eq "local" && $config->{"user_attributes"}) { + my $attrs = {}; + foreach my $key (@{$config->{"user_attributes"}}) { + $attrs->{$key} = 1; + } + foreach my $key (keys %{$ret}) { + delete $ret->{$key} if !$attrs->{$key}; + } + } return $ret; } @@ -1256,6 +1272,9 @@ 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"; @@ -1283,7 +1302,21 @@ my $index = $config->{"index"} || "uidNumber"; - return Users->GetUsers ($index, $type); + $ret = Users->GetUsers ($index, $type); + + # return only requested attributes... + if ($type eq "local" && $config->{"user_attributes"}) { + my $attrs = {}; + foreach my $key (@{$config->{"user_attributes"}}) { + $attrs->{$key} = 1; + } + foreach my $user (values %{$ret}) { + foreach my $key (keys %{$user}) { + delete $user->{$key} if !$attrs->{$key}; + } + } + } + return $ret; } =item * Modified: branches/SuSE-Code-11-SP1-Branch/users/yast2-users.spec.in URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/users/yast2-users.spec.in?rev=58870&r1=58869&r2=58870&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/users/yast2-users.spec.in (original) +++ branches/SuSE-Code-11-SP1-Branch/users/yast2-users.spec.in Thu Oct 1 12:58:47 2009 @@ -34,7 +34,7 @@ @desktopdir@/*.desktop @moduledir@/*.pm @moduledir@/UsersUI.y* -@moduledir@/YaPI/USERS.pm +@moduledir@/YaPI/*.pm @yncludedir@/users/* @schemadir@/autoyast/rnc/users.rnc #agents: -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
jsuchome@svn.opensuse.org