snapd-env-generator: fix when PATH is empty or unset#5808
snapd-env-generator: fix when PATH is empty or unset#5808mvo5 merged 2 commits intocanonical:masterfrom
Conversation
When the PATH is empty or unset the generator will generate the wrong output (PATH=:/snap/bin). This causes havoc. This PR fixes it by outputing only a PATH=/snap/bin segment that systemd will correctly piece together.
| char *path = getenv("PATH"); | ||
| if (path == NULL) | ||
| path = ""; | ||
| if (path == NULL || sc_streq(path, "")) { |
There was a problem hiding this comment.
+1, shall I add sc_strempty for cases like this?
smoser
left a comment
There was a problem hiding this comment.
This change does not fix the problem.
environment-generators inherit environment that /sbin/init
started with, but no other systemd defaults. Therefore, there is no
easy way to append to an environment variable that is not set as snapd
was hoping to do. The only solution currently is to copy the expected
"default path" into the snapd environment-generator.
There is a more long winded response at https://bugs.launchpad.net/cloud-images/+bug/1791691
When the PATH is not set when the generator runs, simply do nothing for now. If we print PATH=/snap/bin thats the wrong path and systemd needs to be smarter to collect paths first. If we add a default PATH the problem is that this is very inconcistent, see LP:#1792004. See also https://bugs.launchpad.net/cloud-images/+bug/1791691
|
@smoser Thanks Scott. I just talked on irc with @xnox and he plans to fix this issue in systemd. Until then his advice is that if the PATH is unset our generator should do nothing. Picking a default PATH seems to be problematic - there are just too many too chose from: https://bugs.launchpad.net/ubuntu/+source/dpkg/+bug/1792004 |
|
@mvo5 I want to confirm that you were going to land and upload your latest change of doing nothing hopefully today/tomorrow? |
Codecov Report
@@ Coverage Diff @@
## master #5808 +/- ##
==========================================
- Coverage 79.13% 79.13% -0.01%
==========================================
Files 531 531
Lines 40720 40735 +15
==========================================
+ Hits 32223 32234 +11
- Misses 5884 5885 +1
- Partials 2613 2616 +3
Continue to review full report at Codecov.
|
|
@powersj Yes, this is scheduled to be uploaded ASAP (hopefully today). We would have done it yesterday already but github was having too much trouble. |
When the PATH is empty or unset the generator will generate the
wrong output (PATH=:/snap/bin). This causes havoc. This PR fixes
it by outputing only a PATH=/snap/bin segment that systemd will
correctly piece together.