@@ -3,6 +3,7 @@ use std::process::Command;
3
3
use crate :: process:: ProcessInfo ;
4
4
use procfs:: process:: Process ;
5
5
use anyhow:: { anyhow, Result as AnyhowResult } ;
6
+ use fs_extra:: dir:: DirEntryAttr :: Path ;
6
7
use libc:: { kill, pid_t, SIGUSR2 } ;
7
8
use regex:: Regex ;
8
9
use crate :: settings:: RASP_PHP_PROBE ;
@@ -188,7 +189,7 @@ fn search_maps(process: &Process) -> AnyhowResult<Option<String>> {
188
189
}
189
190
190
191
fn search_argv ( process : & Process ) -> AnyhowResult < Option < String > > {
191
- let raw_fpm_regex = Regex :: new ( r"/.+php.+\.conf" ) ?;
192
+ let regex = Regex :: new ( r"/.+php.+\.conf" ) ?;
192
193
let cmdlines = process. cmdline ( ) ?;
193
194
for cmdline in cmdlines. iter ( ) {
194
195
if let Some ( caps) = regex. captures ( cmdline) {
@@ -212,15 +213,16 @@ pub fn locate_extension_dir(process: &Process) -> AnyhowResult<String> {
212
213
}
213
214
214
215
pub fn locate_confd_dir ( process : & Process ) -> AnyhowResult < String > {
216
+ let root_dir = PathBuf :: from ( format ! ( "/proc/{}/root/" , process. pid) ) ;
215
217
if let Some ( conf) = search_argv ( process) ? {
216
218
if let Some ( confp) = PathBuf :: from ( conf) . parent ( ) {
217
219
let confd = confp. join ( "conf.d" ) ;
218
- if confd. exists ( ) {
220
+ if root_dir . join ( confd. as_path ( ) ) . exists ( ) {
219
221
return Ok ( String :: from ( confd. to_str ( ) . unwrap ( ) ) ) ;
220
222
}
221
223
if let Some ( confpp) = PathBuf :: from ( confp) . parent ( ) {
222
224
let confd = confpp. join ( "conf.d" ) ;
223
- if confd. exists ( ) {
225
+ if root_dir . join ( confd. as_path ( ) ) . exists ( ) {
224
226
return Ok ( String :: from ( confd. to_str ( ) . unwrap ( ) ) ) ;
225
227
}
226
228
}
0 commit comments