Module: Yast::UsersDialogsInclude
- Defined in:
- ../../src/include/users/dialogs.rb
Instance Method Summary (collapse)
-
- (String) AskForOldPassword
Ask user for current password, see bugs 242531, 244718.
-
- (Object) AskForUppercasePopup(username)
Upperase letters were used in username! (see bug #26409) In these popup, ask user what to do.
-
- (Symbol) EditGroupDialog(what)
Dialog for adding/editing group.
-
- (Symbol) EditUserDialog(what)
Dialog for adding or editing a user.
-
- (Symbol) GroupSave
Check the group parameters and commit it if all is OK.
- - (Object) initialize_users_dialogs(include_target)
-
- (Symbol) UserSave
Just giving paramaters for commiting user.
Instance Method Details
- (String) AskForOldPassword
Ask user for current password, see bugs 242531, 244718
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File '../../src/include/users/dialogs.rb', line 113 def AskForOldPassword UI.OpenDialog( Opt(:decorated), HBox( HSpacing(0.5), VBox( VSpacing(0.5), # password entry label Password( Id(:pw1), Opt(:hstretch), _( "To access the data required to modify\n" + "the encryption settings for this user,\n" + "enter the user's current password." ) ), Password(Id(:pw2), Opt(:hstretch), Label.ConfirmPassword, ""), HBox( PushButton(Id(:ok), Opt(:key_F10), Label.OKButton), PushButton(Id(:cancel), Opt(:key_F9), Label.CancelButton) ), VSpacing(0.5) ), HSpacing(0.5) ) ) ret = :cancel begin ret = UI.UserInput if ret == :ok if UI.QueryWidget(Id(:pw1), :Value) != UI.QueryWidget(Id(:pw2), :Value) Report.Error(_("The passwords do not match.\nTry again.")) ret = :notnext next end end end until ret == :ok || ret == :cancel pw = Convert.to_string(UI.QueryWidget(Id(:pw1), :Value)) UI.CloseDialog ret == :ok ? pw : nil end |
- (Object) AskForUppercasePopup(username)
Upperase letters were used in username! (see bug #26409) In these popup, ask user what to do.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File '../../src/include/users/dialogs.rb', line 63 def AskForUppercasePopup(username) ret = :ok if username != Builtins.tolower(username) && !Users.NotAskUppercase && Package.InstalledAny(["sendmail", "postfix"]) # The login name contains uppercase 1/3 text = _( "<p>\nYou have used uppercase letters in the user login entry.</p>" ) + # The login name contains uppercase 2/3 _( "<p>This could cause problems with delivering mail\n" + "to this user, because mail systems generally do not\n" + "support case-sensitive names.<br>\n" + "You could solve this problem by editing the alias table.</p>\n" ) + # The login name contains uppercase 3/3 _("<p>Really use the entered value?</p>") UI.OpenDialog( Opt(:decorated), HBox( VSpacing(14), VBox( HSpacing(50), RichText(Id(:rt), text), CheckBox(Id(:ch), Opt(:notify), Message.DoNotShowMessageAgain), HBox( PushButton(Id(:ok), Opt(:key_F10), Label.YesButton), PushButton(Id(:no), Opt(:key_F9), Label.NoButton) ) ) ) ) begin ret = Convert.to_symbol(UI.UserInput) end while !Builtins.contains([:cancel, :ok, :no], ret) if ret != :cancel Users.SetAskUppercase( Convert.to_boolean(UI.QueryWidget(Id(:ch), :Value)) ) end UI.CloseDialog end ret end |
- (Symbol) EditGroupDialog(what)
Dialog for adding/editing group
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 |
# File '../../src/include/users/dialogs.rb', line 2039 def EditGroupDialog(what) # create a local copy of current group group = Users.GetCurrentGroup groupname = Ops.get_string(group, "cn", "") password = Ops.get_string(group, "userPassword") gid = GetInt(Ops.get(group, "gidNumber"), -1) # these are the users with this group as a default: more_users = Ops.get_map(group, "more_users", {}) # these are users from /etc/group: userlist = Ops.get_map(group, "userlist", {}) group_type = Ops.get_string(group, "type", "") new_type = group_type additional_users = [] member_attribute = UsersLDAP.GetMemberAttribute if group_type == "ldap" userlist = Ops.get_map(group, member_attribute, {}) end more = Ops.greater_than(Builtins.size(more_users), 0) dialog_labels = { "add_group" => { # dialog caption: "local" => _("New Local Group"), # dialog caption: "system" => _("New System Group"), # dialog caption: "ldap" => _("New LDAP Group") }, "edit_group" => { # dialog caption: "local" => _("Existing Local Group"), # dialog caption: "system" => _("Existing System Group"), # dialog caption: "ldap" => _("Existing LDAP Group") } } plugin_client = "" plugin = "" client2plugin = {} clients = [] # initialize local variables with current state of group reinit_groupdata = lambda do groupname = Ops.get_string(group, "cn", groupname) password = Ops.get_string(group, "userPassword", password) gid = GetInt(Ops.get(group, "gidNumber"), gid) more_users = Convert.convert( Ops.get(group, "more_users", more_users), :from => "any", :to => "map <string, any>" ) userlist = Convert.convert( Ops.get(group, "userlist", userlist), :from => "any", :to => "map <string, any>" ) group_type = Ops.get_string(group, "type", group_type) if group_type == "ldap" userlist = Ops.get_map(group, member_attribute, {}) end nil end # generate contents for Group Data Dialog get_edit_term = lambda do i = 0 more_users_items = [] Builtins.foreach(more_users) do |u, val| if Ops.less_than(i, 42) more_users_items = Builtins.add( more_users_items, Item(Id(u), u, true) ) end if i == 42 more_users_items = Builtins.add( more_users_items, Item(Id("-"), "...", false) ) end i = Ops.add(i, 1) end HBox( HWeight( 1, VBox( VSpacing(1), Top( InputField( Id(:groupname), Opt(:hstretch), # textentry label _("Group &Name"), groupname ) ), Top( InputField( Id(:gid), Opt(:hstretch), # textentry label _("Group &ID (gid)"), Builtins.sformat("%1", gid) ) ), VSpacing(1), Bottom(Password(Id(:pw1), Opt(:hstretch), Label.Password, "")), Bottom( Password(Id(:pw2), Opt(:hstretch), Label.ConfirmPassword, "") ), VSpacing(1) ) ), HSpacing(2), HWeight( 1, VBox( VSpacing(1), ReplacePoint( Id(:rpuserlist), # selection box label MultiSelectionBox(Id(:userlist), _("Group &Members"), []) ), more ? VSpacing(1) : VSpacing(0), more ? MultiSelectionBox(Id(:more_users), "", more_users_items) : VSpacing(0), VSpacing(1) ) ) ) end # generate contents for Plugins Dialog get_plugins_term = lambda do plugin_client = Ops.get(clients, 0, "") plugin = Ops.get_string(client2plugin, plugin_client, plugin_client) items = [] Builtins.foreach(clients) do |cl| summary = WFM.CallFunction(cl, ["Summary", { "what" => "group" }]) pl = Ops.get_string(client2plugin, cl, cl) if Ops.is_string?(summary) items = Builtins.add( items, Item( Id(cl), Builtins.contains(Ops.get_list(group, "plugins", []), pl) ? UI.Glyph(:CheckMark) : " ", summary ) ) end end HBox( HSpacing(0.5), VBox( Table( Id(:table), Opt(:notify), Header( " ", # table header _("Plug-In Description") ), items ), HBox( PushButton( Id(:change), Opt(:key_F3), # pushbutton label _("Add &or Remove Plug-In") ), # pushbutton label Right(PushButton(Id(:run), Opt(:key_F6), _("&Launch"))) ), VSpacing(0.5) ), HSpacing(0.5) ) end tabs = [] dialog_contents = Empty() # Now initialize the list of plugins: we must know now if there is some available. # UsersPlugins will filter out plugins we cannot use for given type plugin_clients = UsersPlugins.Apply( "GUIClient", { "what" => "group", "type" => group_type }, {} ) # remove empty clients plugin_clients = Builtins.filter( Convert.convert( plugin_clients, :from => "map", :to => "map <string, string>" ) ) { |plugin2, client| client != "" } clients = Builtins.maplist( Convert.convert( plugin_clients, :from => "map", :to => "map <string, string>" ) ) do |plugin2, client| Ops.set(client2plugin, client, plugin2) client end use_tabs = Ops.greater_than(Builtins.size(clients), 0) has_tabs = true if use_tabs tabs = [ # tab label Item(Id(:edit), _("Group &Data"), true), # tab label Item(Id(:plugins), _("Plu&g-Ins")) ] dialog_contents = VBox( DumbTab( Id(:tabs), tabs, ReplacePoint(Id(:tabContents), get_edit_term.call) ) ) if !UI.HasSpecialWidget(:DumbTab) has_tabs = false = HBox() Builtins.foreach(tabs) do |it| label = Ops.get_string(it, 1, "") = Builtins.add( , PushButton(Ops.get_term(it, 0) { Id(label) }, label) ) end dialog_contents = VBox( Left(), Frame("", ReplacePoint(Id(:tabContents), get_edit_term.call)) ) end else dialog_contents = get_edit_term.call end Wizard.SetContentsButtons( Ops.get_string(dialog_labels, [what, group_type], ""), dialog_contents, EditGroupDialogHelp(more), Label.CancelButton, Label.OKButton ) Wizard.HideAbortButton ret = :edit current = nil tabids = [:edit, :plugins] # switch focus to specified tab (after error message) and widget inside focus_tab = lambda do |tab, | = deep_copy() UI.ChangeWidget(Id(:tabs), :CurrentItem, tab) if use_tabs && has_tabs UI.SetFocus(Id()) ret = :notnext nil end begin # map returned from Check*UI functions error_map = {} # map with id's of confirmed questions ui_map = {} # error message error = "" ret = Convert.to_symbol(UI.UserInput) if current != nil if (ret == :abort || ret == :cancel) && ReallyAbort() != :abort ret = :notnext next end break if Builtins.contains([:abort, :back, :cancel], ret) tab = Builtins.contains(tabids, ret) next if tab && ret == current # 1. click inside Group Data dialog or moving outside of it if current == :edit && (ret == :next || tab) pw1 = Convert.to_string(UI.QueryWidget(Id(:pw1), :Value)) pw2 = Convert.to_string(UI.QueryWidget(Id(:pw2), :Value)) new_gid = Convert.to_string(UI.QueryWidget(Id(:gid), :Value)) new_i_gid = Builtins.tointeger(new_gid) new_groupname = Convert.to_string( UI.QueryWidget(Id(:groupname), :Value) ) # --------------------------------- groupname checks error2 = Users.CheckGroupname(new_groupname) if error2 != "" Report.Error(error2) focus_tab.call(current, :groupname) next end # --------------------------------- password checks if pw1 != pw2 # The two group password information do not match # error popup Report.Error(_("The passwords do not match.\nTry again.")) focus_tab.call(current, :pw1) next end if pw1 != "" && pw1 != @default_pw error2 = UsersSimple.CheckPassword(pw1, group_type) if error2 != "" Report.Error(error2) focus_tab.call(current, :pw1) next end errors = UsersSimple.CheckPasswordUI( { "cn" => new_groupname, "userPassword" => pw1, "type" => group_type } ) if errors != [] = Ops.add( Ops.add( Builtins.mergestring(errors, "\n\n"), # last part of message popup "\n\n" ), _("Really use this password?") ) if !Popup.YesNo() focus_tab.call(current, :pw1) next end end password = pw1 if Ops.get_boolean(group, "encrypted", false) Ops.set(group, "encrypted", false) end end # --------------------------------- gid checks if new_i_gid != gid error2 = Users.CheckGID(new_i_gid) if error2 != "" Report.Error(error2) focus_tab.call(current, :gid) next end failed = false begin error_map = Users.CheckGIDUI(new_i_gid, ui_map) if error_map != {} if !Popup.YesNo(Ops.get_string(error_map, "question", "")) failed = true else Ops.set( ui_map, Ops.get_string(error_map, "question_id", ""), new_i_gid ) if Builtins.contains( ["local", "system"], Ops.get_string(error_map, "question_id", "") ) new_type = Ops.get_string(error_map, "question_id", "local") UsersCache.SetGroupType(new_type) end end end end while error_map != {} && !failed if failed focus_tab.call(current, :gid) next end end # --------------------------------- update userlist new_userlist = Builtins.listmap( Convert.convert( UI.QueryWidget(Id(:userlist), :SelectedItems), :from => "any", :to => "list <string>" ) ) { |user| { user => 1 } } # --------------------------------- now everything should be OK Ops.set(group, "cn", new_groupname) Ops.set(group, "userPassword", password) Ops.set(group, "more_users", more_users) Ops.set(group, "gidNumber", new_i_gid) Ops.set(group, "type", new_type) if group_type == "ldap" Ops.set(group, member_attribute, new_userlist) else Ops.set(group, "userlist", new_userlist) end reinit_groupdata.call end # inside plugins dialog if current == :plugins plugin_client = Convert.to_string( UI.QueryWidget(Id(:table), :CurrentItem) ) if plugin_client != nil plugin = Ops.get_string(client2plugin, plugin_client, plugin_client) end if ret == :table || ret == :change ret = Builtins.contains(Ops.get_list(group, "plugins", []), plugin) ? :del : :add end if ret == :del out = UsersPlugins.Apply( "PluginRemovable", { "what" => "group", "type" => group_type, "plugins" => [plugin] }, {} ) # check if plugin _could_ be deleted! if Builtins.haskey(out, plugin) && !Ops.get_boolean(out, plugin, false) # popup message Popup.Message(_("This plug-in cannot be removed.")) ret = :not_next next end end if ret == :add || ret == :del || ret == :run # functions for adding/deleting/launching plugin work on # Users::group_in_work, so we must update it before if what == "edit_group" Users.EditGroup(group) else Users.AddGroup(group) end end if ret == :add error = Users.AddGroupPlugin(plugin) if error != "" Popup.Error(error) ret = :notnext next end group = Users.GetCurrentGroup reinit_groupdata.call UI.ChangeWidget( Id(:table), term(:Item, plugin_client, 0), UI.Glyph(:CheckMark) ) end if ret == :del error = Users.RemoveGroupPlugin(plugin) if error != "" Popup.Error(error) ret = :notnext next end group = Users.GetCurrentGroup reinit_groupdata.call UI.ChangeWidget(Id(:table), term(:Item, plugin_client, 0), " ") end if ret == :run plugin_added = false # first, add the plugin if necessary if !Builtins.contains(Ops.get_list(group, "plugins", []), plugin) error = Users.AddGroupPlugin(plugin) if error != "" Popup.Error(error) ret = :notnext next end plugin_added = true group = Users.GetCurrentGroup reinit_groupdata.call end plugin_ret = WFM.CallFunction( plugin_client, ["Dialog", { "what" => "group" }, group] ) if plugin_ret == :next # update the map of changed group group = Users.GetCurrentGroup reinit_groupdata.call UI.ChangeWidget( Id(:table), term(:Item, plugin_client, 0), UI.Glyph(:CheckMark) ) elsif plugin_added error = Users.RemoveGroupPlugin(plugin) if error != "" Popup.Error(error) ret = :notnext next end group = Users.GetCurrentGroup reinit_groupdata.call end end end # initialize Edit Group tab if ret == :edit if use_tabs Wizard.SetHelpText(EditGroupDialogHelp(more)) UI.ReplaceWidget(:tabContents, get_edit_term.call) end UI.SetFocus(Id(:groupname)) if what == "add_group" if what == "edit_group" if password != nil UI.ChangeWidget(Id(:pw1), :Value, @default_pw) UI.ChangeWidget(Id(:pw2), :Value, @default_pw) end end if more # set of users having this group as default - cannot be edited! UI.ChangeWidget(Id(:more_users), :Enabled, false) end additional_users = UsersCache.BuildAdditional(group) # add items later (when there is a huge amount of them, it takes # long time to display, so display at least the rest of the dialog) if Ops.greater_than(Builtins.size(additional_users), 0) UI.ReplaceWidget( Id(:rpuserlist), MultiSelectionBox( Id(:userlist), _("Group &Members"), additional_users ) ) end current = ret end if ret == :plugins UI.ReplaceWidget(:tabContents, get_plugins_term.call) Wizard.SetHelpText(PluginDialogHelp()) UI.ChangeWidget(Id(:table), :CurrentItem, plugin_client) current = ret end # save the changes if ret == :next error = Users.CheckGroup(group) if error != "" Report.Error(error) ret = :notnext next end if what == "edit_group" error = Users.EditGroup(group) else error = Users.AddGroup(group) end if error != "" Report.Error(error) ret = :notnext next end end end until Builtins.contains([:next, :abort, :back, :cancel], ret) ret end |
- (Symbol) EditUserDialog(what)
Dialog for adding or editing a user.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 |
# File '../../src/include/users/dialogs.rb', line 161 def EditUserDialog(what) # user has returned to the "add user dialog" during installation workflow: if Users.StartDialog("user_add") && installation && Users.UseNextTime Users.RestoreCurrentUser Users.SetUseNextTime(false) end display_info = UI.GetDisplayInfo text_mode = Ops.get_boolean(display_info, "TextMode", false) user = Users.GetCurrentUser error_msg = "" if user == {} error_msg = Users.AddUser({}) if error_msg != "" Popup.Error(error_msg) return :back end user = Users.GetCurrentUser end action = Ops.get_string(user, "modified", "") action = what == "add_user" ? "added" : "edited" if action == "" user_type = Ops.get_string(user, "type", "local") username = Ops.get_string(user, "uid", "") cn = "" # in LDAP, cn is list of strings if Ops.is_list?(Ops.get(user, "cn")) cn = Ops.get_string(user, ["cn", 0], "") else cn = Ops.get_string(user, "cn", "") end tmp_fullname = cn # for login proposing default_home = Users.GetDefaultHome(user_type) home = Ops.get_string(user, "homeDirectory", default_home) org_home = Ops.get_string(user, "org_homeDirectory", home) default_mode = Builtins.sformat( "%1", Ops.subtract(777, Builtins.tointeger(String.CutZeros(Users.GetUmask))) ) mode = Ops.get_string(user, "home_mode", default_mode) default_crypted_size = 100 crypted_home_size = GetInt(Ops.get(user, "crypted_home_size"), 0) org_crypted_home_size = GetInt( Ops.get(user, ["org_user", "crypted_home_size"]), 0 ) password = Ops.get_string(user, "userPassword") org_username = Ops.get_string(user, "org_uid", username) uid = GetInt(Ops.get(user, "uidNumber"), nil) gid = GetInt(Ops.get(user, "gidNumber"), Users.GetDefaultGID(user_type)) enabled = Ops.get_boolean(user, "enabled", true) enabled = false if Ops.get_boolean(user, "disabled", false) shell = Ops.get_string(user, "loginShell", "") defaultgroup = Ops.get_string(user, "groupname", "") # additional parts of GECOS (shown by `finger <username>`) (passwd only) addit_data = Ops.get_string(user, "addit_data", "") # this user gets root's mail root_mail = Builtins.haskey(Users.GetRootAliases, username) root_mail_checked = root_mail # if user's password should be set to root root_pw = false # only for LDAP users: sn = "" if Builtins.haskey(user, "sn") if Ops.is_list?(Ops.get(user, "sn")) sn = Ops.get_string(user, ["sn", 0]) { SplitFullName(:sn, cn) } else sn = Ops.get_string(user, "sn") { SplitFullName(:sn, cn) } end end givenname = "" if Builtins.haskey(user, "givenName") if Ops.is_list?(Ops.get(user, "givenName")) givenname = Ops.get_string(user, ["givenName", 0]) do SplitFullName(:givenname, cn) end elsif Ops.is_string?(Ops.get(user, "givenName")) givenname = Ops.get_string(user, "givenName") do SplitFullName(:givenname, cn) end end end create_home = Ops.get_boolean(user, "create_home", true) chown_home = Ops.get_boolean(user, "chown_home", true) no_skel = Ops.get_boolean(user, "no_skeleton", false) do_not_edit = user_type == "nis" crypted_home_enabled = UsersRoutines.CryptedHomesEnabled && (user_type == "ldap" && Ldap.file_server || user_type == "local" || user_type == "system") complex_layout = installation && Users.StartDialog("user_add") groups = Ops.get_map(user, "grouplist", {}) available_shells = Users.AllShells grouplist = "" new_type = user_type all_groupnames = UsersCache.GetAllGroupnames # backup NIS groups of user (they are not shown in details dialog) nis_groups = {} Builtins.foreach(groups) do |group, val| if Ops.get(all_groupnames, ["nis", group], 0) == 1 Ops.set(nis_groups, group, 1) end end # of local group list of remote user was modified grouplist_modified = false # date of passwrod expiration exp_date = "" plugin_client = "" plugin = "" client2plugin = {} # names of plugin GUI clients clients = [] # initialize local variables with current state of user reinit_userdata = lambda do user_type = Ops.get_string(user, "type", user_type) username = Ops.get_string(user, "uid", username) if Ops.is_list?(Ops.get(user, "cn")) cn = Ops.get_string(user, ["cn", 0], cn) else cn = Ops.get_string(user, "cn", cn) end home = Ops.get_string(user, "homeDirectory", home) org_home = Ops.get_string(user, "org_homeDirectory", org_home) crypted_home_size = GetInt(Ops.get(user, "crypted_home_size"), 0) mode = Ops.get_string(user, "home_mode", default_mode) password = Ops.get_string(user, "userPassword", password) org_username = Ops.get_string(user, "org_uid", org_username) uid = GetInt(Ops.get(user, "uidNumber"), uid) gid = GetInt(Ops.get(user, "gidNumber"), gid) enabled = Ops.get_boolean(user, "enabled", true) enabled = false if Ops.get_boolean(user, "disabled", false) shell = Ops.get_string(user, "loginShell", shell) defaultgroup = Ops.get_string(user, "groupname", defaultgroup) addit_data = Ops.get_string(user, "addit_data", addit_data) if Builtins.haskey(user, "sn") if Ops.is_list?(Ops.get(user, "sn")) sn = Ops.get_string(user, ["sn", 0]) { SplitFullName(:sn, cn) } else sn = Ops.get_string(user, "sn") { SplitFullName(:sn, cn) } end end if Builtins.haskey(user, "givenName") if Ops.is_list?(Ops.get(user, "givenName")) givenname = Ops.get_string(user, ["givenName", 0]) do SplitFullName(:givenname, cn) end elsif Ops.is_string?(Ops.get(user, "givenName")) givenname = Ops.get_string(user, "givenName") do SplitFullName(:givenname, cn) end end end chown_home = Ops.get_boolean(user, "chown_home", chown_home) no_skel = Ops.get_boolean(user, "no_skeleton", no_skel) groups = Ops.get_map(user, "grouplist", {}) do_not_edit = user_type == "nis" nil end # helper function: show a popup if existing crypted home directory file # should be used by current user ask_take_image = lambda do |img_file, key_file| # yes/no popup label, %1,%2 are file paths Popup.YesNo( Builtins.sformat( _( "Crypted directory image and key files\n" + "'%1' and '%2'\n" + "were found. Use them for current user?\n" + "\n" + "This means that data from this image will be used instead of current home directory." ), img_file, key_file ) ) end # helper function: show a popup if existing home directory should be used # and its ownership should be changed ask_chown_home = lambda do |dir, chown_default| UI.OpenDialog( Opt(:decorated), HBox( HSpacing(1), VBox( VSpacing(0.2), # popup label, %1 is path to directory Label( Builtins.sformat( _("The home directory (%1) already exists.\nUse it anyway?"), dir ) ), Left( # checkbox label CheckBox( Id(:chown_home), _("&Change directory owner"), chown_default ) ), ButtonBox( PushButton(Id(:yes), Opt(:default), Label.YesButton), PushButton(Id(:no), Label.NoButton) ), VSpacing(0.2) ), HSpacing(1) ) ) ui = UI.UserInput retmap = { "retval" => ui == :yes } if ui == :yes Ops.set(retmap, "chown_home", UI.QueryWidget(Id(:chown_home), :Value)) end UI.CloseDialog deep_copy(retmap) end # generate contents for User Data Dialog get_edit_term = lambda do # text entry fullnamelabel = _("User's &Full Name") name_entries = what == "add_user" ? InputField(Id(:cn), Opt(:notify), fullnamelabel, cn) : InputField(Id(:cn), fullnamelabel, cn) if user_type == "ldap" name_entries = HBox( # text entry InputField(Id(:givenname), _("&First Name"), givenname), HSpacing(0.8), # text entry InputField(Id(:sn), _("&Last Name"), sn) ) end fields = VBox( # label text do_not_edit ? Label( _( "For remote users, only additional group memberships can be changed." ) ) : VSpacing(0), do_not_edit ? VSpacing(1) : VSpacing(0), name_entries, InputField( Id(:username), what == "add_user" ? Opt(:notify, :hstretch) : Opt(:hstretch), # input field for login name _("&Username"), username ), VSpacing(), Password(Id(:pw1), Opt(:hstretch), Label.Password, ""), Password(Id(:pw2), Opt(:hstretch), Label.ConfirmPassword, "") ) optionbox = VBox( # checkbox label Left( CheckBox( Id(:root_mail), _("Receive S&ystem Mail"), root_mail_checked ) ) ) if complex_layout optionbox = Builtins.add( optionbox, # checkbox label Left( CheckBox(Id(:autologin), _("A&utomatic Login"), Autologin.used) ) ) root_pw_feature = ProductFeatures.GetFeature( "globals", "root_password_as_first_user" ) if root_pw_feature != "" optionbox = Builtins.add( optionbox, Left( CheckBox( Id(:root_pw), # checkbox label _("U&se this password for system administrator"), root_pw_feature == true ) ) ) end elsif !do_not_edit && !installation optionbox = Builtins.add( optionbox, # check box label Left(CheckBox(Id(:ena), _("D&isable User Login"), !enabled)) ) end contents = VBox( VSpacing(), VBox( VSpacing(0.5), HBox( HSpacing(2), VBox( HSquash(fields), VSpacing(0.5), HBox(HStretch(), HCenter(HVSquash(optionbox)), HStretch()) ), HSpacing(2) ), VSpacing(0.5) ) ) if complex_layout contents = Builtins.add( contents, VBox( HCenter( PushButton( Id(:additional), Opt(:key_F3), # push button _("User &Management") ) ), VSpacing(0.5) ) ) end HVCenter(contents) end # generate contents for User Details Dialog get_details_term = lambda do available_groups = [] additional_groups = [] additional_ldap_groups = [] defaultgroup_shown = false # fill the list available_groups and set the user default group true Builtins.foreach(all_groupnames) do |grouptype, groupmap| if grouptype == "local" || grouptype == "system" || grouptype == "ldap" && user_type == "ldap" Builtins.foreach(groupmap) do |group, val| if user_type == "ldap" if grouptype == "ldap" if group == defaultgroup available_groups = Builtins.add( available_groups, Item(Id(group), group, true) ) defaultgroup_shown = true else available_groups = Builtins.add( available_groups, Item(Id(group), group) ) end if Builtins.haskey(groups, group) additional_ldap_groups = Builtins.add( additional_ldap_groups, Item(Id(group), group, true) ) else additional_ldap_groups = Builtins.add( additional_ldap_groups, Item(Id(group), group, false) ) end else # if there is a group with same name, use only that # with type "ldap" next if Ops.get(all_groupnames, ["ldap", group], 0) == 1 if Builtins.haskey(groups, group) additional_groups = Builtins.add( additional_groups, Item(Id(group), group, true) ) else additional_groups = Builtins.add( additional_groups, Item(Id(group), group, false) ) end end else if group == defaultgroup available_groups = Builtins.add( available_groups, Item(Id(group), group, true) ) defaultgroup_shown = true else available_groups = Builtins.add( available_groups, Item(Id(group), group) ) end if Builtins.haskey(groups, group) additional_groups = Builtins.add( additional_groups, Item(Id(group), group, true) ) else additional_groups = Builtins.add( additional_groups, Item(Id(group), group, false) ) end end end end end # show default group, even if the type is 'wrong' (#43433) if !defaultgroup_shown if Ops.get(all_groupnames, ["local", defaultgroup], 0) == 1 || Ops.get(all_groupnames, ["system", defaultgroup], 0) == 1 available_groups = Builtins.add( available_groups, Item(Id(defaultgroup), defaultgroup, true) ) end end if defaultgroup == "" available_groups = Builtins.add( available_groups, # group name is not known (combobox item): Item(Id(""), _("(Unknown)"), true) ) end edit_defaultgroup = ComboBox( Id(:defaultgroup), Opt(:hstretch), # combobox label _("De&fault Group"), available_groups ) edit_shell = ComboBox( Id(:shell), Opt(:hstretch, :editable), # combobox label _("Login &Shell"), available_shells ) additional_data = Empty() if user_type == "system" || user_type == "local" additional_data = Top( InputField( Id(:addd), Opt(:hstretch), # textentry label _("Addi&tional User Information"), addit_data ) ) end browse = VBox( Label(""), # button label PushButton(Id(:browse), Opt(:key_F6), _("B&rowse...")), action != "edited" ? Empty() : Label("") ) home_w = VBox( # textentry label InputField(Id(:home), Opt(:hstretch), _("&Home Directory"), home), action != "edited" ? Empty() : HBox( HSpacing(), Left( CheckBox( Id(:move_home), # check box label _("&Move to New Location"), create_home ) ) ) ) new_user_term = action != "added" ? VBox() : VBox( InputField( Id(:mode), Opt(:hstretch), # textentry label _("Home Directory &Permission Mode"), mode ), # check box label HBox( HSpacing(), Left(CheckBox(Id(:skel), _("E&mpty Home"), no_skel)) ) ) crypted_home_term = crypted_home_enabled ? HBox( VBox( Label(""), HBox( HSpacing(), Left( CheckBox( Id(:crypted_home), Opt(:notify), # check box label _("&Use Encrypted Home Directory"), Ops.greater_than(crypted_home_size, 0) ) ) ) ), # for max value, see bug 244631 :-) # IntField label IntField( Id(:dirsize), _("&Directory Size in MB"), 10, 2147483647, crypted_home_size ) ) : HBox() HBox( HSpacing(1), VBox( # label do_not_edit ? Label( _( "For remote users, only additional \ngroup memberships can be changed." ) ) : VSpacing(0), VSpacing(0.5), HBox( text_mode ? Empty() : HSpacing(1), HWeight( 3, VBox( VSpacing(0.5), Top( InputField( Id(:uid), Opt(:hstretch), # textentry label _("User &ID (uid)"), Builtins.sformat("%1", uid) ) ), Top( VBox(HBox(home_w, browse), new_user_term, crypted_home_term) ), additional_data, Top(edit_shell), Top(edit_defaultgroup), VStretch() ) ), text_mode ? Empty() : HSpacing(2), HWeight( 2, VBox( VSpacing(0.5), MultiSelectionBox( Id(:grouplist), # selection box label _("Additional Gr&oups"), additional_groups ), user_type == "ldap" ? MultiSelectionBox( Id(:ldapgrouplist), # selection box label _("&LDAP Groups"), additional_ldap_groups ) : Empty() ) ), text_mode ? Empty() : HSpacing(1) ), VSpacing(0.5) ), HSpacing(1) ) end # generate contents for Password Settings Dialog get_password_term = lambda do last_change = GetString(Ops.get(user, "shadowLastChange"), "0") last_change_label = "" expires = GetString(Ops.get(user, "shadowExpire"), "0") expires = "0" if expires == "" inact = GetInt(Ops.get(user, "shadowInactive"), -1) max = GetInt(Ops.get(user, "shadowMax"), -1) min = GetInt(Ops.get(user, "shadowMin"), -1) warn = GetInt(Ops.get(user, "shadowWarning"), -1) if last_change != "0" out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "date --date='1970-01-01 00:00:01 %1 days' +\"%%x\"", last_change ) ) ) # label (date of last password change) last_change_label = Ops.get_locale(out, "stdout", _("Unknown")) else # label (date of last password change) last_change_label = _("Never") end if expires != "0" && expires != "-1" && expires != "" out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Ops.add( Builtins.sformat( "date --date='1970-01-01 00:00:01 %1 days' ", expires ), "+\"%Y-%m-%d\"" ) ) ) # remove \n from the end exp_date = Builtins.deletechars( Ops.get_string(out, "stdout", ""), "\n" ) end HBox( HSpacing(3), VBox( VStretch(), Left(Label("")), HSquash( VBox( Left( Label( Builtins.sformat( # label _("Last Password Change: %1"), last_change_label ) ) ), VSpacing(0.2), Left( # check box label CheckBox( Id(:force_pw), _("Force Password Change"), last_change == "0" ) ), VSpacing(1), IntField( Id("shadowWarning"), # intfield label _("Days &before Password Expiration to Issue Warning"), -1, 99999, warn ), VSpacing(0.5), IntField( Id("shadowInactive"), # intfield label _("Days after Password Expires with Usable &Login"), -1, 99999, inact ), VSpacing(0.5), IntField( Id("shadowMax"), # intfield label _("Ma&ximum Number of Days for the Same Password"), -1, 99999, max ), VSpacing(0.5), IntField( Id("shadowMin"), # intfield label _("&Minimum Number of Days for the Same Password"), -1, 99999, min ), VSpacing(0.5), InputField( Id("shadowExpire"), Opt(:hstretch), # textentry label _("Ex&piration Date"), exp_date ) ) ), VStretch() ), HSpacing(3) ) end # generate contents for Plugins Dialog get_plugins_term = lambda do plugin_client = Ops.get(clients, 0, "") plugin = Ops.get_string(client2plugin, plugin_client, plugin_client) items = [] Builtins.foreach(clients) do |cl| summary = WFM.CallFunction(cl, ["Summary", { "what" => "user" }]) pl = Ops.get_string(client2plugin, cl, cl) if Ops.is_string?(summary) items = Builtins.add( items, Item( Id(cl), Builtins.contains(Ops.get_list(user, "plugins", []), pl) ? UI.Glyph(:CheckMark) : " ", summary ) ) end end HBox( HSpacing(0.5), VBox( Table( Id(:table), Opt(:notify), Header( " ", # table header _("Plug-In Description") ), items ), HBox( PushButton( Id(:change), Opt(:key_F3), # pushbutton label _("Add &or Remove Plug-In") ), # pushbutton label Right(PushButton(Id(:run), Opt(:key_F6), _("&Launch"))) ), VSpacing(0.5) ), HSpacing(0.5) ) end dialog_labels = { "add_user" => { # dialog caption: "local" => _("New Local User"), # dialog caption: "system" => _("New System User"), # dialog caption: "ldap" => _("New LDAP User") }, "edit_user" => { # dialog caption: "local" => _("Existing Local User"), # dialog caption: "system" => _("Existing System User"), # dialog caption: "ldap" => _("Existing LDAP User"), # dialog caption: "nis" => _("Existing NIS User") } } tabs = [ # tab label Item(Id(:edit), _("Us&er Data"), true), # tab label Item(Id(:details), _("&Details")) ] if !do_not_edit && user_type != "ldap" # tab label tabs = Builtins.add( tabs, Item(Id(:passwordsettings), _("Pass&word Settings")) ) end # Now initialize the list of plugins: we must know now if there is some available. # UsersPlugins will filter out plugins we cannot use for given type plugin_clients = UsersPlugins.Apply( "GUIClient", { "what" => "user", "type" => user_type }, {} ) # remove empty clients plugin_clients = Builtins.filter( Convert.convert( plugin_clients, :from => "map", :to => "map <string, string>" ) ) { |plugin2, client| client != "" } clients = Builtins.maplist( Convert.convert( plugin_clients, :from => "map", :to => "map <string, string>" ) ) do |plugin2, client| Ops.set(client2plugin, client, plugin2) client end if clients != [] # tab label tabs = Builtins.add(tabs, Item(Id(:plugins), _("Plu&g-Ins"))) end dialog_contents = VBox( DumbTab( Id(:tabs), tabs, ReplacePoint(Id(:tabContents), get_edit_term.call) ) ) has_tabs = true if !UI.HasSpecialWidget(:DumbTab) has_tabs = false = HBox() Builtins.foreach(tabs) do |it| label = Ops.get_string(it, 1, "") = Builtins.add(, PushButton(Ops.get_term(it, 0) do Id(label) end, label)) end dialog_contents = VBox( Left(), Frame("", ReplacePoint(Id(:tabContents), get_edit_term.call)) ) end if complex_layout dialog_contents = ReplacePoint(Id(:tabContents), get_edit_term.call) Wizard.SetContents( Ops.get_string(dialog_labels, [what, user_type], ""), dialog_contents, EditUserDialogHelp(complex_layout, user_type, what), GetInstArgs.enable_back, GetInstArgs.enable_next ) else Wizard.SetContentsButtons( Ops.get_string(dialog_labels, [what, user_type], ""), dialog_contents, EditUserDialogHelp(complex_layout, user_type, what), Label.CancelButton, Label.OKButton ) Wizard.HideAbortButton end ret = :edit current = nil login_modified = false tabids = [:edit, :details, :passwordsettings, :plugins] ldap_user_defaults = UsersLDAP.GetUserDefaults # switch focus to specified tab (after error message) and widget inside focus_tab = lambda do |tab, | = deep_copy() UI.ChangeWidget(Id(:tabs), :CurrentItem, tab) if has_tabs UI.SetFocus(Id()) ret = :notnext nil end # map with id's of confirmed questions ui_map = {} while true # map returned from Check*UI functions error_map = {} # error message error = "" ret = Convert.to_symbol(UI.UserInput) if current != nil if (ret == :abort || ret == :cancel) && ReallyAbort() != :abort ret = :notnext next end break if Builtins.contains([:abort, :back, :cancel], ret) ret = :next if ret == :ok tab = Builtins.contains(tabids, ret) next if tab && ret == current # ------------------- handle actions inside the tabs # 1. click inside User Data dialog or moving outside of it if current == :edit 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") # 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 if Popup.YesNoHeadline( _("Empty User Login"), # yes-no popup contents _( "Leaving the user name empty only makes sense\n" + "in a network environment with an authentication server.\n" + "Leave it empty?" ) ) ret = :nextmodule break end focus_tab.call(current, :username) next end # now gather user data from dialog if user_type == "ldap" # Form the fullname for LDAP user # sn (surname) and cn (fullname) are required attributes, # they cannot be empty givenname = Convert.to_string( UI.QueryWidget(Id(:givenname), :Value) ) sn = Convert.to_string(UI.QueryWidget(Id(:sn), :Value)) # create default cn/sn if they are not marked for substitution if sn == "" && (what == "edit_user" || !Builtins.haskey(ldap_user_defaults, "sn")) if givenname == "" sn = username else sn = givenname givenname = "" end end if cn == "" && # no substitution when editing: TODO bug 238282 (what == "edit_user" || !# cn should not be substitued: Builtins.haskey(ldap_user_defaults, "cn")) # if 'givenname' or 'sn' should be substitued, wait for it # and do not create cn now: if !Builtins.haskey(ldap_user_defaults, "sn") && !Builtins.haskey(ldap_user_defaults, "givenName") cn = Ops.add(Ops.add(givenname, givenname != "" ? " " : ""), sn) end end UI.ChangeWidget(Id(:givenname), :Value, givenname) UI.ChangeWidget(Id(:sn), :Value, sn) else cn = Convert.to_string(UI.QueryWidget(Id(:cn), :Value)) error = UsersSimple.CheckFullname(cn) if error != "" Report.Error(error) focus_tab.call(current, :cn) next end end if Builtins.haskey(user, "givenName") && Ops.is_list?(Ops.get(user, "givenName")) Ops.set(user, ["givenName", 0], givenname) else Ops.set(user, "givenName", givenname) end if Builtins.haskey(user, "sn") && Ops.is_list?(Ops.get(user, "sn")) Ops.set(user, ["sn", 0], sn) else Ops.set(user, "sn", sn) end if Builtins.haskey(user, "cn") && Ops.is_list?(Ops.get(user, "cn")) Ops.set(user, ["cn", 0], cn) else Ops.set(user, "cn", cn) end # generate a login name from the full name # (not for LDAP, there are customized rules...) if ret == :cn uname = Convert.to_string(UI.QueryWidget(Id(:username), :Value)) login_modified = false if login_modified && uname == "" # reenable suggestion if !login_modified full = Convert.to_string(UI.QueryWidget(Id(ret), :Value)) full = Ops.get(Builtins.splitstring(full, " "), 0, "") full = UsersSimple.Transliterate(full) UI.ChangeWidget( Id(:username), :Value, Builtins.tolower( Builtins.filterchars(full, UsersSimple.ValidLognameChars) ) ) end end login_modified = true if ret == :username # in continue mode: move to 'User Management' without adding user if ret == :additional if username == "" && (user_type == "ldap" && cn == "" && givenname == "" || user_type != "ldap" && cn == "") ret = :nosave end end end # now check if currently added user data are correct # (going out from User Data tab) if current == :edit && !do_not_edit && (ret == :next || ret == :additional || tab) # --------------------------------- username checks, part 1/2 error = Users.CheckUsername(username) if error != "" Report.Error(error) focus_tab.call(current, :username) next end Ops.set(user, "uid", username) # --------------------------------- uid check (for nil value) if !tab && uid == nil error = Users.CheckUID(uid) if error != "" Report.Error(error) focus_tab.call(current, :details) next end end # --------------------------------- password checks pw1 = Convert.to_string(UI.QueryWidget(Id(:pw1), :Value)) pw2 = Convert.to_string(UI.QueryWidget(Id(:pw2), :Value)) if pw1 != pw2 # The two user password information do not match # error popup Report.Error(_("The passwords do not match.\nTry again.")) focus_tab.call(current, :pw1) next end if (pw1 != "" || !tab) && pw1 != @default_pw error = UsersSimple.CheckPassword(pw1, user_type) if error != "" Report.Error(error) focus_tab.call(current, :pw1) next end errors = UsersSimple.CheckPasswordUI( { "uid" => username, "userPassword" => pw1, "type" => user_type } ) if errors != [] = Ops.add( Ops.add( Builtins.mergestring(errors, "\n\n"), # last part of message popup "\n\n" ), _("Really use this password?") ) if !Popup.YesNo() focus_tab.call(current, :pw1) next end end # now saving plain text password if Ops.get_boolean(user, "encrypted", false) Ops.set(user, "encrypted", false) end Ops.set(user, "userPassword", pw1) Ops.set(user, "shadowLastChange", Users.LastChangeIsNow) password = pw1 end # build default home dir if home == "" || home == default_home || Builtins.issubstring(home, "%") # LDAP: maybe value of homedirectory should be substituted? if user_type == "ldap" && Builtins.issubstring(home, "%") user = UsersLDAP.SubstituteValues("user", user) home = Ops.get_string(user, "homeDirectory", default_home) end if home == default_home || home == "" home = Ops.add(default_home, username) end end if ret != :details && username != org_username generated_home = Ops.add(default_home, username) if user_type == "ldap" && Builtins.issubstring(default_home, "%") tmp_user = UsersLDAP.SubstituteValues("user", user) generated_home = Ops.get_string(tmp_user, "homeDirectory", home) end if home != generated_home && (what == "add_user" || Popup.YesNo( Builtins.sformat( # popup question _("Change home directory to %1?"), generated_home ) )) home = generated_home end end # -------------------------------------- directory checks if !tab && home != org_home error = Users.CheckHome(home) if error != "" Report.Error(error) ret = :notnext next end failed = false begin error_map = Users.CheckHomeUI(uid, home, ui_map) if error_map != {} if Ops.get_string(error_map, "question_id", "") == "chown" && !Builtins.haskey(error_map, "owned") ret2 = ask_chown_home.call(home, chown_home) if Ops.get_boolean(ret2, "retval", false) Ops.set(ui_map, "chown", home) chown_home = Ops.get_boolean(ret2, "chown_home", chown_home) else failed = true end else if !Popup.YesNo(Ops.get_string(error_map, "question", "")) failed = true else Ops.set( ui_map, Ops.get_string(error_map, "question_id", ""), home ) end end end end while error_map != {} && !failed if failed ret = :notnext next end end Ops.set(user, "homeDirectory", home) Ops.set(user, "chown_home", chown_home) # --------------------------------- username checks, part 2/2 if what == "add_user" || username != org_username if AskForUppercasePopup(username) != :ok focus_tab.call(current, :username) next end end # --------------------------------- autologin (during installation) if Users.StartDialog("user_add") && installation if Autologin.available Autologin.user = Convert.to_boolean( UI.QueryWidget(Id(:autologin), :Value) ) ? username : "" Autologin.used = Convert.to_boolean( UI.QueryWidget(Id(:autologin), :Value) ) Autologin.modified = true end elsif UI.WidgetExists(Id(:ena)) # -------------------------------------- enable/disable checks new_enabled = !Convert.to_boolean(UI.QueryWidget(Id(:ena), :Value)) if enabled != new_enabled enabled = new_enabled if enabled Ops.set(user, "enabled", true) if Builtins.haskey(user, "disabled") Ops.set(user, "disabled", false) end else Ops.set(user, "disabled", true) if Builtins.haskey(user, "enabled") Ops.set(user, "enabled", false) end end end end root_mail_checked = Convert.to_boolean( UI.QueryWidget(Id(:root_mail), :Value) ) root_pw = UI.WidgetExists(Id(:root_pw)) && Convert.to_boolean(UI.QueryWidget(Id(:root_pw), :Value)) # save the username for possible check if it was changed # and home directory should be re-generated org_username = username if org_username == "" end # indide Details dialog if current == :details && ret == :browse dir = home if SCR.Read(path(".target.size"), home) == -1 dir = Users.GetDefaultHome(new_type) end dir = UI.AskForExistingDirectory(dir, "") if dir != nil if Ops.add(Builtins.findlastof(dir, "/"), 1) == Builtins.size(dir) dir = Builtins.substring( dir, 0, Ops.subtract(Builtins.size(dir), 1) ) end UI.ChangeWidget(Id(:home), :Value, dir) end end if current == :details && ret == :crypted_home checked = Convert.to_boolean( UI.QueryWidget(Id(:crypted_home), :Value) ) if !checked && UserLogged(org_username) # error popup Report.Error( _( "The home directory for this user cannot be decrypted,\n" + "because the user is currently logged in.\n" + "Log the user out first." ) ) UI.ChangeWidget(Id(:crypted_home), :Value, true) next end if checked && Convert.to_integer(UI.QueryWidget(Id(:dirsize), :Value)) == 10 UI.ChangeWidget(Id(:dirsize), :Value, default_crypted_size) end UI.ChangeWidget(Id(:dirsize), :Enabled, checked) end # going from Details dialog if current == :details && (ret == :next || tab) new_shell = Convert.to_string(UI.QueryWidget(Id(:shell), :Value)) new_uid = Convert.to_string(UI.QueryWidget(Id(:uid), :Value)) new_defaultgroup = Convert.to_string( UI.QueryWidget(Id(:defaultgroup), :Value) ) new_home = Convert.to_string(UI.QueryWidget(Id(:home), :Value)) if what == "add_user" no_skel = Convert.to_boolean(UI.QueryWidget(Id(:skel), :Value)) mode = Convert.to_string(UI.QueryWidget(Id(:mode), :Value)) end if Ops.add(Builtins.findlastof(new_home, "/"), 1) == Builtins.size(new_home) new_home = Builtins.substring( new_home, 0, Ops.subtract(Builtins.size(new_home), 1) ) end if do_not_edit new_home = home new_shell = shell new_uid = Builtins.sformat("%1", uid) new_defaultgroup = defaultgroup end new_i_uid = Builtins.tointeger(new_uid) # additional data in GECOS field (passwd only) if new_type == "local" || new_type == "system" addit_data = Convert.to_string(UI.QueryWidget(Id(:addd), :Value)) error2 = Users.CheckGECOS(addit_data) if error2 != "" Report.Error(error2) focus_tab.call(current, :addd) ret = :notnext next end end # check the uid if new_i_uid != uid error2 = Users.CheckUID(new_i_uid) if error2 != "" Report.Error(error2) focus_tab.call(current, :uid) next end failed = false begin error_map = Users.CheckUIDUI(new_i_uid, ui_map) if error_map != {} if !Popup.YesNo(Ops.get_string(error_map, "question", "")) focus_tab.call(current, :uid) failed = true else Ops.set( ui_map, Ops.get_string(error_map, "question_id", ""), new_i_uid ) if Builtins.contains( ["local", "system"], Ops.get_string(error_map, "question_id", "") ) new_type = Ops.get_string(error_map, "question_id", "local") UsersCache.SetUserType(new_type) end end end end while error_map != {} && !failed if failed focus_tab.call(current, :uid) next end end # end of uid checks if defaultgroup != new_defaultgroup g = Users.GetGroupByName(new_defaultgroup, new_type) g = Users.GetGroupByName(new_defaultgroup, "") if g == {} gid = GetInt(Ops.get(g, "gidNumber"), gid) end # check the homedirectory if home != new_home || what == "add_user" error2 = Users.CheckHome(new_home) if error2 != "" Report.Error(error2) focus_tab.call(current, :home) next end failed = false begin error_map = Users.CheckHomeUI(new_i_uid, new_home, ui_map) if error_map != {} if Ops.get_string(error_map, "question_id", "") == "chown" && !Builtins.haskey(error_map, "owned") ret2 = ask_chown_home.call(new_home, chown_home) if Ops.get_boolean(ret2, "retval", false) Ops.set(ui_map, "chown", new_home) chown_home = Ops.get_boolean(ret2, "chown_home", chown_home) else failed = true end else if !Popup.YesNo(Ops.get_string(error_map, "question", "")) failed = true else Ops.set( ui_map, Ops.get_string(error_map, "question_id", ""), new_home ) end end end end while error_map != {} && !failed if failed focus_tab.call(current, :home) next end end if crypted_home_enabled home_size = Convert.to_integer(UI.QueryWidget(Id(:dirsize), :Value)) if Convert.to_boolean(UI.QueryWidget(Id(:crypted_home), :Value)) if home_size == 0 # error popup Popup.Error(_("Enter the size for the home directory.")) focus_tab.call(current, :dirsize) next end crypted_home_size = home_size else crypted_home_size = 0 end end error_map = Users.CheckShellUI(new_shell, ui_map) if error_map != {} if !Popup.YesNo(Ops.get_string(error_map, "question", "")) focus_tab.call(current, :shell) next else Ops.set( ui_map, Ops.get_string(error_map, "question_id", ""), new_shell ) end end # generate new map of groups (NIS groups were not shown!) new_groups = Builtins.listmap( Convert.convert( UI.QueryWidget(Id(:grouplist), :SelectedItems), :from => "any", :to => "list <string>" ) ) { |g| { g => 1 } } if new_type == "ldap" Builtins.foreach( Convert.convert( UI.QueryWidget(Id(:ldapgrouplist), :SelectedItems), :from => "any", :to => "list <string>" ) ) { |group| new_groups = Builtins.add(new_groups, group, 1) } end # now add NIS groups again (were not shown in dialog) Builtins.foreach(nis_groups) do |group, val| if !Builtins.haskey(new_groups, group) new_groups = Builtins.add(new_groups, group, 1) end end # TODO remove from local g. when there is nis g. with same name if do_not_edit && !grouplist_modified && groups != new_groups grouplist_modified = true end if new_home == "/var/lib/nobody" create_home = false chown_home = false end if UI.WidgetExists(Id(:move_home)) && UI.QueryWidget(Id(:move_home), :Value) == false create_home = false end home = new_home shell = new_shell uid = new_i_uid groups = deep_copy(new_groups) defaultgroup = new_defaultgroup user_type = new_type Ops.set(user, "homeDirectory", new_home) Ops.set(user, "loginShell", new_shell) Ops.set(user, "gidNumber", gid) Ops.set(user, "uidNumber", new_i_uid) Ops.set(user, "grouplist", new_groups) Ops.set(user, "groupname", new_defaultgroup) Ops.set(user, "type", new_type) Ops.set(user, "create_home", create_home) Ops.set(user, "chown_home", chown_home) Ops.set(user, "addit_data", addit_data) Ops.set(user, "no_skeleton", no_skel) Ops.set(user, "home_mode", mode) Ops.set(user, "crypted_home_size", crypted_home_size) end if current == :passwordsettings && (ret == :next || tab) exp = Convert.to_string(UI.QueryWidget(Id("shadowExpire"), :Value)) if exp != "" && !Builtins.regexpmatch( exp, "[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" ) # popup text: Don't reorder the letters YYYY-MM-DD!!! # The date must stay in this format Popup.Message( _("The expiration date must be in the format YYYY-MM-DD.") ) focus_tab.call(current, "shadowExpire") next end Builtins.foreach( ["shadowWarning", "shadowMax", "shadowMin", "shadowInactive"] ) do |shadowsymbol| if Ops.get(user, shadowsymbol) != UI.QueryWidget(Id(shadowsymbol), :Value) Ops.set( user, shadowsymbol, Builtins.sformat("%1", UI.QueryWidget(Id(shadowsymbol), :Value)) ) end end new_exp_date = Convert.to_string( UI.QueryWidget(Id("shadowExpire"), :Value) ) if new_exp_date != exp_date exp_date = new_exp_date if exp_date == "" Ops.set(user, "shadowExpire", user_type == "ldap" ? "" : "0") else out = Convert.to_map( SCR.Execute( path(".target.bash_output"), Ops.add( Builtins.sformat("date --date='%1 UTC' ", exp_date), "+%s" ) ) ) seconds_s = Builtins.deletechars( Ops.get_string(out, "stdout", "0"), "\n" ) if seconds_s != "" days = Ops.divide(Builtins.tointeger(seconds_s), 60 * 60 * 24) Ops.set(user, "shadowExpire", Builtins.sformat("%1", days)) end end end if UI.QueryWidget(Id(:force_pw), :Value) == true # force password change Ops.set(user, "shadowLastChange", "0") end end # inside plugins dialog if current == :plugins plugin_client = Convert.to_string( UI.QueryWidget(Id(:table), :CurrentItem) ) if plugin_client != nil plugin = Ops.get_string(client2plugin, plugin_client, plugin_client) end if ret == :table || ret == :change ret = Builtins.contains(Ops.get_list(user, "plugins", []), plugin) ? :del : :add end if ret == :del out = UsersPlugins.Apply( "PluginRemovable", { "what" => "user", "type" => user_type, "plugins" => [plugin] }, {} ) # check if plugin _could_ be deleted! if Builtins.haskey(out, plugin) && !Ops.get_boolean(out, plugin, false) # popup message Popup.Message(_("This plug-in cannot be removed.")) ret = :not_next next end end if ret == :add || ret == :del || ret == :run # functions for adding/deleting/launching plugin work on # Users::user_in_work, so we must update it before if what == "edit_user" Users.EditUser(user) else Users.AddUser(user) end end if ret == :add error = Users.AddUserPlugin(plugin) if error != "" Popup.Error(error) ret = :notnext next end user = Users.GetCurrentUser reinit_userdata.call UI.ChangeWidget( Id(:table), term(:Item, plugin_client, 0), UI.Glyph(:CheckMark) ) end if ret == :del error = Users.RemoveUserPlugin(plugin) if error != "" Popup.Error(error) ret = :notnext next end user = Users.GetCurrentUser reinit_userdata.call UI.ChangeWidget(Id(:table), term(:Item, plugin_client, 0), " ") end if ret == :run plugin_added = false # first, add the plugin if necessary if !Builtins.contains(Ops.get_list(user, "plugins", []), plugin) error = Users.AddUserPlugin(plugin) if error != "" Popup.Error(error) ret = :notnext next end plugin_added = true user = Users.GetCurrentUser reinit_userdata.call end plugin_ret = WFM.CallFunction( plugin_client, ["Dialog", { "what" => "user" }, user] ) if plugin_ret == :next # update the map of changed user user = Users.GetCurrentUser reinit_userdata.call UI.ChangeWidget( Id(:table), term(:Item, plugin_client, 0), UI.Glyph(:CheckMark) ) # for `cancel we must remove the plugin if it was added because of `run elsif plugin_added error = Users.RemoveUserPlugin(plugin) if error != "" Popup.Error(error) ret = :notnext next end user = Users.GetCurrentUser reinit_userdata.call end end end # ------------------- now handle switching between the tabs if ret == :edit Wizard.SetHelpText(EditUserDialogHelp(installation, user_type, what)) UI.ReplaceWidget(:tabContents, get_edit_term.call) # update the contets of User Data Dialog if do_not_edit UI.ChangeWidget(Id(:cn), :Enabled, false) UI.ChangeWidget(Id(:username), :Enabled, false) UI.ChangeWidget(Id(:pw1), :Enabled, false) UI.ChangeWidget(Id(:pw2), :Enabled, false) end if what == "add_user" if user_type == "ldap" UI.SetFocus(Id(:givenname)) else UI.SetFocus(Id(:cn)) end end if password != nil || what == "edit_user" UI.ChangeWidget(Id(:pw1), :Value, @default_pw) UI.ChangeWidget(Id(:pw2), :Value, @default_pw) end if complex_layout && !Autologin.available UI.ChangeWidget(Id(:autologin), :Enabled, false) UI.ChangeWidget(Id(:autologin), :Value, false) end # LDAP users can be disabled only with certain plugins (bnc#557714) if UI.WidgetExists(Id(:ena)) && user_type == "ldap" ena = Builtins.contains( Ops.get_list(user, "plugins", []), "UsersPluginLDAPShadowAccount" ) || Builtins.contains( Ops.get_list(user, "plugins", []), "UsersPluginLDAPPasswordPolicy" ) UI.ChangeWidget(Id(:ena), :Enabled, ena) end current = ret end if ret == :details UI.ReplaceWidget(:tabContents, get_details_term.call) Wizard.SetHelpText(EditUserDetailsDialogHelp(user_type, what)) if do_not_edit UI.ChangeWidget(Id(:uid), :Enabled, false) UI.ChangeWidget(Id(:home), :Enabled, false) UI.ChangeWidget(Id(:move_home), :Enabled, false) UI.ChangeWidget(Id(:shell), :Enabled, false) UI.ChangeWidget(Id(:defaultgroup), :Enabled, false) UI.ChangeWidget(Id(:browse), :Enabled, false) end if user_type == "ldap" && !Ldap.file_server UI.ChangeWidget(Id(:browse), :Enabled, false) if UI.WidgetExists(Id(:move_home)) UI.ChangeWidget(Id(:move_home), :Enabled, false) end end if !FileUtils.Exists(home) && UI.WidgetExists(Id(:move_home)) UI.ChangeWidget(Id(:move_home), :Enabled, false) end if UI.WidgetExists(Id(:mode)) UI.ChangeWidget(Id(:mode), :ValidChars, "01234567") UI.ChangeWidget(Id(:mode), :InputMaxLength, 3) end UI.ChangeWidget(Id(:shell), :Value, shell) if UI.WidgetExists(Id(:crypted_home)) UI.ChangeWidget( Id(:dirsize), :Enabled, Convert.to_boolean(UI.QueryWidget(Id(:crypted_home), :Value)) ) end current = ret end if ret == :passwordsettings UI.ReplaceWidget(:tabContents, get_password_term.call) if GetString(Ops.get(user, "shadowLastChange"), "0") == "0" # forcing password change cannot be undone UI.ChangeWidget(Id(:force_pw), :Enabled, false) end Wizard.SetHelpText(EditUserPasswordDialogHelp()) current = ret end if ret == :plugins UI.ReplaceWidget(:tabContents, get_plugins_term.call) Wizard.SetHelpText(PluginDialogHelp()) UI.ChangeWidget(Id(:table), :CurrentItem, plugin_client) current = ret end if (ret == :next || ret == :additional) && # for do_not_edit, there may be a change in groups (Details dialog) (!do_not_edit || grouplist_modified) # --------------------------------- final check error = Users.CheckUser(user) if error != "" Report.Error(error) ret = :notnext next end if crypted_home_enabled && action == "edited" && Ops.get(user, "current_text_userpassword") == nil && (crypted_home_size != org_crypted_home_size || Ops.greater_than(crypted_home_size, 0) && (org_username != username || org_home != home || Ops.get_boolean( # only password was changed user, "encrypted", false ) == false)) img_file = Builtins.sformat("%1.img", home) key_file = Builtins.sformat("%1.key", home) # ask to take existing orphaned image by user # without current directory encrypted (bnc#425745) if org_crypted_home_size == 0 && FileUtils.Exists(img_file) && FileUtils.Exists(key_file) && UsersRoutines.CryptedImageOwner(img_file) == "" && UsersRoutines.CryptedImageOwner(key_file) == "" && ask_take_image.call(img_file, key_file) Ops.set(user, "take_existing_image", img_file) end # do not ask when enabling for first time and password was already entered # do not ask when taking existing image, pw not needed for that FIXME really? if (Ops.get_boolean(user, "encrypted", false) == false || Ops.get(user, "text_userpassword") != nil || Ops.get_string(user, "take_existing_image", "") != "") && org_crypted_home_size == 0 Ops.set( user, "current_text_userpassword", Ops.get(user, "text_userpassword") != nil ? Ops.get(user, "text_userpassword") : Ops.get_string(user, "userPassword", "") ) else old_pw = AskForOldPassword() if old_pw != nil Ops.set(user, "current_text_userpassword", old_pw) else ret = :notnext next end end end # --------------------------------- save the settings if Builtins.haskey(user, "check_error") user = Builtins.remove(user, "check_error") end if what == "edit_user" error_msg = Users.EditUser(user) else error_msg = Users.AddUser(user) end if error_msg != "" Report.Error(error_msg) ret = :notnext next end # check if autologin is not set for some user if what == "add_user" && !complex_layout && # ask only when there is still one user (bnc#332729) Builtins.size(UsersCache.GetUsernames("local")) == 1 Autologin.AskForDisabling( # popup text _("Now you have added a new user.") ) end if root_mail_checked Users.RemoveRootAlias(org_username) if username != org_username Users.AddRootAlias(username) elsif root_mail # not checked now, but checked before if username != org_username Users.RemoveRootAlias(org_username) else Users.RemoveRootAlias(username) end end if username == "root" Users.SaveRootPassword(false) elsif root_pw # set root's password Users.SetRootPassword(password) Users.SaveRootPassword(true) end end if Builtins.contains( [:next, :abort, :back, :cancel, :additional, :nosave], ret ) break end end if ret == :additional || ret == :nosave # during installation, store the data of first user # (to show it when clicking `back from Summary dialog) Users.SaveCurrentUser Users.SetStartDialog("users") end ret end |
- (Symbol) GroupSave
Check the group parameters and commit it if all is OK
2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 |
# File '../../src/include/users/dialogs.rb', line 2637 def GroupSave group = Users.GetCurrentGroup # do not check group which should be deleted if Ops.get_string(group, "what", "") != "delete_group" error = Users.CheckGroup(group) if error != "" Report.Error(error) return :back end end Users.CommitGroup :next end |
- (Object) initialize_users_dialogs(include_target)
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File '../../src/include/users/dialogs.rb', line 31 def initialize_users_dialogs(include_target) textdomain "users" Yast.import "Autologin" Yast.import "GetInstArgs" Yast.import "FileUtils" Yast.import "Label" Yast.import "Ldap" Yast.import "LdapPopup" Yast.import "Message" Yast.import "Package" Yast.import "Popup" Yast.import "ProductFeatures" Yast.import "Report" Yast.import "Stage" Yast.import "String" Yast.import "Users" Yast.import "UsersCache" Yast.import "UsersLDAP" Yast.import "UsersPlugins" Yast.import "UsersRoutines" Yast.import "UsersSimple" Yast.import "Wizard" Yast.include include_target, "users/helps.rb" Yast.include include_target, "users/routines.rb" @default_pw = "******" end |
- (Symbol) UserSave
Just giving paramaters for commiting user
2625 2626 2627 2628 2629 2630 2631 2632 2633 |
# File '../../src/include/users/dialogs.rb', line 2625 def UserSave Users.CommitUser # adding only one user during install if installation && Users.StartDialog("user_add") return :save else return :next end end |