Stanislav Brabec changed bug 1187209
What Removed Added
Flags needinfo?(sbrabec@suse.com)  

Comment # 2 on bug 1187209 from Stanislav Brabec
This is expected behavior, as documented in the su(8).

For backward compatibility, su defaults to not change the current directory and
to only set the environment variables HOME and SHELL (plus USER and LOGNAME if
the target user is not root). It is recommended to always use the --login
option
(instead of its shortcut -) to avoid side effects caused by mixing
environments.

So if you want a clear environment, use su --login.

XDG_RUNTIME_DIR is kept from the previous environment. And it is actually set
by the desktop environment, so even if you clear it manually, if would not be
set.

So su keeps most variables from the previous environment.

Please note that su --login reads profile, so the variables may be reset by
that.

In opposite to that, sudo drops all environment variables except SUDO_EDITOR,
VISUAL, EDITOR and eventually HOME (with -H).


Behavior of both tools can be modified.

For su:

/etc/default/su
/etc/login.defs

Regarding PATH, it was not always the default:
* St dub 04 2018 sbrabec@suse.com
- su.default: Set ALWAYS_SET_PATH default to "yes" (bsc#353876#c7);
  add one-time wrapper forcing ALWAYS_SET_PATH on upgrade.

For sudo:
It is heavily configurable, see sudoers(5).


You are receiving this mail because: