On Mon, Feb 21, 2011 at 04:51:41AM +0100, Guillem Jover wrote:
> found 614049 1.1-2
> notfound 614049 1.0-1

...
 
> Anyway, the problem here is that init
> starts the agettys from inittab and ngetty starts itself too from the
> new init script. And both gettys fight for the terminal. This will
> happen if one has not deactivated the gettys entries in inittab, it
> might also happen if one has configured inittab to start the ngetty
> helper.
> 
> The correct solution here is to remove the init script, and the users
> should change the inittab themselves. This also agrees with the sance
> from the sysvinit maintainer in #613618.

Right!  The problem is how to find which ttys are unused.  If X-server
or agetty opens /dev/tty1 we should not start ngetty on tty1.  I wrote
a simple program which find all free ttys.  If this solves the problem
in next release of ngetty I'll include it in the package.  Maybe the
name lsfreevt is better ;)  Start for example:
        tryvt 12
to see which tty <= 12 are free (not in use).
You must start it as root or make it SUID.

How do you find the idea:
        ngetty -5
It finds the first 5 free consoles and open them.  They could
be for example:  2 5 6 7 9.  X-server opens the first free tty. 

/nv

----------- tryvt.c ------------
/* 
   [diet -Os] gcc -Wall -W -o tryvt tryvt.c 
   usage: tryvt [number]
   only first two digits of number are important!
*/

#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/vt.h>

int main(int argc, char **argv) {
  int vtno, fd, max_consoles;
  char tty[12] = "/dev/tty0", *x = tty + 8; 
  max_consoles = MAX_NR_CONSOLES;

  if (argc > 1) {
    unsigned char ch;
    max_consoles = 0;
    if ((ch = argv[1][0] - '0') < 10) max_consoles = ch;
    if ((ch = argv[1][1] - '0') < 10) max_consoles = max_consoles*10 + ch;
  }

  fd = open(tty, O_RDWR, 0);
  if (fd < 0) return -1;

  do {
    char *y = x;
    if (ioctl(fd, VT_OPENQRY, &vtno) || vtno > max_consoles) break;

    if (vtno >= 10) *y++ = '0' + vtno/10;
    *y++ = '0' + vtno%10;
    *y++ = ' ';

    write(1, x, y-x);
    y[-1] = 0;

    if (open(tty, O_RDWR | O_NOCTTY) < 0) break;
  } while (1);

  write(1,"\n",1);
  return 0;
}



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to