|
Bugzilla – Full Text Bug Listing |
| Summary: | Double sudo no longer sets USER environment variable | ||
|---|---|---|---|
| Product: | Sudo | Reporter: | Marek Tamaskovic <mtamasko> |
| Component: | Sudo | Assignee: | Todd C. Miller <Todd.Miller> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | low | ||
| Version: | 1.8.20 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
|
Description
Marek Tamaskovic
2017-09-25 05:56:10 MDT
It looks like this is due to RedHat adding USERNAME to env_keep in the default sudoers file you ship. Here's what is happening: 1) sudo is invoked without USERNAME set 2) sudo executes the other sudo command, setting LOGNAME, USER and USERNAME to the name of target user 3) the second sudo preserves USERNAME as per sudoers, which is set to the name of the user the first sudo ran as (root in your example) 4) sudo also preserves LOGNAME and USER to avoid having LOGNAME, USER and USERNAME be inconsistent. Sudo is behaving as intended, though the behavior with respect to keeping LOGNAME, USER and USERNAME be consistent is not well documented. It would probably be less surprising if sudo were to preserve USER and LOGNAME too if USERNAME is listed in env_keep. I'm considering removing the handling of the USERNAME environment variable in sudo 1.8.26. It was added a long time ago when Fedora used to set USERNAME to the same value as LOGNAME and USER. That's no longer the case and sshd doesn't set USERNAME either so I think it is safe for sudo to drop it as well. This will make it possible to have more consistent handling of LOGNAME and USER in sudo. |