@@ -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 ) ]
4042pub enum IpcMode {
4143 Shared ,
@@ -94,6 +96,7 @@ pub struct Config {
9496 pub crashtracker_endpoint : Option < Endpoint > ,
9597 pub appsec_config : Option < AppSecConfig > ,
9698 pub max_memory : usize ,
99+ pub connect_to_master_pid : i32 ,
97100}
98101
99102#[ derive( Debug , Clone ) ]
@@ -138,6 +141,12 @@ impl Config {
138141 format ! ( "{}" , self . max_memory) . into ( ) ,
139142 ) ;
140143 }
144+ if self . connect_to_master_pid != 0 {
145+ res. insert (
146+ ENV_SIDECAR_CONNECT_TO_MASTER_PID ,
147+ format ! ( "{}" , self . connect_to_master_pid) . into ( ) ,
148+ ) ;
149+ }
141150 res
142151 }
143152}
@@ -251,9 +260,17 @@ impl FromEnv {
251260 crashtracker_endpoint : Self :: crashtracker_endpoint ( ) ,
252261 appsec_config : Self :: appsec_config ( ) ,
253262 max_memory : Self :: max_memory ( ) ,
263+ connect_to_master_pid : Self :: connect_to_master_pid ( ) ,
254264 }
255265 }
256266
267+ fn connect_to_master_pid ( ) -> i32 {
268+ std:: env:: var ( ENV_SIDECAR_CONNECT_TO_MASTER_PID )
269+ . ok ( )
270+ . and_then ( |s| s. parse ( ) . ok ( ) )
271+ . unwrap_or ( 0 )
272+ }
273+
257274 fn appsec_config ( ) -> Option < AppSecConfig > {
258275 let shared_lib_path = std:: env:: var_os ( ENV_SIDECAR_APPSEC_SHARED_LIB_PATH ) ?;
259276 let socket_file_path = std:: env:: var_os ( ENV_SIDECAR_APPSEC_SOCKET_FILE_PATH ) ?;
0 commit comments