Skip to content

Commit 2f7d1fe

Browse files
author
Lin Liu
committed
CP-310956: Remove legacy winbind configuration
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 Signed-off-by: Lin Liu <[email protected]>
1 parent 19f2398 commit 2f7d1fe

File tree

2 files changed

+43
-86
lines changed

2 files changed

+43
-86
lines changed

ocaml/xapi/extauth_plugin_ADwinbind.ml

Lines changed: 43 additions & 79 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
@@ -746,7 +736,7 @@ end
746736
let kdcs_of_domain domain =
747737
try
748738
Helpers.call_script ~log_output:On_failure net_cmd
749-
(["lookup"; "kdc"; domain; "-d"; debug_level ()] @ kerberos_opt)
739+
["lookup"; "kdc"; domain; "-d"; debug_level ()]
750740
(* Result like 10.71.212.25:88\n10.62.1.25:88\n*)
751741
|> String.split_on_char '\n'
752742
|> List.filter (fun x -> String.trim x <> "") (* Remove empty lines *)
@@ -760,9 +750,7 @@ let workgroup_from_server kdc =
760750
let key = "Pre-Win2k Domain" in
761751
try
762752
Helpers.call_script ~log_output:On_failure net_cmd
763-
(["ads"; "lookup"; "-S"; KDC.server kdc; "-d"; debug_level ()]
764-
@ kerberos_opt
765-
)
753+
["ads"; "lookup"; "-S"; KDC.server kdc; "-d"; debug_level ()]
766754
|> Xapi_cmd_result.of_output ~sep:':' ~key
767755
|> Result.ok
768756
with _ ->
@@ -789,57 +777,39 @@ let config_winbind_daemon ~workgroup ~netbios_name ~domain =
789777
let smb_config = "/etc/samba/smb.conf" in
790778
let string_of_bool = function true -> "yes" | false -> "no" in
791779

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

15661534
let args =
15671535
[
1568-
[
1569-
"ads"
1570-
; "join"
1571-
; service_name
1572-
; "-U"
1573-
; user
1574-
; "-n"
1575-
; netbios_name
1576-
; "-d"
1577-
; debug_level ()
1578-
; "--no-dns-updates"
1579-
]
1580-
@ kerberos_opt
1581-
; ou_param
1582-
; dns_hostname_option
1536+
"ads"
1537+
; "join"
1538+
; service_name
1539+
; "-U"
1540+
; user
1541+
; "-n"
1542+
; netbios_name
1543+
; "-d"
1544+
; debug_level ()
1545+
; "--no-dns-updates"
15831546
]
1584-
|> List.concat
1547+
@ ou_param
1548+
@ dns_hostname_option
15851549
in
15861550
debug "Joining domain %s with user %s netbios_name %s" service_name user
15871551
netbios_name ;

ocaml/xapi/xapi_globs.ml

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

10591059
let winbind_set_machine_account_kerberos_encryption_type = ref false
10601060

1061-
let winbind_allow_kerberos_auth_fallback = ref false
1062-
10631061
let winbind_scan_trusted_domains = ref false
10641062

10651063
let winbind_keep_configuration = ref false
@@ -1646,11 +1644,6 @@ let other_options =
16461644
, "Whether set machine account encryption type \
16471645
(msDS-SupportedEncryptionTypes) on domain controller"
16481646
)
1649-
; ( "winbind_allow_kerberos_auth_fallback"
1650-
, Arg.Set winbind_allow_kerberos_auth_fallback
1651-
, (fun () -> string_of_bool !winbind_allow_kerberos_auth_fallback)
1652-
, "Whether to allow fallback to other auth on kerberos failure"
1653-
)
16541647
; ( "winbind_scan_trusted_domains"
16551648
, Arg.Set winbind_scan_trusted_domains
16561649
, (fun () -> string_of_bool !winbind_scan_trusted_domains)

0 commit comments

Comments
 (0)