Skip to contentSkip to conversation

vlock command

DISCUSSION Karel Zak 5 participants 17 messages Nov 14, 2012 – Nov 16, 2012 Util-Linux package

lore
Share & tools
lore

Karel Zak

author maintainer
#0 lore raw

vlock(1) - Virtual Console lock program

This nice and small program used by admins on machines with consoles only. Unfortunately it has inactive upstream(s).

The original upstream for vlock-1.3 at

    ftp://tsx-11.mit.edu:/pub/linux/sources/usr.bin/

is inactive for years. There is also new upstream at

http://freecode.com/projects/vlock
http://repo.or.cz/w/vlock.git

but this also seems inactive and from my point of view vlock-2.x is over-engineering rhapsody (glib, plug-ins, dependences resolver, external scripts etc.)

What about to merge vlock-1.3 into utils-linux? It's 630 lines of code (including unnecessary non-PAM code).

Comments & Objections?

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#1 lore raw
Quoted 15 lines · Karel Zak

vlock(1) - Virtual Console lock program

This nice and small program used by admins on machines with consoles only. Unfortunately it has inactive upstream(s).

The original upstream for vlock-1.3 at

    ftp://tsx-11.mit.edu:/pub/linux/sources/usr.bin/

is inactive for years. There is also new upstream at

   http://freecode.com/projects/vlock
   http://repo.or.cz/w/vlock.git
Quoted 9 lines

but this also seems inactive and from my point of view vlock-2.x is over-engineering rhapsody (glib, plug-ins, dependences resolver, external scripts etc.)

What about to merge vlock-1.3 into utils-linux? It's 630 lines of code (including unnecessary non-PAM code).

Comments & Objections?

We have another version of vlock, which is being supported by Dmitry V. Levin.

http://git.altlinux.org/people/ldv/packages/vlock.git

Some time ago, I have merged this version in kbd project:

http://git.altlinux.org/people/legion/packages/kbd.git?p=kbd.git;a=tree;f=src/vlock;h=92419b98175d215a71f83bfb06b409daa97b13c4;hb=768b8c314e1d3c465d895b206da4aa4543914d1d

I have a collection of utilities for manipulation in console (openvt, chvt, deallocvt ...) I consider logical to have the utility for terminal blocking.

What do you think ?

Signature · 1 line
Rgrds, legion
author maintainer
#2 lore raw
Quoted 23 lines · Alexey Gladkov
Quoted 22 lines · Karel Zak

vlock(1) - Virtual Console lock program

This nice and small program used by admins on machines with consoles only. Unfortunately it has inactive upstream(s).

The original upstream for vlock-1.3 at

    ftp://tsx-11.mit.edu:/pub/linux/sources/usr.bin/

is inactive for years. There is also new upstream at

   http://freecode.com/projects/vlock
   http://repo.or.cz/w/vlock.git

but this also seems inactive and from my point of view vlock-2.x is over-engineering rhapsody (glib, plug-ins, dependences resolver, external scripts etc.)

What about to merge vlock-1.3 into utils-linux? It's 630 lines of code (including unnecessary non-PAM code).

Quoted 7 lines
Quoted 2 lines

Comments & Objections?

We have another version of vlock, which is being supported by Dmitry V. Levin.

http://git.altlinux.org/people/ldv/packages/vlock.git

it seems the same code as the original vlock-1.3

Quoted 9 lines

Some time ago, I have merged this version in kbd project:

http://git.altlinux.org/people/legion/packages/kbd.git?p=kbd.git;a=tree;f=src/vlock;h=92419b98175d215a71f83bfb06b409daa97b13c4;hb=768b8c314e1d3c465d895b206da4aa4543914d1d

I have a collection of utilities for manipulation in console (openvt, chvt, deallocvt ...) I consider logical to have the utility for terminal blocking.

What do you think?

Well, vlock is mostly about authentication, but I have no strong opinion about it -- we can keep it in kbd as well.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
author maintainer
#5 lore raw
In reply to Alexey Gladkov
Quoted 4 lines · Alexey Gladkov

We have another version of vlock, which is being supported by Dmitry V. Levin.

http://git.altlinux.org/people/ldv/packages/vlock.git

Alexey, just today I added --erase option to Fedora version. Maybe you can apply the patch below to your repository too. Author of the patch is Petr Pisar <[email protected]>.

Karel

help.c renamed from help.c.kzak +1 -0
diff -up vlock-1.3/help.c.kzak vlock-1.3/help.c
@@ -26,6 +26,7 @@ void print_help(int exitcode) {
 	  "       switch to other virtual consoles.\n"
 	  "-a or --all: lock all virtual consoles by preventing other users\n"
 	  "       from switching virtual consoles.\n"
+	  "-e or --erase: erase current virtual console content\n"
 	  "-v or --version: Print the version number of vlock and exit.\n"
 	  "-h or --help: Print this help message and exit.\n"
 	  );
