There are more important things that involve less work to do, therefore this is intended as a low priority wishlist bug. Please clear console on logout if the recommended config for new users is used. This requires: * a console_clear (currently part of the bash package) that is not completely broken * a patched zsh-newuser-install that also installs the file /etc/zsh/newuser.zlogout.recommended if available * a newuser.zlogout.recommended that handles everything console_clear does not and should not handle, for example, don't clear the console if $0 is -su (such a file is currently available in a bug report against bash and might in future be part of bash) * doko relicensing a trivial shell snippet used in /etc/.bash_logout (this shouldn't be a problem)
Carsten Hey wrote:
function debian_clear_upon_exit () {
clear
}
add-zsh-hook zshexit debian_clear_upon_exit
That hook could be installed in the recommended setup file.
Disclaimer: I didn't try this. :-)
Regards, Frank
* Frank Terbeck [2015-08-08 23:51 +0200]:
Interesting :) This could indeed avoid the need to ship a .zlogout for
new users. (An ugly alternative would be to set some variable and clear
consoles in /etc/zsh/zlogout if this variable is set.)
By console I meant the thing you get if you press Ctrl-Alt-F1. The
usual use case is to clear the console on logout for privacy reasons (an
other one is that the user might not want to be annoyed by things she/he
did in previous sessions whilst logging in again).
A minimal console_clear implementation with some tiny bugs could be
(this might fail to compile):
#include "required_headers.h"
void main(void) {
int mode;
if (ioctl(STDOUT_FILENO, KDGKBMODE, &mode) != 0)
exit(EXIT_SUCCESS); /* not a console, exit successfully */
if (access("/usr/bin/clear", R_OK | X_OK) == 0)
execl("/usr/bin/clear", "/usr/bin/clear", (char *) NULL);
exit(EXIT_FAILURE);
}
To meet the requirements of this use case, but not clearing the terminal
if it is not required, the shell needs to check if the terminal is
a console (or rather let clear_console do this check), ensure that it is
not a subshell and check that ${0##*/} does not match (-su|su). Also
checking if $SSH_CONNECTION is set would avoid some useless calls to
console_clear.
console_clear could be replaced by checking $(tty) and running clear if
the output indicates that the terminal is a console. But relying on
ttyname() and correctly interpreting its result is not the clean
solution I would prefer. I'd rather wait until doko has the time to fix
/usr/bin/clear_console, i.e., presumably after the gcc transition is
done. Nevertheless, using an zshexit hook seems to be worth
considering.
Carsten
Hi, Carsten Hey wrote: Why? This is a very annoying behaviour IMHO and definitely shouldn't be a default. If a user wants to have such a behaviour because he considers to be a security feature (I don't), the user should configure that in his user's configuration. I'm tempted to mark this as wontfix, but would like to hear the opions of other team-members. Regards, Axel
Hi Axel, * Axel Beckert [2015-08-09 16:12 +0200]: at first we should make sure that you are talking about the same console as I do: I consider everything that runs in X not to be a console, but the thing you get if you press for example Ctrl-Alt-F1 is a console. It is indeed a very annoying behaviour if it isn't implemented correctly, bash's implementation isn't significantly better than adding "(( $RANDOM % 2 )) && clear" to ~/.bash_logout. I'm sure that the people that maintain the possibly best interactive shell in the possibly best Linux distribution are able to implement this in a way that is not completely broken ;) I wonder if you still think that it's annoying if you know, that it only clears a console if, and only if, the parent process is /bin/login. If you still consider what I requested to be annoying (I think I should have made the intension and how it should behave more clear), I could grep bash's changelog for the bug number of the bug that contains the same discussion, which might save some time. It's about the (recommended) user's configuration, no one will ever add this to a *global* zsh config file that is shipped with Debian. Carsten
Hi Carsten, Carsten Hey wrote: Ok, thanks for the clarification. I'm mostly annoyed by such behaviour upon remote logins via SSH as usually the whole terminal history gets lost in such cases. Does SSH use /bin/login by default? (IIRC not.) So if it's really just for the Linux (or FreeBSD or Hurd :-) virtual console, I'm fine with it. There it indeed makes sense. Just not for SSH logins or calling "zsh" or "zsh -l" for testing purposes from another zsh instance (as I do very often before zsh uploads :-). Ok, thanks for that clarification, too. :-) Regards, Axel
Hi Axel, * Axel Beckert [2015-08-09 16:57 +0200]: SSH does not use a console but a pseudo terminal, even if it is invoked from a console (and even if this would not be true in rare cases, the check to avoid spawning a new subprocess if SSH_CONNECTION is set would avoid running clear_console anyway). Therefore the screen would never be cleared when returning from an SSH session. I assume this answers your actual question. You might remember that I asked you if you had physical access to a kFreeBSD box. Now you know what I wanted to test ... This would not be console ;) This could be described as subshell (i.e., the parent process is a shell) and therefore clear_console would not be run. Pasting the code that would be part of the recommended .zlogout could help to clarify some things, but there's still a GPL'd triviality in it. Carsten
* Carsten Hey [2015-08-09 18:05 +0200]:
Without the GPL'd trivial check of being a subshell - i.e., this test
needs to be added before it can be shipped, a ~/.zlogout could look like
this:
if [[ -z ${SSH_CONNECTION-}${TMUX-}${debian_chroot-} ]] &&
[[ ${0##*/} != (-su|su) && -x /usr/bin/clear_console ]]
then
/usr/bin/clear_console || :
fi
The first line is mainly used to avoid accessing the hard disk and
spawning a new process in some common cases - only the check for an
empty ${debian_chroot-} might be required, depending on the actual
implementation of schroot et al.
Also using [[ ${TTY-} != /dev/pts/* ]] would avoid running clear_console
in other cases and possibly make checking ${SSH_CONNECTION-} and
${TMUX-} obsolete.
Carsten
Hi Carsten, Carsten Hey wrote: Sorry, but using /usr/bin/clear_console is a no-go for me. It's shipped in the package "bash" and would add a dependency on bash, at least an implicit one. Bash is currently in the essential set, but there are long-time endeavours to make bash non-essential: https://wiki.debian.org/Proposals/RemoveBashFromEssential So I won't add anything which adds a dependency on bash in the binary packages. (I don't mind build-dependencies.) Regards, Axel