04:16
I've been intermittently writing bits of a Q&A about it. I'm not sure how much to describe in the question and how much to describe in the answer. But I am inclined to think that describing my original observations, plus information about how they still hold now that Ubuntu+1 is out, is justified in the question, even though that would make it longer than the question portion of many planned-out self-answered questions.
In case you're interested (since we discussed it before when 19.10 was Ubuntu+1), right now I have this draft for the question and this draft for the first ~25% of the answer (more than 25%, if I can write better and figure out what's worth omitting, though I don't think that beginning section will itself get much shorter).
10 hours later…
1 hour later…
15:55
I'm thinking I should probably do that. That should go in the answer, because people who want to make 19.10 work like previous releases will look in the answer to find out how (and I do plan to cover that), but most people should just use
--preserve-env=HOME
in specific cases rather than doing that.
I am wondering if I should remove the italicized paragraph at the bottom of the question. As written, it's not really correct -- this isn't really intended as a canonical question, because there are not yet (as far as I know) any questions asked about this. My motivations for having that part are
(a) defensive question-asking, i.e., fear that people will vote to close the question as OT bug, but I should probably just let that happen and try to get it reopened if it is wrongly closed for that reason, and
(b) preventing people from thinking that
sudo echo "$HOME"
showing their home directory is related to this.
@Zanna Should I try to split the stuff about
always_set_home
between the question and the answer? Like, I could say in the question: At first I thought this might be due to [updated configuration files][2]. But I checked, and `always_set_home` does not appear in any `Defaults` line in the 19.10 `sudoers` file.
At first I thought this might be due to [updated configuration files][2]. I can make it so `sudo` behaves this way on earlier releases--always resetting `$HOME` unless overridden by `--preserve-env` or `-E`--by editing `/etc/sudoers` (`sudo visudo`) or a file in `/etc/sudoers.d` (e.g. `sudo visudo -f /etc/sudoers.d/always_set_home`) to add: Defaults always_set_home But I checked, and `always_set_home` does not appear in any `Defaults` line in the 19.10 `sudoers` file.
1 hour later…
17:07
17:21
Now that I've moved the conversation here, I won't be distracting from stuff that's on-topic in the Downboat by just posting the old Q and A drafts here, where I think they are much easier to consult than in the pastebin.
In Ubuntu releases prior to Ubuntu 19.10 Eoan Ermine, when I run a command with `sudo`, that command receives *my home directory* in the `$HOME` environment variable. This is the behavior I have long expected and [warned other people about][1]. If I want `sudo` to reset the `$HOME` environment variable, so that it refers to the target user's home directory instead of my own, I have to pass the `-H` option (or `-i`, though that does more). <!-- language-all: lang-bash --> ek@Kip:~$ lsb_release -d
For years, Ubuntu has provided a patched version of `sudo` that preserves `$HOME` by default. Besides Ubuntu and its derivatives, very few other operating systems (perhaps no others) do this. It has been decided that this causes more problems than it solves, and starting in Ubuntu 19.10, `$HOME` is no longer one of the few environment variables `sudo` preserves.
In terms of *what* the change is and how it affects users, the key points are:
- **As of Ubuntu 19.10, <code>sudo *command*</code> does what <code>sudo -H *command*</code> does in previous releases.** It can indeed be used in case…
In Ubuntu releases prior to Ubuntu 19.10 Eoan Ermine, when I run a command with `sudo`, that command receives *my home directory* in the `$HOME` environment variable. This is the behavior I have long expected and [warned other people about][1]. If I want `sudo` to reset the `$HOME` environment variable, so that it refers to the target user's home directory instead of my own, I have to pass the `-H` option (or `-i`, though that does more). <!-- language-all: lang-bash --> ek@Kip:~$ lsb_release -d
@Zanna Now the question on my mind is, can I manage to not write most of what I planned to write in the answer, and still make an answer that's as good as or better than what I had originally envisioned?
I'm having some trouble, going just by sudo.ws/changes.html, in figuring out exactly when the change was made upstream.
2 hours later…
21:06
The author of the bug report was concerned specifically about the security of commands run by users who are permitted to run specific commands but not others with
sudo
. But the change was made for reasons beyond that, and so the stronger effect of simply never preserving the value of HOME
(unless the user acts specifically to make this happen) was chosen. /etc/sudoers
in the eoan git repo does not contain env_keep
or otherwise mention HOME
(and it still contains env_reset
). To double check, I just installed from the 19.10 live-server image on a virtual machine. Neither the live-server image's own /etc/sudoers
nor the one it installs to the target has env_keep
(and neither has a file in /etc/sudoers.d/
with it).
I have also created an LXD container from the official 19.10 image. As expected, it doesn't have
env_keep
in /etc/sudoers
(or in any file in /etc/sudoers.d/
). All the systems/environments have the new (to Ubuntu) behavior of resetting $HOME
even when -H
or -i
is not used (as a non-root user, I tested printenv HOME
vs. sudo printenv HOME
on all of them). « first day (788 days earlier) ← previous day next day → last day (1779 days later) »