Bug 1193453

Summary: "systemctl show" doesn't show environment variables defined when EnvironmentFile is used
Product: [Fedora] Fedora Reporter: Jack <damnedyankee>
Component: systemdAssignee: systemd-maint
Status: CLOSED CANTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 21CC: johannbg, jsynacek, lnykryn, msekleta, s, systemd-maint, vpavlin, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-14 16:05:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.