tags:

views:

483

answers:

3

I swear there used to be a way in X to start capturing all terminal traffic to a file on your host. It may have been a HummingBird extension, but I thought it was standard. Now, I can't find the trick. Am I hallucinating (happens when you get old), or is it possible?

I'm not talking about 'tee'. I want to be able to send a xterm control-sequence to stdout, giving a file name, and have everthing shown in the window from that time onward saved to the file (until the bookend cancel is issued).

A: 

I am a little bit confused by the way you asked your question. First you mention Xterm then X and then terminal, are you simply looking for the "tee" (man tee) command?

André
Thanks for the feedback -- question edited and improved, I hope.
Kevin Little
+1  A: 

Question is rather vague.

Try looking at:

  1. "ttyrec/ttyplay" for recording a text-mode "movie" of your terminal session
  2. "screen" for recording a log out stdout of your entire session
  3. "tee" for recording a stdout/stderr of a single command
ADEpt
"screen -L" is close, but can't be started/stopped via control-sequences. But, it may be as close as I can get...
Kevin Little
+1  A: 

This feature is called logging and exists in the source code but is disabled by default for security reasons. Do you really want everyone with the ability to write control sequences to your terminal (e.g., the author of any file you might one day cat) to be able to write arbitrary data to arbitrarily-named files under your account?

For example, an attacker could easily use this functionality to modify your ~/.ssh/authorized_keys to grant the attacker access, and change your ~/.profile to ping the attacker with your IP address.

That said, if you compile xterm with --enable-logging AND you #define ALLOWLOGFILECHANGES, then according to the Xterm Control Sequences manual, you will gain access to the following control sequences:

^[[?46h            Start logging
^[[?46l            Stop logging
^[]46;filename\007 Change log file to `filename`

The log file name will by default be called Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX.

There is also an option to enable logging through a pipe, which is also very dangerous if you allow changing the logger via control sequences. That would also allow anyone to execute their code on your system.

andrew
Suspected this... I'll not compromise the security of xterm just to get this little benefit. I've gone to a two-level scripting scheme where full logging of the inner script is an option given to the outer script. Thanks!
Kevin Little