/
dialogs.rb
2659 lines (2507 loc) · 87.5 KB
/
dialogs.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
60
61
62
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
110
111
112
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
157
158
159
160
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
# encoding: utf-8
# ------------------------------------------------------------------------------
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
#
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of version 2 of the GNU General Public License as published by the
# Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, contact Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail, you may find
# current contact information at www.novell.com.
# ------------------------------------------------------------------------------
# File: include/users/wizards.ycp
# Package: Configuration of users and groups
# Summary: Wizards definitions
# Authors: Johannes Buchhold <jbuch@suse.de>,
# Jiri Suchomel <jsuchome@suse.cz>
#
# $Id$
module Yast
module UsersDialogsInclude
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
# Upperase letters were used in username! (see bug #26409)
# In these popup, ask user what to do.
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
# Ask user for current password, see bugs 242531, 244718
# @return [String] or nil when dialog was canceled
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
# Dialog for adding or editing a user.
# @param [String] what "add_user" or "edit_user"
# @return [Symbol] for wizard sequencer
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(