Bug 1193453 - "systemctl show" doesn't show environment variables defined when EnvironmentFile is used
Summary: "systemctl show" doesn't show environment variables defined when EnvironmentF...
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: 21
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-02-17 11:29 UTC by Jack
Modified: 2015-03-14 16:05 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-14 16:05:16 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jack 2015-02-17 11:29:28 UTC
Description of problem:
"systemctl show" doesn't show environment variables defined when EnvironmentFile is used

Version-Release number of selected component (if applicable):

systemctl --version
systemd 216
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN


How reproducible:
Always

Steps to Reproduce:
1.Using a services file with EnvironmentFile=/path/to/environment
2.start service
3.run "systemctl show" on that service

Actual results:
Environment=[empty]


Expected results:
Environment=VAR=val VAR2=val, etc.

Additional info:

Comment 1 Zbigniew Jędrzejewski-Szmek 2015-03-14 16:05:16 UTC
Yes, Environment only refers to the configuration directive. Variables set in EnvironmentFile are separate.

A different question is whether systemd should show variables defined in EnvironmentFile Systemd does not show those because EnvironmentFile is actually read late — just before the process is executed. Variable substitution is actually done after a fork and the main systemd process cannot display them, because it does not know their values for some variables.

So this is by design, and hard to change.

As a partial workaround you can do something like
  tr '\0' '\n' < /proc/<pid-of-daemon>/environ
This will show the environment of the process.


Note You need to log in before you can comment on or make changes to this bug.