A month later...

On Wed, Nov 18, 2020 at 07:55:07PM -0500, Judah Milgram wrote:
> On 11/18/20 10:04 AM, Moshe M. Katz wrote:
>> I believe the intent here is to protect non-GUI console sessions,
>> because they do not have a screensaver that can lock.
>
> Makes sense. More than once I've flipped over to a non-X virtual console
> to do one thing after another, and forgotten to log out before flipping
> back to X.
>
> But the way they do it, it gets exported from your first login shell on
> down, and it's set readonly, so you can't unset it. So if you set up
> some work in an xterm, and get distracted for 10 minutes (or work in
> another xterm for 10 minutes), the xterm will silently disappear with no
> warning. In fact, for the first week after it started, I was scouring
> the logs trying to figure out why my xterms were crashing.
>
> Maybe there's a way to test whether the shell is starting up at a console.

Just like Perl, there's more than one way to do it.  If you're looking for
the *difference* between console sessions and X sessions,

- "$DISPLAY" isn't set on the console (usually - if it is, you're doing
  something weird)

- bash on Slackware sets the BASH_SOURCE array - if ${BASH_SOURCE[1]} is
  either "/usr/lib/X11/xdm/Xsession" or "/usr/lib64/X11/xdm/Xsession" then
  you've logged in via X (xdm, in fact).  I have no idea what Red Hat does
  here, but looking at the output of "set | less" until doing your taxes
  seems more rewarding will probably give you some clues as to what gets set
  under X that isn't set on the console (and maybe isn't set on a remote
  session either (e.g., SSH)).

- Speaking of SSH, if you use an agent that gets forwarded, SSH will set
  some environment variables:

  bstern@banjo:~$ set | grep SSH
  SSH_AUTH_SOCK=/tmp/ssh-aZsL1HQrBU/agent.28294
  SSH_CLIENT='10.1.2.4 42726 22'
  SSH_CONNECTION='10.1.2.4 42726 10.3.5.17 22'
  SSH_TTY=/dev/pts/3

  After some quick research, the latter 3 are there even without an agent.

- The tty command might help too:

  bstern@banjo:~$ tty
  /dev/pts/3

  The console is /dev/ttyN, not /dev/pts/N.

> Peter's solution (zsh) works and I'm finding zsh pretty cool, to boot.

I sort of love the solution of "use a shell that doesn't honor TMOUT".

Cheers,
Ben
-- 
Ben Stern
This space intentionally left blank.

You received this email because you are subscribed to the UM Linux User's Group 
(UM-LINUX) mailing list. If you would like to unsubscribe from this list, 
simply send an email to lists...@listserv.umd.edu with the message signoff 
UM-LINUX in the body.

Reply via email to