-
Notifications
You must be signed in to change notification settings - Fork 1
Print current environment #47
Copy link
Copy link
Closed
Labels
Component: penvIssues related to penv(1)Issues related to penv(1)Priority: MediumNormal priorityNormal priorityType: EnhancementA request, idea, or new functionalityA request, idea, or new functionality
Description
Metadata
Metadata
Assignees
Labels
Component: penvIssues related to penv(1)Issues related to penv(1)Priority: MediumNormal priorityNormal priorityType: EnhancementA request, idea, or new functionalityA request, idea, or new functionality
/proc/$PID/environcontains the environment as it was when the proc was started. To get the current environment, we need to inspect its memory to find out how it has changed. POSIX defines achar **__environsymbol that we will need to find. Unfortunately, inspecting the memory of another process is not typically permitted, even if the process is owned by the same user (see/etc/sysctl.d/10-ptrace.conffor details). So we might want to print the current environment if we can (e.g. withprocess_vm_readvor ptrace), and print a warning and the contents of/proc/$PID/environif we can't. We should be able to do this for both live processes and core files.Open question: If we can't find
__environ, and we don't have access to/proc(e.g. a coredump withoutsystemd-coredumpmetadata, should we try to find the environment from the initial stack layout, which placesargc, thenargvpointers, thenenvppointers?