Skip to content

Print current environment #47

Description

@basil

/proc/$PID/environ contains 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 a char **__environ symbol 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.conf for details). So we might want to print the current environment if we can (e.g. with process_vm_readv or ptrace), and print a warning and the contents of /proc/$PID/environ if 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 without systemd-coredump metadata, should we try to find the environment from the initial stack layout, which places argc, then argv pointers, then envp pointers?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions