Author: jsuchome Date: Mon Mar 8 11:52:03 2010 New Revision: 61176 URL: http://svn.opensuse.org/viewcvs/yast?rev=61176&view=rev Log: - handle possible empty shadow (bnc#583338) - 2.17.35 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/Users.pm branches/SuSE-Code-11-SP1-Branch/users/src/UsersPasswd.pm 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=61176&r1=61175&r2=61176&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/users/VERSION (original) +++ branches/SuSE-Code-11-SP1-Branch/users/VERSION Mon Mar 8 11:52:03 2010 @@ -1 +1 @@ -2.17.34 +2.17.35 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=61176&r1=61175&r2=61176&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 Mon Mar 8 11:52:03 2010 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Mon Mar 8 10:45:57 CET 2010 - jsuchome@suse.cz + +- handle possible empty shadow (bnc#583338) +- 2.17.35 + +------------------------------------------------------------------- Tue Feb 16 14:00:46 CET 2010 - jsuchome@suse.cz - empty hash before reading, to avoid caching problems (bnc#580167) Modified: branches/SuSE-Code-11-SP1-Branch/users/src/Users.pm URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/users/src/Users.pm?rev=61176&r1=61175&r2=61176&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/users/src/Users.pm (original) +++ branches/SuSE-Code-11-SP1-Branch/users/src/Users.pm Mon Mar 8 11:52:03 2010 @@ -4027,14 +4027,25 @@ } ##------------------------------------ + BEGIN { $TYPEINFO{WriteShadow} = ["function", "boolean"]; } sub WriteShadow { - if (SCR->Execute (".target.bash", "/bin/cp $base_directory/shadow $base_directory/shadow.YaST2save") != 0) + my $cmd = "/bin/cp $base_directory/shadow $base_directory/shadow.YaST2save"; + if (SCR->Execute (".target.bash", $cmd) != 0) { - return 0; + if (FileUtils->Exists ("$base_directory/shadow")) { + y2error ("creating backup of $base_directory/shadow failed"); + return 0; + } else { + y2milestone ("$base_directory/shadow does not exists, so it won't be written"); + return 1; + } + } + else + { + return UsersPasswd->WriteShadow (\%shadow); } - return UsersPasswd->WriteShadow (\%shadow); } ##------------------------------------ Modified: branches/SuSE-Code-11-SP1-Branch/users/src/UsersPasswd.pm URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/users/src/UsersPasswd.pm?rev=61176&r1=61175&r2=61176&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/users/src/UsersPasswd.pm (original) +++ branches/SuSE-Code-11-SP1-Branch/users/src/UsersPasswd.pm Mon Mar 8 11:52:03 2010 @@ -68,6 +68,9 @@ # data correctly initialized ? (Read must be called before Get*) my $initialized = 0; +# indicates that /etc/shadow is missing (may be intentional, see bnc#583338) +my $no_shadow = 0; + #--------------------------------------------------------------------- #-------------------------------------------------- internal functions @@ -100,11 +103,13 @@ %shadow_tmp = (); @plus_lines_shadow = (); @comments_shadow = (); + $no_shadow = 0; my $file = "$base_directory/shadow"; if (! FileUtils->Exists ($file)) { y2warning ("$file is not available!"); + $no_shadow = 1; return 1; } my $in = SCR->Read (".target.string", $file); @@ -421,6 +426,10 @@ "userPassword" => undef, "type" => $user_type }; + # sometimes real password might be in /etc/passwd + if ($password ne "" && $password ne "x" && $no_shadow) { + $users{$user_type}{$username}{"userPassword"} = $password; + } if (! defined $shadow_tmp{$username}) { y2debug ("There is no shadow entry for user $username."); @@ -688,6 +697,10 @@ my %user = %{$users_w{$type}{$username}}; my $pass = "x"; + if ($no_shadow && $user{"userPassword"}) + { + $pass = $user{"userPassword"}; + } my $cn = $user{"cn"} || ""; if (defined $user{"addit_data"} && $user{"addit_data"} ne "") { $cn .= ",".$user{"addit_data"}; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org