Skip to content

Commit

Permalink
CP-52320 & CP-52743: Classify xapi threads.
Browse files Browse the repository at this point in the history
Classifies the threads at the time of session creation and inside
`do_dispatch`.

This ensures that new threads created by current session/request inherit
the propper classification.

Note: threads created by xenopsd calling back into xapi are yet to be
classified.

Signed-off-by: Gabriel Buica <[email protected]>
  • Loading branch information
GabrielBuica committed Dec 4, 2024
1 parent 77e0d22 commit fc0da95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ocaml/xapi/xapi_session.ml
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ let consider_touching_session rpc session_id =
(* Make sure the pool secret matches *)
let slave_login_common ~__context ~host_str ~psecret =
Context.with_tracing ~__context __FUNCTION__ @@ fun __context ->
Tgroup.of_creator (Tgroup.Group.Creator.make ~intrapool:true ()) ;
if not (Helpers.PoolSecret.is_authorized psecret) then (
let msg = "Pool credentials invalid" in
debug "Failed to authenticate slave %s: %s" host_str msg ;
Expand Down Expand Up @@ -881,6 +882,8 @@ let login_with_password ~__context ~uname ~pwd ~version:_ ~originator =
| Some `root ->
(* in this case, the context origin of this login request is a unix socket bound locally to a filename *)
(* we trust requests from local unix filename sockets, so no need to authenticate them before login *)
Tgroup.of_creator
Tgroup.Group.(Creator.make ~identity:Identity.root_identity ()) ;
login_no_password_common ~__context ~uname:(Some uname) ~originator
~host:(Helpers.get_localhost ~__context)
~pool:false ~is_local_superuser:true ~subject:Ref.null ~auth_user_sid:""
Expand Down Expand Up @@ -929,6 +932,8 @@ let login_with_password ~__context ~uname ~pwd ~version:_ ~originator =
do_local_auth uname pwd ;
debug "Success: local auth, user %s from %s" uname
(Context.get_origin __context) ;
Tgroup.of_creator
Tgroup.Group.(Creator.make ~identity:Identity.root_identity ()) ;
login_no_password_common ~__context ~uname:(Some uname) ~originator
~host:(Helpers.get_localhost ~__context)
~pool:false ~is_local_superuser:true ~subject:Ref.null
Expand Down Expand Up @@ -1224,6 +1229,10 @@ let login_with_password ~__context ~uname ~pwd ~version:_ ~originator =
Caching.memoize ~__context uname pwd
~slow_path:query_external_auth
in
Tgroup.of_creator
Tgroup.Group.(
Creator.make ~identity:(Identity.make subject_identifier) ()
) ;
login_no_password_common ~__context ~uname:(Some uname)
~originator
~host:(Helpers.get_localhost ~__context)
Expand Down
1 change: 1 addition & 0 deletions ocaml/xe-cli/newcli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ let main () =
in
let args = String.concat "\n" args in
Printf.fprintf oc "User-agent: xe-cli/Unix/%d.%d\r\n" major minor ;
Printf.fprintf oc "originator: cli\r\n" ;
Option.iter (Printf.fprintf oc "traceparent: %s\r\n") traceparent ;
Printf.fprintf oc "content-length: %d\r\n\r\n" (String.length args) ;
Printf.fprintf oc "%s" args ;
Expand Down

0 comments on commit fc0da95

Please sign in to comment.