Add path to request trace (#61)

This commit is contained in:
Max Goedjen 2020-03-17 01:23:49 -07:00 committed by GitHub
parent 2b5fdf541d
commit 5ef1fe996b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -8,6 +8,9 @@
#import <Foundation/Foundation.h>
// Forward declaration of proc_pidpath from libproc.h
int proc_pidpath(int pid, void * buffer, uint32_t buffersize);
//! Project version number for SecretAgentKit.
FOUNDATION_EXPORT double SecretAgentKitVersionNumber;

View File

@ -29,7 +29,10 @@ struct SigningRequestTracer {
var pidAndNameInfo = self.pidAndNameInfo(from: pid)
let ppid = pidAndNameInfo.kp_eproc.e_ppid != 0 ? pidAndNameInfo.kp_eproc.e_ppid : nil
let procName = String(cString: &pidAndNameInfo.kp_proc.p_comm.0)
return SigningRequestProvenance.Process(pid: pid, name: procName, path: "", parentPID: ppid)
let pathPointer = UnsafeMutablePointer<UInt8>.allocate(capacity: Int(MAXPATHLEN))
_ = proc_pidpath(pid, pathPointer, UInt32(MAXPATHLEN))
let path = String(cString: pathPointer)
return SigningRequestProvenance.Process(pid: pid, name: procName, path: path, parentPID: ppid)
}
}