3f891b
commit 0aec2900f63820c3405ba38a4d1cd67cc22f0715
3f891b
Author: Miroslav Lichvar <mlichvar@redhat.com>
3f891b
Date:   Mon Jul 18 17:26:47 2011 +0200
3f891b
3f891b
    Clear scrollback buffer when locking terminal
3f891b
    
3f891b
    Linux kernel 3.0 adds a new command to clear the scrollback buffer in
3f891b
    the linux console. It's available in the ncurses terminfo entry as
3f891b
    extended capability E3. This is useful to prevent an attacker to read
3f891b
    content of a locked terminal via Shift-PgUp key.
3f891b
3f891b
diff --git a/src/display.c b/src/display.c
3f891b
index 5fa11cb..038c435 100644
3f891b
--- a/src/display.c
3f891b
+++ b/src/display.c
3f891b
@@ -3779,4 +3779,10 @@ char **cmdv;
3f891b
 
3f891b
 #endif /* BLANKER_PRG */
3f891b
 
3f891b
+void
3f891b
+ClearScrollbackBuffer()
3f891b
+{
3f891b
+  if (D_CE3)
3f891b
+    AddCStr(D_CE3);
3f891b
+}
3f891b
 
3f891b
diff --git a/src/extern.h b/src/extern.h
3f891b
index c787d99..d3fecf0 100644
3f891b
--- a/src/extern.h
3f891b
+++ b/src/extern.h
3f891b
@@ -316,6 +316,7 @@ extern int   color256to88 __P((int));
3f891b
 extern void  ResetIdle __P((void));
3f891b
 extern void  KillBlanker __P((void));
3f891b
 extern void  DisplaySleep1000 __P((int, int));
3f891b
+extern void  ClearScrollbackBuffer __P((void));
3f891b
 
3f891b
 /* resize.c */
3f891b
 extern int   ChangeWindowSize __P((struct win *, int, int, int));
3f891b
diff --git a/src/screen.c b/src/screen.c
3f891b
index cc8f565..3efb67b 100644
3f891b
--- a/src/screen.c
3f891b
+++ b/src/screen.c
3f891b
@@ -1967,6 +1967,7 @@ int mode;
3f891b
 #endif
3f891b
     case D_LOCK:
3f891b
       ClearAll();
3f891b
+      ClearScrollbackBuffer();
3f891b
       sign = SIG_LOCK;
3f891b
       /* tell attacher to lock terminal with a lockprg. */
3f891b
       break;
3f891b
diff --git a/src/term.c b/src/term.c
3f891b
index 991de1b..7485900 100644
3f891b
--- a/src/term.c
3f891b
+++ b/src/term.c
3f891b
@@ -83,6 +83,7 @@ struct term term[T_N] =
3f891b
   { "CD", T_STR  },
3f891b
   { "ce", T_STR  },
3f891b
   { "cb", T_STR  },
3f891b
+  { "E3", T_STR  },
3f891b
 
3f891b
 /* initialise */
3f891b
   { "is", T_STR  },