@@ -32,20 +32,21 @@ let xapi_internal_originator = "xapi"
32
32
33
33
let serialize_auth = Mutex. create()
34
34
35
- let wipe_string_contents str = for i = 0 to String. length str - 1 do str.[i] < - '\000' done
35
+ let wipe_string_contents str =
36
+ for i = 0 to Bytes. length str - 1 do (Bytes. set str i '\000' ) done
36
37
let wipe ss = List. iter (fun s -> wipe_string_contents s) ss
37
38
(* wrapper that erases sensitive string parameters from functions *)
38
39
let wipe_params_after_fn params fn =
39
40
try (let r= fn () in wipe params; r) with e -> (wipe params; raise e)
40
41
41
42
let do_external_auth uname pwd =
42
- Mutex. execute serialize_auth (fun () -> (Ext_auth. d() ).authenticate_username_password uname pwd)
43
+ Mutex. execute serialize_auth (fun () -> (Ext_auth. d() ).authenticate_username_password uname ( Bytes. unsafe_to_string pwd) )
43
44
44
45
let do_local_auth uname pwd =
45
- Mutex. execute serialize_auth (fun () -> Pam. authenticate uname pwd)
46
+ Mutex. execute serialize_auth (fun () -> Pam. authenticate uname ( Bytes. unsafe_to_string pwd) )
46
47
47
48
let do_local_change_password uname newpwd =
48
- Mutex. execute serialize_auth (fun () -> Pam. change_password uname newpwd)
49
+ Mutex. execute serialize_auth (fun () -> Pam. change_password uname ( Bytes. unsafe_to_string newpwd) )
49
50
50
51
let trackid session_id = (Context. trackid_of_session (Some session_id))
51
52
@@ -348,7 +349,9 @@ let slave_local_login ~__context ~psecret =
348
349
Xapi_local_session. create ~__context ~pool: true
349
350
350
351
(* Emergency mode login, uses local storage *)
351
- let slave_local_login_with_password ~__context ~uname ~pwd = wipe_params_after_fn [pwd] (fun () ->
352
+ let slave_local_login_with_password ~__context ~uname ~pwd =
353
+ let pwd = Bytes. of_string pwd in
354
+ wipe_params_after_fn [pwd] (fun () ->
352
355
if not (Context. preauth ~__context)
353
356
then
354
357
(try
@@ -367,7 +370,9 @@ let slave_local_login_with_password ~__context ~uname ~pwd = wipe_params_after_f
367
370
- try and authenticate remotely, passing the supplied username/password to the external auth/directory service. (Note: see below for definition of 'authenticate remotely')
368
371
2. otherwise, Session.login_with_password will only attempt to authenticate against the local superuser credentials
369
372
*)
370
- let login_with_password ~__context ~uname ~pwd ~version ~originator = wipe_params_after_fn [pwd] (fun () ->
373
+ let login_with_password ~__context ~uname ~pwd ~version ~originator =
374
+ let pwd = Bytes. of_string pwd in
375
+ wipe_params_after_fn [pwd] (fun () ->
371
376
(* !!! Do something with the version number *)
372
377
if (Context. preauth ~__context) then
373
378
begin
@@ -595,7 +600,10 @@ let login_with_password ~__context ~uname ~pwd ~version ~originator = wipe_param
595
600
)
596
601
)
597
602
598
- let change_password ~__context ~old_pwd ~new_pwd = wipe_params_after_fn [old_pwd;new_pwd] (fun () ->
603
+ let change_password ~__context ~old_pwd ~new_pwd =
604
+ let old_pwd = Bytes. of_string old_pwd in
605
+ let new_pwd = Bytes. of_string new_pwd in
606
+ wipe_params_after_fn [old_pwd;new_pwd] (fun () ->
599
607
let session_id = Context. get_session_id __context in
600
608
(* let user = Db.Session.get_this_user ~__context ~self:session_id in
601
609
let uname = Db.User.get_short_name ~__context ~self:user in*)
0 commit comments