@@ -36,6 +36,8 @@ const ENV_SIDECAR_APPSEC_LOCK_FILE_PATH: &str = "_DD_SIDECAR_APPSEC_LOCK_FILE_PA
3636const ENV_SIDECAR_APPSEC_LOG_FILE_PATH : & str = "_DD_SIDECAR_APPSEC_LOG_FILE_PATH" ;
3737const ENV_SIDECAR_APPSEC_LOG_LEVEL : & str = "_DD_SIDECAR_APPSEC_LOG_LEVEL" ;
3838
39+ const ENV_SIDECAR_CONNECT_TO_MASTER_PID : & str = "_DD_SIDECAR_CONNECT_TO_MASTER_PID" ;
40+
3941#[ derive( Debug , Copy , Clone , Default ) ]
4042pub enum IpcMode {
4143 #[ default]
@@ -84,6 +86,7 @@ pub struct Config {
8486 pub crashtracker_endpoint : Option < Endpoint > ,
8587 pub appsec_config : Option < AppSecConfig > ,
8688 pub max_memory : usize ,
89+ pub connect_to_master_pid : i32 ,
8790}
8891
8992#[ derive( Debug , Clone ) ]
@@ -128,6 +131,12 @@ impl Config {
128131 format ! ( "{}" , self . max_memory) . into ( ) ,
129132 ) ;
130133 }
134+ if self . connect_to_master_pid != 0 {
135+ res. insert (
136+ ENV_SIDECAR_CONNECT_TO_MASTER_PID ,
137+ format ! ( "{}" , self . connect_to_master_pid) . into ( ) ,
138+ ) ;
139+ }
131140 res
132141 }
133142}
@@ -241,9 +250,17 @@ impl FromEnv {
241250 crashtracker_endpoint : Self :: crashtracker_endpoint ( ) ,
242251 appsec_config : Self :: appsec_config ( ) ,
243252 max_memory : Self :: max_memory ( ) ,
253+ connect_to_master_pid : Self :: connect_to_master_pid ( ) ,
244254 }
245255 }
246256
257+ fn connect_to_master_pid ( ) -> i32 {
258+ std:: env:: var ( ENV_SIDECAR_CONNECT_TO_MASTER_PID )
259+ . ok ( )
260+ . and_then ( |s| s. parse ( ) . ok ( ) )
261+ . unwrap_or ( 0 )
262+ }
263+
247264 fn appsec_config ( ) -> Option < AppSecConfig > {
248265 let shared_lib_path = std:: env:: var_os ( ENV_SIDECAR_APPSEC_SHARED_LIB_PATH ) ?;
249266 let socket_file_path = std:: env:: var_os ( ENV_SIDECAR_APPSEC_SOCKET_FILE_PATH ) ?;
0 commit comments