vlock.1 renamed from vlock.1.kzak +4 -0
diff -up vlock-1.3/vlock.1.kzak vlock-1.3/vlock.1
@@ -38,6 +38,10 @@ Lock all console sessions and disable VC
 .IP
 Lock the current session (this is the default).
 .PP
+.B -e,--erase
+.IP
+Erase current console content to prevent from leaking sensitive data.
+.PP
 .B -h,--help
 .IP
 Print a brief help message.
vlock.c renamed from vlock.c.kzak +14 -1
diff -up vlock-1.3/vlock.c.kzak vlock-1.3/vlock.c
@@ -29,6 +29,9 @@
   /* This determines whether the default behavior is to lock only the */
   /* current VT or all of them.  0 means current, 1 means all. */
   int o_lock_all = 0;
+  /* This determines whether to erase terminal content after the locking.
+   * 0 means do not erase, 1 means to erase. */
+  int o_erase_terminal = 0;
 
 /* Other globals */
   struct vt_mode ovtm;
@@ -41,6 +44,7 @@ int main(int argc, char **argv) {
   static struct option long_options[] = { /* For parsing long arguments */
     {"current", 0, &o_lock_all, 0},
     {"all", 0, &o_lock_all, 1},
+    {"erase", no_argument, &o_erase_terminal, 1},
     {"version", no_argument, 0, O_VERSION},
     {"help", no_argument, 0, O_HELP},
     {0, 0, 0, 0},
@@ -51,7 +55,7 @@ int main(int argc, char **argv) {
   char *env;
 
   /* First we parse all the command line arguments */
-  while ((c = getopt_long(argc, argv, "acvh",
+  while ((c = getopt_long(argc, argv, "acevh",
 			  long_options, &option_index)) != -1) {
     switch(c) {
     case 'c':
@@ -60,6 +64,9 @@ int main(int argc, char **argv) {
     case 'a':
       o_lock_all = 1;
       break;
+    case 'e':
+      o_erase_terminal = 1;
+      break;
     case 'v':
     case O_VERSION:
       fprintf(stderr, VERSION);
@@ -116,6 +123,12 @@ int main(int argc, char **argv) {
     ioctl(vfd, VT_SETMODE, &vtm);
   }
 
+  /* Erase console. 2J erases display; 3J, since Linux 3.0, erases scroll-back
+   * buffer too. */
+  if (o_erase_terminal) {
+    puts("\E[3J\E[2J");
+  }
+
   /* get_password() sets the terminal characteristics and does not */
   /* return until the correct password has been read.              */
   get_password();
Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#7 lore raw
In reply to Karel Zak
Quoted 9 lines · Karel Zak
Quoted 4 lines · Alexey Gladkov

We have another version of vlock, which is being supported by Dmitry V. Levin.

http://git.altlinux.org/people/ldv/packages/vlock.git

Alexey, just today I added --erase option to Fedora version. Maybe you can apply the patch below to your repository too. Author of the patch is Petr Pisar <[email protected]>.

The first vlock RFE for ages! Alexey, please apply.

Signature · 1 line
ldv
#3 lore raw
In reply to Karel Zak
Quoted 4 lines · Karel Zak
Quoted 1 line · Alexey Gladkov

http://git.altlinux.org/people/ldv/packages/vlock.git

it seems the same code as the original vlock-1.3

It was surely based on the same vlock-1.3 code, and it has essentially the same features list, but it's hardly the same code. :)

Quoted 11 lines
Quoted 9 lines

Some time ago, I have merged this version in kbd project:

http://git.altlinux.org/people/legion/packages/kbd.git?p=kbd.git;a=tree;f=src/vlock;h=92419b98175d215a71f83bfb06b409daa97b13c4;hb=768b8c314e1d3c465d895b206da4aa4543914d1d

I have a collection of utilities for manipulation in console (openvt, chvt, deallocvt ...) I consider logical to have the utility for terminal blocking.

What do you think?

Well, vlock is mostly about authentication,

About authentication? Well, could you then explain why do you keep that 7 year old vlock-1.3-morepam.patch from Nalin in Fedora vlock package? It does something unnatural for vlock, e.g. pam_acct_mgmt and even pam_setcred! At the same time, the only module in its account stack is pam_permit.so. Weird.

Signature · 1 line
ldv
#8 lore raw
In reply to Dmitry V. Levin
Quoted 5 lines · Dmitry V. Levin
Quoted 4 lines · Karel Zak
Quoted 3 lines · Alexey Gladkov

We have another version of vlock, which is being supported by Dmitry V. Levin.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

http://git.altlinux.org/people/ldv/packages/vlock.git

Alexey, just today I added --erase option to Fedora version. Maybe you can apply the patch below to your repository too. Author of the patch is Petr Pisar <[email protected]>.

The first vlock RFE for ages! Alexey, please apply.

Dmitry, I mistakenly did not add you in the Cc. I wrote Karel that similar functionality you have already implemented. Here is my answer:

Quoted 9 lines

On closer look I found out that the my version of vlock already erases display if we are on the virtual console:

http://git.altlinux.org/people/legion/packages/kbd.git?p=kbd.git;a=blob;f=src/vlock/screen.c;h=720d880080f9030553a32d625756b5e30c6d4266;hb=768b8c314e1d3c465d895b206da4aa4543914d1d#l37

http://git.altlinux.org/people/legion/packages/kbd.git?p=kbd.git;a=blob;f=src/vlock/vt.c;h=50746de238f5acc231d2ffef8a5604dfbef3cfad;hb=768b8c314e1d3c465d895b206da4aa4543914d1d#l194

As I understand you want a similar functionality. Is this enough for you, or you want to be able to clear the display regardless of conditions?

Signature · 1 line
Rgrds, legion
author maintainer
#9 lore raw
Quoted 7 lines · Alexey Gladkov
Quoted 6 lines · Dmitry V. Levin
Quoted 3 lines · Karel Zak

Alexey, just today I added --erase option to Fedora version. Maybe you can apply the patch below to your repository too. Author of the patch is Petr Pisar <[email protected]>.

Quoted 15 lines
Quoted 1 line

The first vlock RFE for ages! Alexey, please apply.

Dmitry, I mistakenly did not add you in the Cc. I wrote Karel that similar functionality you have already implemented. Here is my answer:

Quoted 9 lines

On closer look I found out that the my version of vlock already erases display if we are on the virtual console:

http://git.altlinux.org/people/legion/packages/kbd.git?p=kbd.git;a=blob;f=src/vlock/screen.c;h=720d880080f9030553a32d625756b5e30c6d4266;hb=768b8c314e1d3c465d895b206da4aa4543914d1d#l37

http://git.altlinux.org/people/legion/packages/kbd.git?p=kbd.git;a=blob;f=src/vlock/vt.c;h=50746de238f5acc231d2ffef8a5604dfbef3cfad;hb=768b8c314e1d3c465d895b206da4aa4543914d1d#l194

As I understand you want a similar functionality. Is this enough for you, or you want to be able to clear the display regardless of conditions?

CC to Petr, original author of the patch.
Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#10 lore raw
Quoted 17 lines · Karel Zak
Quoted 16 lines · Alexey Gladkov
Quoted 7 lines · Dmitry V. Levin
Quoted 3 lines · Karel Zak

Alexey, just today I added --erase option to Fedora version. Maybe you can apply the patch below to your repository too. Author of the patch is Petr Pisar <[email protected]>.

The first vlock RFE for ages! Alexey, please apply.

Dmitry, I mistakenly did not add you in the Cc. I wrote Karel that similar functionality you have already implemented. Here is my answer:

Quoted 3 lines

On closer look I found out that the my version of vlock already erases display if we are on the virtual console:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

http://git.altlinux.org/people/legion/packages/kbd.git?p=kbd.git;a=blob;f=src/vlock/screen.c;h=720d880080f9030553a32d625756b5e30c6d4266;hb=768b8c314e1d3c465d895b206da4aa4543914d1d#l37

http://git.altlinux.org/people/legion/packages/kbd.git?p=kbd.git;a=blob;f=src/vlock/vt.c;h=50746de238f5acc231d2ffef8a5604dfbef3cfad;hb=768b8c314e1d3c465d895b206da4aa4543914d1d#l194

As I understand you want a similar functionality. Is this enough for you,

It's similar but insufficient. The difference between your clear_str[] = "\33[H\33[J" and my string is my way clears scroll-back buffer of Linux virtual terminal too. This prevents from reading history using Shift-PgUp while the terminal is locked. Read current console_codes(4) page, especially search for word "buffer".

So what I ask is to prepend "\33[3J" to your clear_str[]. This even users with older kernel not implementing this code get console cleared.

Quoted 1 line

or you want to be able to clear the display regardless of conditions?

If I understand the code correctly, you clear screen only if it's a virtual terminal. I have no idea how usefull is vlock on other terminals (I use "screen" there), so I do not request any change in this matter.

-- Petr

#11 lore raw
Quoted 8 lines · Petr Pisar

It's similar but insufficient. The difference between your clear_str[] = "\33[H\33[J" and my string is my way clears scroll-back buffer of Linux virtual terminal too. This prevents from reading history using Shift-PgUp while the terminal is locked. Read current console_codes(4) page, especially search for word "buffer".

So what I ask is to prepend "\33[3J" to your clear_str[]. This even users with older kernel not implementing this code get console cleared.

Sounds reasonable.

Quoted 3 lines

If I understand the code correctly, you clear screen only if it's a virtual terminal. I have no idea how usefull is vlock on other terminals (I use "screen" there), so I do not request any change in this matter.

Ok. This is what I wanted to find out.

Guys, I want to release the new version of kbd next month. This will be the first kbd release with the vlock. Do you have any more suggestions on vlock?

Signature · 1 line
Rgrds, legion
author maintainer
#12 lore raw
Quoted 16 lines · Alexey Gladkov
Quoted 8 lines · Petr Pisar

It's similar but insufficient. The difference between your clear_str[] = "\33[H\33[J" and my string is my way clears scroll-back buffer of Linux virtual terminal too. This prevents from reading history using Shift-PgUp while the terminal is locked. Read current console_codes(4) page, especially search for word "buffer".

So what I ask is to prepend "\33[3J" to your clear_str[]. This even users with older kernel not implementing this code get console cleared.

Sounds reasonable.

Quoted 3 lines

If I understand the code correctly, you clear screen only if it's a virtual terminal. I have no idea how usefull is vlock on other terminals (I use "screen" there), so I do not request any change in this matter.

Quoted 5 lines

Ok. This is what I wanted to find out.

Guys, I want to release the new version of kbd next month. This will be the first kbd release with the vlock. Do you have any more suggestions on vlock?

Rename --enable-vlock to --disable-vlock and enable it by default :-)

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#13 lore raw
Quoted 1 line · Karel Zak

Rename --enable-vlock to --disable-vlock and enable it by default :-)

No problem :)

Signature · 1 line
Rgrds, legion
#14 lore raw
In reply to Alexey Gladkov
Quoted 4 lines · Alexey Gladkov

Guys, I want to release the new version of kbd next month. This will be the first kbd release with the vlock. Do you have any more suggestions on vlock?

Yes. Could you please internationalize vlock code (adding the setlocate(), bindtextdomain(), textdomain(), and _() around all messages)? I'll be happy to translate it then.

-- Petr

author maintainer
#4 lore raw
In reply to Dmitry V. Levin
Quoted 2 lines · Dmitry V. Levin

Well, could you then explain why do you keep that
7 year old vlock-1.3-morepam.patch from Nalin in Fedora vlock package?

...to make it compatible with many others PAM applications. It's common practice to use pam_authenticate() + pam_acct_mgmt() + pam_setcred(). I don't think it's good idea to make any exceptions from this practice.

You need pam_acct_mgmt() to check account validity, expiration etc.

Quoted 3 lines

It does something unnatural for vlock, e.g. pam_acct_mgmt and even pam_setcred! At the same time, the only module in its account stack is pam_permit.so. Weird.

Well, it's only config file, $EDITOR /etc/pam.d/vlock is enough to make your configuration more paranoid. It's definitely better to support all the features by binary and define policies in config files.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#15 lore raw
In reply to Petr Pisar
Quoted 8 lines · Petr Pisar
Quoted 4 lines · Alexey Gladkov

Guys, I want to release the new version of kbd next month. This will be the first kbd release with the vlock. Do you have any more suggestions on vlock?

Yes. Could you please internationalize vlock code (adding the setlocate(), bindtextdomain(), textdomain(), and _() around all messages)? I'll be happy to translate it then.

Please check:

http://git.altlinux.org/people/legion/packages/kbd.git

Signature · 1 line
Rgrds, legion
#16 lore raw
Quoted 6 lines · Alexey Gladkov
Quoted 5 lines · Petr Pisar
Quoted 4 lines · Alexey Gladkov

Guys, I want to release the new version of kbd next month. This will be the first kbd release with the vlock. Do you have any more suggestions on vlock?

Quoted 8 lines
Quoted 3 lines

Yes. Could you please internationalize vlock code (adding the setlocate(), bindtextdomain(), textdomain(), and _() around all messages)? I'll be happy to translate it then.

Please check:

http://git.altlinux.org/people/legion/packages/kbd.git

It looks good. Once new catalog appears on the Translation Project, me or the assigned translator will update Czech translation.

Thanks.

-- Petr