Skip to content

Commit 5c0cfbc

Browse files
authored
CP-310956: Remove legacy winbind configuration (#6822)
9a468bf updated samba to 4.2x and keep legacy configuration in smb.conf conditionally for backward compatibility. Now samba binary is updated in all releases, this commit just drop the legacy configurations
2 parents 0eacfc3 + 273f961 commit 5c0cfbc

File tree

2 files changed

+43
-84
lines changed

2 files changed

+43
-84
lines changed

ocaml/xapi/extauth_plugin_ADwinbind.ml

Lines changed: 43 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,6 @@ let generic_error msg =
102102

103103
let fail fmt = Printf.ksprintf generic_error fmt
104104

105-
let is_samba_updated =
106-
(* This is temporary workaround to be compatible for old and new samba, to decouple the merge of xapi and samba *)
107-
let check_file = "/usr/lib64/samba/libxattr-tdb-private-samba.so" in
108-
Sys.file_exists check_file
109-
110-
let kerberos_opt =
111-
match is_samba_updated with true -> [] | false -> ["--kerberos"]
112-
113105
(* Global cache for netbios name to domain name mapping using atomic map for thread safety *)
114106
module StringMap = Map.Make (String)
115107

@@ -424,7 +416,6 @@ module Ldap = struct
424416
; kdc
425417
; "--machine-pass"
426418
]
427-
@ kerberos_opt
428419
@ attrs
429420
in
430421
let stdout =
@@ -458,7 +449,6 @@ module Ldap = struct
458449
let query = Printf.sprintf "(|(sAMAccountName=%s)(name=%s))" name name in
459450
let args =
460451
["ads"; "search"; "-d"; debug_level (); "--server"; kdc; "--machine-pass"]
461-
@ kerberos_opt
462452
@ [query; key]
463453
in
464454
try
@@ -751,7 +741,7 @@ end
751741
let kdcs_of_domain domain =
752742
try
753743
Helpers.call_script ~log_output:On_failure net_cmd
754-
(["lookup"; "kdc"; domain; "-d"; debug_level ()] @ kerberos_opt)
744+
["lookup"; "kdc"; domain; "-d"; debug_level ()]
755745
(* Result like 10.71.212.25:88\n10.62.1.25:88\n*)
756746
|> String.split_on_char '\n'
757747
|> List.filter (fun x -> String.trim x <> "") (* Remove empty lines *)
@@ -765,9 +755,7 @@ let workgroup_from_server kdc =
765755
let key = "Pre-Win2k Domain" in
766756
try
767757
Helpers.call_script ~log_output:On_failure net_cmd
768-
(["ads"; "lookup"; "-S"; KDC.server kdc; "-d"; debug_level ()]
769-
@ kerberos_opt
770-
)
758+
["ads"; "lookup"; "-S"; KDC.server kdc; "-d"; debug_level ()]
771759
|> Xapi_cmd_result.of_output ~sep:':' ~key
772760
|> Result.ok
773761
with _ ->
@@ -794,57 +782,41 @@ let config_winbind_daemon ~workgroup ~netbios_name ~domain =
794782
let smb_config = "/etc/samba/smb.conf" in
795783
let string_of_bool = function true -> "yes" | false -> "no" in
796784

