Hello Tom H,

Thanks for your feedback here pointing out this difference.

On Fri, Feb 24, 2017 at 07:11:01AM -0500, Tom H wrote:
> There's a difference in the handling of environment variables between
> the two implementations.
> 
> su provided by login/src:shadow resets
> HOME
> LOGNAME
> PATH
> SHELL
> USER

(As documented in su(1) from src:shadow.)

> 
> su provided by util-linux resets
> HOME
> SHELL
[...]

... when switching to uid 0.

When switching to another uid it also resets LOGNAME and USER.
http://sources.debian.net/src/util-linux/2.29.1-1/login-utils/su-common.c/#L564

(And PATH if ALWAYS_SET_PATH is set in login.defs.)
http://sources.debian.net/src/util-linux/2.29.1-1/login-utils/su-common.c/#L513

Thus the difference is smaller then it first seemed.... But definitely
a difference.

To me this mostly seems like a(nother) case of "always use 'su -', never
su".

I did some archeology to find out more about the special-casing of uid 0
here, but found out that this condition has existed in util-linux
version since the initial commit.

Would be interesting to hear if anyone knows more about this and if they
know anything that'll be affected by this difference if we switch.

Regards,
Andreas Henriksson

Reply via email to