For some terminals COLORTERM seems to be the only way for checking for that specific terminal. For instance, gnome-terminal sets its TERM as "xterm" but its COLORTERM as "gnome-terminal". The COLORTERM variable is also of use when running GNU screen since it sets TERM to "screen" but doesn't touch COLORTERM. Currently su -l only preserves the TERM variable, COLORTERM is unset. This simple patch makes su -l preserve the COLORTERM environment variable as well.
Created attachment 130837 [details, diff] shadow-4.0.18.1-su-preserve-colorterm.patch
I've attached another patch which incorporates the previous one and preserves the STY and WINDOW environment vars as well. These are set by GNU screen and provide a way to query the session name and window number respectively. Like with the COLORTERM variable, I don't know of any other way to query this information which makes these variables invaluable.
Created attachment 131040 [details, diff] shadow-4.0.18.1-su-preserve-variables.patch
this has been merged upstream