797-
(*`allow kerberos auth fallback` depends on our internal samba patch,
798-
* this patch disable fallback to ntlm by default and can be enabled
799-
* Looks like upstream is doing something similar on master with
800-
* configuration `weak_crypto`, check and replace the internal patch when
801-
* upgrade to samba packages with this capacity *)
802-
let allow_fallback =
803-
string_of_bool !Xapi_globs.winbind_allow_kerberos_auth_fallback
804-
in
805785
let scan_trusted_domains =
806786
string_of_bool !Xapi_globs.winbind_scan_trusted_domains
807787
in
808-
let version_conf =
809-
match is_samba_updated with
810-
| false ->
811-
[Printf.sprintf "allow kerberos auth fallback = %s" allow_fallback]
812-
| true ->
788+
( match (workgroup, netbios_name, domain) with
789+
| Some wkgroup, Some netbios, Some dom ->
813790
[
814-
"client use kerberos = required"
791+
"# autogenerated by xapi"
792+
; "[global]"
793+
; "client use kerberos = required"
815794
; "sync machine password to keytab = \
816795
/etc/krb5.keytab:account_name:sync_etypes:sync_kvno:machine_password"
796+
; "kerberos method = secrets and keytab"
797+
; Printf.sprintf "realm = %s" dom
798+
; "security = ADS"
799+
; "template shell = /bin/bash"
800+
; "winbind refresh tickets = yes"
801+
; "winbind enum groups = no"
802+
; "winbind enum users = no"
803+
; Printf.sprintf "winbind scan trusted domains = %s"
804+
scan_trusted_domains
805+
; "winbind use krb5 enterprise principals = yes"
806+
; Printf.sprintf "winbind cache time = %d"
807+
!Xapi_globs.winbind_cache_time
808+
; Printf.sprintf "machine password timeout = 0"
809+
; Printf.sprintf "kerberos encryption types = %s"
810+
(Kerberos_encryption_types.Winbind.to_string
811+
!Xapi_globs.winbind_kerberos_encryption_type
812+
)
813+
; Printf.sprintf "workgroup = %s" wkgroup
814+
; Printf.sprintf "netbios name = %s" netbios
815+
; "idmap config * : backend = autorid"
816+
; Printf.sprintf "idmap config * : range = %d-%d" 2_000_000 99_999_999
817+
; Printf.sprintf "log level = %s" (debug_level ())
818+
; "" (* Empty line at the end *)
817819
]
818-
in
819-
( match (workgroup, netbios_name, domain) with
820-
| Some wkgroup, Some netbios, Some dom ->
821-
["# autogenerated by xapi"; "[global]"]
822-
@ version_conf
823-
@ [
824-
"kerberos method = secrets and keytab"
825-
; Printf.sprintf "realm = %s" dom
826-
; "security = ADS"
827-
; "template shell = /bin/bash"
828-
; "winbind refresh tickets = yes"
829-
; "winbind enum groups = no"
830-
; "winbind enum users = no"
831-
; Printf.sprintf "winbind scan trusted domains = %s"
832-
scan_trusted_domains
833-
; "winbind use krb5 enterprise principals = yes"
834-
; Printf.sprintf "winbind cache time = %d"
835-
!Xapi_globs.winbind_cache_time
836-
; Printf.sprintf "machine password timeout = 0"
837-
; Printf.sprintf "kerberos encryption types = %s"
838-
(Kerberos_encryption_types.Winbind.to_string
839-
!Xapi_globs.winbind_kerberos_encryption_type
840-
)
841-
; Printf.sprintf "workgroup = %s" wkgroup
842-
; Printf.sprintf "netbios name = %s" netbios
843-
; "idmap config * : backend = autorid"
844-
; Printf.sprintf "idmap config * : range = %d-%d" 2_000_000 99_999_999
845-
; Printf.sprintf "log level = %s" (debug_level ())
846-
; "" (* Empty line at the end *)
847-
]
848820
| _ ->
849821
["# autogenerated by xapi"; "[global]"; "" (* Empty line at the end *)]
850822
)
@@ -922,9 +894,7 @@ let clear_machine_account ~service_name = function
922894
| Some u, Some p -> (
923895
(* Disable machine account in DC *)
924896
let env = [|Printf.sprintf "PASSWD=%s" p|] in
925-
let args =
926-
["ads"; "leave"; "-U"; u; "-d"; debug_level ()] @ kerberos_opt
927-
in
897+
let args = ["ads"; "leave"; "-U"; u; "-d"; debug_level ()] in
928898
try
929899
Helpers.call_script ~env net_cmd args |> ignore ;
930900
debug "Succeed to clear the machine account for domain %s" service_name
@@ -1568,23 +1538,19 @@ module AuthADWinbind : Auth_signature.AUTH_MODULE = struct
15681538

15691539
let args =
15701540
[
1571-
[
1572-
"ads"
1573-
; "join"
1574-
; service_name
1575-
; "-U"
1576-
; user
1577-
; "-n"
1578-
; netbios_name
1579-
; "-d"
1580-
; debug_level ()
1581-
; "--no-dns-updates"
1582-
]
1583-
@ kerberos_opt
1584-
; ou_param
1585-
; dns_hostname_option
1541+
"ads"
1542+
; "join"
1543+
; service_name
1544+
; "-U"
1545+
; user
1546+
; "-n"
1547+
; netbios_name
1548+
; "-d"
1549+
; debug_level ()
1550+
; "--no-dns-updates"
15861551
]
1587-
|> List.concat
1552+
@ ou_param
1553+
@ dns_hostname_option
15881554
in
15891555
debug "Joining domain %s with user %s netbios_name %s" service_name user
15901556
netbios_name ;

ocaml/xapi/xapi_globs.ml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,6 @@ let winbind_kerberos_encryption_type = ref Kerberos_encryption_types.Winbind.All
10631063

10641064
let winbind_set_machine_account_kerberos_encryption_type = ref false
10651065

1066-
let winbind_allow_kerberos_auth_fallback = ref false
1067-
10681066
let winbind_scan_trusted_domains = ref false
10691067

10701068
let winbind_keep_configuration = ref false
@@ -1663,11 +1661,6 @@ let other_options =
16631661
, "Whether set machine account encryption type \
16641662
(msDS-SupportedEncryptionTypes) on domain controller"
16651663
)
1666-
; ( "winbind_allow_kerberos_auth_fallback"
1667-
, Arg.Set winbind_allow_kerberos_auth_fallback
1668-
, (fun () -> string_of_bool !winbind_allow_kerberos_auth_fallback)
1669-
, "Whether to allow fallback to other auth on kerberos failure"
1670-
)
16711664
; ( "winbind_scan_trusted_domains"
16721665
, Arg.Set winbind_scan_trusted_domains
16731666
, (fun () -> string_of_bool !winbind_scan_trusted_domains)

0 commit comments

Comments
 (0)