Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stop sourcing profile, let inherited login shell env override systemd env (#72) #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions uwsm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2737,9 +2737,6 @@ def prepare_env_gen_sh(random_mark):
}

#### Basic environment
[ -f /etc/profile ] && . /etc/profile
[ -f "${HOME}/.profile" ] && . "${HOME}/.profile"
export PATH
export XDG_CONFIG_DIRS="${XDG_CONFIG_DIRS:-/etc/xdg}"
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}"
export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
Expand Down Expand Up @@ -2898,6 +2895,10 @@ def prepare_env():
# save initial systemd state for later restoration on cleanup
save_env("env_pre", env_pre)

# merge systemd environment with login environment,
# with login environment overriding systemd
env_merged = env_pre | env_login

# Run shell code with env_pre environment to prepare env and print results
random_mark = f"MARK_{random_hex(16)}_MARK"
shell_code = prepare_env_gen_sh(random_mark)
Expand All @@ -2912,7 +2913,7 @@ def prepare_env():
text=True,
input=shell_code,
capture_output=True,
env=env_pre,
env=env_merged,
check=False,
)
print_debug(sprc)
Expand Down Expand Up @@ -2954,12 +2955,6 @@ def prepare_env():
print_error(f"No value: {env}!")
env_post = filter_varnames(env_post)

# include vars from login session that are missing from env_post
for var, value in env_login.items():
if var not in env_post:
print_debug(f'back-adding from login env: {var}="{value}"')
env_post.update({var: value})

## Dict of vars to put into systemd user manager
# raw difference dict between env_post and env_pre
set_env = dict(set(env_post.items()) - set(env_pre.items()))
Expand Down