/
ui.rb
2200 lines (2077 loc) · 72.2 KB
/
ui.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/ldap/ui.ycp
# Package: Configuration of LDAP
# Summary: User interface functions.
# Authors: Thorsten Kukuk <kukuk@suse.de>
# Anas Nashif <nashif@suse.de>
#
# $Id$
#
# All user interface functions.
module Yast
module LdapUiInclude
def initialize_ldap_ui(include_target)
Yast.import "UI"
textdomain "ldap-client"
Yast.import "Address"
Yast.import "Autologin"
Yast.import "Directory"
Yast.import "FileUtils"
Yast.import "Label"
Yast.import "Ldap"
Yast.import "LdapPopup"
Yast.import "Message"
Yast.import "Mode"
Yast.import "Package"
Yast.import "Pam"
Yast.import "Popup"
Yast.import "Report"
Yast.import "Service"
Yast.import "SLPAPI"
Yast.import "Stage"
Yast.import "Wizard"
Yast.include include_target, "ldap/routines.rb"
end
def Modified
Ldap.modified || Ldap.ldap_modified
end
# The dialog that appears when the [Abort] button is pressed.
# @return `abort if user really wants to abort, `back otherwise
def ReallyAbort
ret = Modified() || Stage.cont ? Popup.ReallyAbort(true) : true
if ret
return :abort
else
return :back
end
end
# Read settings dialog
# @return `abort if aborted and `next otherwise
def ReadDialog
ret = Ldap.Read
ret ? :next : :abort
end
# Write settings dialog
# @return `next
def WriteDialog
# popup text
abort = lambda do
if UI.PollInput == :abort &&
# popup text
Popup.YesNo(_("Really abort the writing process?"))
next true
end
false
end
if Modified()
# help text
Wizard.RestoreHelp(_("Writing LDAP Client Settings"))
return Ldap.Write(abort)
end
:next
end
# Check syntax of entry with servers:
# multiple adresses are allowed (separated by spaces), address may contain
# port number
def check_address(servers)
ret = true
Builtins.foreach(Builtins.splitstring(servers, " \t")) do |server|
next if server == ""
if Builtins.issubstring(server, ":")
pos = Builtins.search(server, ":")
port = Builtins.substring(server, Ops.add(pos, 1))
if port == "" || Builtins.tointeger(port) == nil
ret = false
else
ret = ret && Address.Check(Builtins.substring(server, 0, pos))
end
else
ret = ret && Address.Check(server)
end
end
ret
end
# Select from LDAP servers provided by SLP
def BrowseServers
servers = ""
UI.OpenDialog(
# popup window
Label(_("Scanning for LDAP servers provided by SLP..."))
)
UI.BusyCursor
items = []
Builtins.foreach(SLPAPI.FindSrvs("service:ldap", "")) do |service|
s = Ops.get_string(service, "pcHost", "")
# TODO take address+port from url
# if (service["pcHost"]:"" == "")
# s = service["srvurl"]:"";
items = Builtins.add(items, s) if s != ""
end
UI.CloseDialog
UI.OpenDialog(
VBox(
HSpacing(36),
ReplacePoint(
Id(:rp),
MultiSelectionBox(
Id(:sel),
# multiselection box label
_("LDAP &Servers Provided by SLP"),
items
)
),
ButtonBox(
PushButton(Id(:ok), Label.OKButton),
PushButton(Id(:cancel), Label.CancelButton)
)
)
)
UI.NormalCursor
ret = ""
begin
ret = UI.UserInput
servers = Builtins.mergestring(
Convert.convert(
UI.QueryWidget(Id(:sel), :SelectedItems),
:from => "any",
:to => "list <string>"
),
" "
)
end while ret != :ok && ret != :cancel
UI.CloseDialog
ret == :ok ? servers : ""
end
# Try to check if certificate file has a valid format (bnc#792413)
# (Just a simple check, for a warning that something might be wrong)
# Return the check result
def check_certificate(file)
# first, check for DER encoded certificate
if FileUtils.Exists("/usr/bin/openssl") &&
SCR.Execute(
path(".target.bash"),
Builtins.sformat("/usr/bin/openssl x509 -in %1 -inform der", file)
) == 0
return true
end
# check the contents of possible plain text certificates
out = Convert.to_map(
SCR.Execute(
path(".target.bash_output"),
Builtins.sformat(
"grep -I '\\-----BEGIN CERTIFICATE' %1 && grep -I '\\-----END CERTIFICATE' %1",
file
)
)
)
if Ops.get_integer(out, "exit", 1) != 0
# warning popup
Popup.Warning(
_("The certificate file does not seem to have valid format.")
)
return false
end
true
end
# Popup for TLS/SSL related stuff
def SSLConfiguration
certTmpFile = Builtins.sformat("%1/__LDAPcert.crt", Directory.tmpdir)
tls_cacertdir = Ldap.tls_cacertdir
tls_cacertfile = Ldap.tls_cacertfile
ldap_id_use_start_tls = Ldap.ldap_tls
UI.OpenDialog(
Opt(:decorated),
HBox(
HSpacing(1),
VBox(
VSpacing(0.5),
HSpacing(75),
Left(
CheckBox(
Id(:ldap_id_use_start_tls),
# checkbox label
_("Use TLS for Identity Resolve"),
ldap_id_use_start_tls
)
),
VSpacing(0.4),
HBox(
InputField(
Id(:tls_cacertdir),
Opt(:hstretch),
# inputfield label
_("Cer&tificate Directory"),
tls_cacertdir
),
VBox(
Bottom(
# button label
PushButton(Id(:br_tls_cacertdir), _("B&rowse"))
)
)
),
HBox(
InputField(
Id(:tls_cacertfile),
Opt(:hstretch),
# inputfield label
_("CA Cert&ificate File"),
tls_cacertfile
),
VBox(
Bottom(
# button label
PushButton(Id(:br_tls_cacertfile), _("Brows&e"))
)
)
),
HBox(
InputField(
Id(:url),
Opt(:hstretch),
# inputfield label
_("CA Certificate URL for Download")
),
VBox(
Bottom(
# push button label
PushButton(Id(:import_cert), _("Do&wnload CA Certificate"))
)
)
),
ButtonBox(
PushButton(Id(:ok), Label.OKButton),
PushButton(Id(:cancel), Label.CancelButton)
),
VSpacing(0.5)
),
HSpacing(1)
)
)
ret = :again
begin
ret = Convert.to_symbol(UI.UserInput)
if ret == :br_tls_cacertdir
dir = UI.AskForExistingDirectory(
tls_cacertdir,
# popup label
_("Choose the directory with certificates")
)
if dir != nil
tls_cacertdir = dir
UI.ChangeWidget(Id(:tls_cacertdir), :Value, dir)
end
elsif ret == :br_tls_cacertfile
file = UI.AskForExistingFile(
tls_cacertfile,
"*.pem *.crt",
# popup label
_("Choose the certificate file")
)
if file != nil
check_certificate(file)
tls_cacertfile = file
UI.ChangeWidget(Id(:tls_cacertfile), :Value, file)
end
else
tls_cacertdir = Convert.to_string(
UI.QueryWidget(Id(:tls_cacertdir), :Value)
)
tls_cacertfile = Convert.to_string(
UI.QueryWidget(Id(:tls_cacertfile), :Value)
)
ldap_id_use_start_tls = UI.QueryWidget(
Id(:ldap_id_use_start_tls),
:Value
) == true
end
if ret == :import_cert
dir = tls_cacertdir
dir = "/etc/openldap/cacerts/" if dir == ""
success = false
name = ""
cert_url = Convert.to_string(UI.QueryWidget(Id(:url), :Value))
curlcmd = Builtins.sformat(
"curl -f --connect-timeout 60 --max-time 120 '%1' -o %2",
cert_url,
certTmpFile
)
if SCR.Execute(path(".target.bash"), curlcmd) != 0
# error message
Popup.Error(
_("Could not download the certificate file from specified URL.")
)
elsif FileUtils.CheckAndCreatePath(dir) &&
check_certificate(certTmpFile)
l = Builtins.splitstring(cert_url, "/")
name = Ops.get(
l,
Ops.subtract(Builtins.size(l), 1),
"downloaded-by-yast2-ldap-client.pem"
)
success = SCR.Execute(
path(".target.bash"),
Builtins.sformat(
"/bin/cp -a '%1' '%2/%3'",
certTmpFile,
dir,
name
)
) == 0
# rehash cert directory (bnc#662937)
out = Convert.to_map(
SCR.Execute(
path(".target.bash_output"),
Builtins.sformat("/usr/bin/c_rehash %1", dir)
)
)
if Ops.get_string(out, "stderr", "") != ""
Builtins.y2error("something went wrong: %1", out)
end
end
if success
# popup message, %1 is file name, %2 directory
Popup.Message(
Builtins.sformat(
_(
"The downloaded certificate file\n" +
"\n" +
"'%1'\n" +
"\n" +
"has been copied to '%2' directory.\n"
),
name,
dir
)
)
tls_cacertdir = dir
Ldap.modified = true
end
end
end while ret != :ok && ret != :cancel
UI.CloseDialog
if ret == :ok
Ldap.tls_cacertfile = tls_cacertfile
Ldap.tls_cacertdir = tls_cacertdir
Ldap.ldap_tls = ldap_id_use_start_tls
end
ret == :ok
end
# The main dialog for ldap-client configuration
# @return `back, `next or `abort
def LdapDialog
# help text 1/9
help_text = _("<p>Set up your machine as an LDAP client.</p>\n") +
# help text 2/9
_(
"<p>To authenticate your users with an OpenLDAP server, select <b>Use LDAP</b>. NSS and PAM will be configured accordingly.</p>"
) +
# help text 3/9
_(
"<p>To deactivate LDAP services, click <b>Do Not Use LDAP</b>.\n" +
"If you deactivate LDAP, the current LDAP entry for passwd in /etc/nsswitch.conf\n" +
"will be removed. The PAM configuration will be modified and the LDAP entry\n" +
"removed.</p>"
) +
# help text 3.5/9
_(
"<p>To activate LDAP but forbid users from logging in to this machine, select <b>Enable LDAP Users but Disable Logins</b>.</p>"
) +
# help text
_(
"<p>Check <b>Use System Security Services Daemon</b> if you want the system to use SSSD instead of nss_ldap.</p>"
) +
# help text 4/9
_(
"<p>Enter the LDAP server's address (such as ldap.example.com or 10.20.0.2) in <b>Addresses</b> and the distinguished name of the search base (<b>Base DN</b>, such as dc=example,dc=com). Specify multiple servers\n" +
"by separating their addresses with spaces. It must be possible to resolve the\n" +
"addresses without using LDAP. You can also specify the port on which the server is running using the syntax \"server:port\", for example, <tt>ldap.example.com:379</tt>.\n" +
"</p>\n"
) +
# help text 5/9
_(
"<p>With <b>Find</b>, select the LDAP server from the list provided by the service location protocol (SLP). Using <b>Fetch DN</b>, read the base DN from server.</p>"
) +
# help text 6/9
_(
"<p>Some LDAP servers support StartTLS (RFC2830).\n" +
"If your server supports it and it is configured, activate <b>LDAP TLS/SSL</b>\n" +
"to encrypt your communication with the LDAP server. You may download a CA\n" +
"certificate file in PEM format from a given URL.</p>\n"
) +
# help text 8/9
_(
"<p>To configure advanced LDAP settings, click\n<b>Advanced Configuration</b>.</p>\n"
)
# help text 9/9 (additional)
autofs_help_text = _(
"<p><b>Automounter</b> is a daemon that automatically mounts directories, such\n" +
"as users' home directories. Its configuration files (auto.*) should already\n" +
"exist locally or over LDAP. If the automounter is not installed yet but you\n" +
"want to use it, it will be installed automatically.</p>\n"
)
# during installation, starting ldap is default
installation = Stage.cont && !Builtins.contains(WFM.Args, "from_users")
start = Ldap.start || installation
base_dn = Ldap.GetBaseDN
server = Ldap.server
ldap_tls = Ldap.ldap_tls
tls_checkpeer = Ldap.tls_checkpeer
login_enabled = Ldap.login_enabled
ssl_changed = false
autofs = Ldap._start_autofs
autofs_con = Empty()
if Ldap._autofs_allowed
autofs_con = VBox(
VSpacing(0.5),
# check box label
Left(CheckBox(Id(:autofs), _("Start Auto&mounter"), autofs))
)
help_text = Ops.add(help_text, autofs_help_text)
end
mkhomedir = Ldap.mkhomedir
mkhomedir_term = VBox(
Left(
CheckBox(
Id(:mkhomedir),
# checkbox label
_("C&reate Home Directory on Login"),
mkhomedir
)
)
)
disable_login_term = VBox(
Left(
CheckBox(
Id(:ldapnologin),
# checkbox label
_("Disable User &Logins"),
!login_enabled
)
)
)
con = VCenter(
HBox(
HSpacing(3),
VBox(
VSpacing(0.5),
# frame label
Frame(
_("User Authentication"),
HBox(
HSpacing(0.5),
VBox(
VSpacing(0.4),
RadioButtonGroup(
Id(:rd),
Left(
HVSquash(
VBox(
Left(
RadioButton(
Id(:ldapno),
Opt(:notify),
# radio button label
_("Do &Not Use LDAP"),
!start
)
),
Left(
RadioButton(
Id(:ldapyes),
Opt(:notify),
# radio button label
_("&Use LDAP"),
start
)
)
)
)
)
),
VSpacing(0.4)
)
)
),
VSpacing(0.4),
# frame label
Frame(
_("LDAP Client"),
HBox(
HSpacing(0.5),
VBox(
VSpacing(0.4),
HBox(
# text entry label
InputField(
Id(:server),
Opt(:hstretch),
_("Addresses of LDAP &Servers"),
server
),
VBox(
Label(""),
# push button label
PushButton(Id(:slp), _("F&ind"))
)
),
HBox(
InputField(
Id(:ldapbasedn),
Opt(:hstretch),
# text entry label
_("LDAP Base &DN"),
base_dn
),
VBox(
Label(""),
# push button label
PushButton(Id(:fetch), _("F&etch DN"))
)
),
VSpacing(0.4)
),
HSpacing(0.5)
)
),
autofs_con,
mkhomedir_term,
disable_login_term,
VSpacing(),
HBox(
# pushbutton label
PushButton(Id(:ssl_config), _("SSL/TLS Configuration...")),
# pushbutton label
PushButton(Id(:advanced), _("&Advanced Configuration..."))
)
),
HSpacing(3)
)
)
Wizard.SetContentsButtons(
# dialog title
_("LDAP Client Configuration"),
con,
help_text,
Stage.cont ? Label.BackButton : Label.CancelButton,
Stage.cont ? Label.NextButton : Label.OKButton
)
if Stage.cont
Wizard.RestoreAbortButton
else
Wizard.HideAbortButton
end
UI.ChangeWidget(
Id(:server),
:ValidChars,
Ops.add(Address.ValidChars, " ")
)
if Ldap.start && !Ldap.sssd
if Popup.ContinueCancel(
# question popup
_(
"Previous LDAP client configuration was detected.\n" +
"\n" +
"Current configuration does not use SSSD but nss_ldap.\n" +
"Only SSSD based configurations are supported by YaST.\n" +
"Do you want to continue and use SSSD or cancel to keep the old configuration?"
)
)
Ldap.sssd = true
ldap_tls = true
else
return :cancel
end
end
result = :not_next
begin
result = Convert.to_symbol(UI.UserInput)
rb = UI.QueryWidget(Id(:rd), :CurrentButton)
start = rb != :ldapno
login_enabled = UI.QueryWidget(Id(:ldapnologin), :Value) != true
server = Convert.to_string(UI.QueryWidget(Id(:server), :Value))
mkhomedir = Convert.to_boolean(UI.QueryWidget(Id(:mkhomedir), :Value))
if result == :ssl_config
ssl_changed = SSLConfiguration() || ssl_changed
ldap_tls = Ldap.ldap_tls # re-read after possible change
end
if result == :slp
srv = ""
if !Package.Installed("yast-slp")
if Package.Install("yast2-slp")
SCR.RegisterAgent(path(".slp"), term(:ag_slp, term(:SlpAgent)))
srv = BrowseServers()
end
else
srv = BrowseServers()
end
UI.ChangeWidget(Id(:server), :Value, srv) if srv != ""
end
if result == :fetch
Ldap.tls_switched_off = false
if Ldap.ldap_initialized && Ldap.tls_when_initialized != ldap_tls
Ldap.LDAPClose
end
dn = Ldap.ldap_initialized ?
LdapPopup.BrowseTree("") :
LdapPopup.InitAndBrowseTree(
"",
{
"hostname" => Ldap.GetFirstServer(server),
"port" => Ldap.GetFirstPort(server),
"use_tls" => ldap_tls ? "yes" : "no",
"cacertdir" => Ldap.tls_cacertdir,
"cacertfile" => Ldap.tls_cacertfile
}
)
UI.ChangeWidget(Id(:ldapbasedn), :Value, dn) if dn != ""
# adapt the checkbox value
UI.ChangeWidget(Id(:ldaps), :Value, false) if Ldap.tls_switched_off
end
if result == :next || result == :advanced
base_dn = Convert.to_string(UI.QueryWidget(Id(:ldapbasedn), :Value))
autofs = Ldap._autofs_allowed &&
Convert.to_boolean(UI.QueryWidget(Id(:autofs), :Value))
end
if (result == :next || result == :advanced) && start
if base_dn == ""
# error popup label
Report.Error(_("Enter an LDAP base DN."))
result = :not_next
next
end
if server == "" || Builtins.deletechars(server, " \t") == ""
# error popup label
Report.Error(_("Enter at least one address of an LDAP server."))
result = :not_next
next
end
if !check_address(server)
# error popup label
Report.Error(
Ops.add(
_("The LDAP server address is invalid.") + "\n\n",
Address.Valid4
)
)
UI.SetFocus(Id(:server))
result = :not_next
next
end
end
if (result == :abort || result == :cancel || result == :back) &&
ReallyAbort() != :abort
result = :not_next
end
if result == :next && (start || autofs)
if start && !Ldap.start && Ldap.nis_available
# popup question: user enabled LDAP now, but probably has
# enabled NIS client before
if !Popup.YesNo(
_(
"When you configure your machine as an LDAP client,\nyou cannot retrieve data with NIS. Really use LDAP instead of NIS?\n"
)
)
result = :not_next
next
end
end
needed_packages = deep_copy(Ldap.sssd_packages)
if Ldap.sssd_with_krb
needed_packages = Convert.convert(
Builtins.union(needed_packages, Ldap.kerberos_packages),
:from => "list",
:to => "list <string>"
)
end
if start && !Package.InstalledAll(needed_packages)
Ldap.required_packages = Convert.convert(
Builtins.union(Ldap.required_packages, needed_packages),
:from => "list",
:to => "list <string>"
)
end
if autofs && !Package.Installed("autofs")
Ldap.required_packages = Convert.convert(
Builtins.union(Ldap.required_packages, ["autofs"]),
:from => "list",
:to => "list <string>"
)
end
if !Package.InstallAll(Ldap.required_packages)
if start && !Package.InstalledAll(needed_packages)
Popup.Error(Message.FailedToInstallPackages)
start = false
result = :not_next
UI.ChangeWidget(Id(:rd), :CurrentButton, :ldapno) if !installation
next
end
end
# test the connection in case of TLS
if start && ldap_tls && Ldap.tls_when_initialized != ldap_tls
args = {
"hostname" => Ldap.GetFirstServer(server),
"port" => Ldap.GetFirstPort(server),
"use_tls" => ldap_tls ? "yes" : "no",
"cacertdir" => Ldap.tls_cacertdir,
"cacertfile" => Ldap.tls_cacertfile
}
if !Mode.config && !Ldap.CheckLDAPConnection(args)
result = :not_next
next
end
end
end
end while !Builtins.contains([:back, :next, :cancel, :abort, :advanced], result)
if result == :next || result == :advanced
if Ldap.start != start || Ldap.GetBaseDN != base_dn ||
Ldap.server != server ||
Ldap.ldap_tls != ldap_tls ||
Ldap._start_autofs != autofs ||
Ldap.login_enabled != login_enabled ||
Ldap.mkhomedir != mkhomedir || ssl_changed
if result == :next
if start && !Ldap.start && !Mode.config
Autologin.AskForDisabling(
# popup text
_("LDAP is now enabled.")
)
message = Stage.cont ?
"" :
# message popup, part 1/2
_(
"This change only affects newly created processes and not already\n" +
"running services. Restart your services manually or reboot \n" +
"the machine to enable it for all services.\n"
)
if Service.Status("sshd") == 0
Ldap.RestartSSHD(true)
# message popup, part 1/2
message = Ops.add(
message,
_(
"\n" +
"To enable remote login for LDAP users, sshd is\n" +
"restarted automatically by YaST.\n"
)
)
end
Popup.Message(message) if message != ""
end
if ldap_tls && tls_checkpeer == "no"
# yes/no question
if Popup.YesNo(
_(
"The security connection is enabled, but server certificate verification is disabled.\nEnable certificate checks now?"
)
)
Ldap.tls_checkpeer = "yes"
end
end
# check if user changed part of imported settings (#252094)
if start && Stage.cont &&
Ops.greater_than(Builtins.size(Ldap.initial_defaults), 0) &&
Ldap.create_ldap &&
server !=
Ops.get_string(Ldap.initial_defaults, "ldap_server", "") &&
base_dn !=
Ops.get_string(Ldap.initial_defaults, "ldap_domain", "") &&
Ldap.bind_dn ==
Ops.get_string(Ldap.initial_defaults, "bind_dn", "") &&
!Builtins.issubstring(Ldap.bind_dn, base_dn)
Builtins.y2warning(
"Server and base DN changed but bind_dn remains imported -> disabling LDAP objects creation..."
)
Ldap.create_ldap = false
end
end
Ldap.SetBaseDN(base_dn)
Ldap.start = start
Ldap.server = server
Ldap.ldap_tls = ldap_tls
Ldap._start_autofs = autofs
Ldap.login_enabled = login_enabled
Ldap.mkhomedir = mkhomedir
Ldap.modified = true
end
end
result
end
# Configuration of advanced settings (how to get to config data on server)
def AdvancedConfigurationDialog
help_text = {
:client => Ops.add(
Ops.add(
# help text caption 1
_("<p><b>Advanced LDAP Client Settings</b></p>") +
# help text 1/3
_(
"<p>If Kerberos authentication should be used, specify the <b>realm</b> and <b>KDC Address</b>.\n" +
"Determine if user credentials should be cached locally by checking <b>SSSD Offline Authentication</b>.\n" +
"For more info about SSSD settings, check the man page of <tt>sssd.conf</tt>.</p>\n"
) +
# help text 2/3
_(
"<p><b>Password Change Protocol</b> refers to the pam_password attribute of the\n<tt>/etc/ldap.conf</tt> file. See <tt>man pam_ldap</tt> for an explanation of its values.</p>"
),
# help text 3/3, %1 is attribute name
Builtins.sformat(
_(
"<p>Set the type of LDAP groups to use.\nThe default value for <b>Group Member Attribute</b> is <i>%1</i>.</p>\n"
),
"member"
)
),
_(
"<p>If secure connection requires certificate checking, specify where your\n" +
"certificate file is located. Enter either a directory containing certificates\n" +
"or the explicit path to one certificate file.</p>"
)
),
:admin =>
# help text caption 2
_("<p><b>Access to Server</b></p>") +
# help text 1/4
_(
"<p>First, set <b>Configuration Base DN</b>.\n" +
"This is the base for storing your configuration data on the LDAP\n" +
"server.</p>\n"
) +
# help text 2/4
_(
"<p>To access the data stored on the server, enter the\n" +
"<b>Administrator DN</b>.\n" +
"You can enter the full DN (for example, cn=Administrator,dc=mydomain,dc=com) or \n" +
"the relative DN (for example, cn=Administrator). The LDAP base DN is appended automatically if the appropriate option is checked.</p>\n"
) +
# help text 3/4
_(
"<p>To create the default configuration objects for LDAP users and groups,\ncheck <b>Create Default Configuration Objects</b>. The objects are only created when they do not already exist.</p>\n"
) +
# help text 4/4
_(
"<p>Press <b>Configure</b> to configure settings stored on the\n" +
"LDAP server. You will be asked for the password if you are not connected yet or\n" +
"have changed your configuration.</p>\n"
),
:searching =>
# help text 1/1
_(
"<p>Specify the search bases to use for specific maps (users or groups) if they are different from the base DN. These values are\nset to the ldap_user_search_base, ldap_group_search_base and ldap_autofs_search_base attributes in /etc/sssd/sssd.conf file.</p>\n"
)
}
bind_dn = Ldap.bind_dn
base_dn = Ldap.GetBaseDN
member_attribute = Ldap.member_attribute
base_config_dn = Ldap.GetMainConfigDN
create_ldap = Ldap.create_ldap
append_base = bind_dn != "" && Builtins.issubstring(bind_dn, base_dn)
pam_password = Ldap.pam_password
krb5_realm = Ldap.krb5_realm
krb5_server = Ldap.krb5_server
sssd_with_krb = Ldap.sssd_with_krb
sssd_ldap_schema = Ldap.sssd_ldap_schema
sssd_enumerate = Ldap.sssd_enumerate
sssd_cache_credentials = Ldap.sssd_cache_credentials
nss_base_passwd = Ldap.nss_base_passwd
nss_base_group = Ldap.nss_base_group
nss_base_automount = Ldap.nss_base_automount
member_attributes = [
Item(Id("member"), "member", member_attribute == "member"),
Item(
Id("uniqueMember"),
"uniqueMember",
member_attribute == "uniqueMember"
)
]
if member_attribute != "member" && member_attribute != "uniqueMember"
member_attributes = Builtins.add(
member_attributes,
Item(Id(member_attribute), member_attribute, true)
)
end
# propose some good default
if base_config_dn == ""
base_config_dn = Builtins.sformat("ou=ldapconfig,%1", base_dn)
end
pam_password_items = [
"ad",
"crypt",
"clear",
"clear_remove_old",
"exop",
"exop_send_old",
"md5",
"nds",
"racf"
]
pam_password_items = Builtins.sort(
Builtins.maplist(
Convert.convert(
Builtins.union(pam_password_items, [pam_password]),
:from => "list",
:to => "list <string>"
)
) { |it| Item(Id(it), it, it == pam_password) }
)
ldap_schemas = ["rfc2307", "rfc2307bis"]
# mapping of browse button id's to appropriate text entries
br2entry = {
:br => :base_config_dn,
:br_passwd => :nss_base_passwd,
:br_group => :nss_base_group,
:br_autofs => :nss_base_automount