chroot stub, getpass advice

Peter Naulls peter at
Wed Mar 6 11:36:29 PST 2002

In message <Pine.LNX.4.44.0203061848540.25224-100000 at>
          Theo Markettos <theo at> wrote:

> Here's a basic stub for chroot.  This is my first patch, so I'm not sure
> what to do about creating a new file (I assume CVS sorts all the rcs
> tags), and please tell me if there's a better diff format...
> Also, I'm looking at implementing getpass.  But tty.c is big and scary,
> and I don't understand how to turn echo off.  Essentially I want to do:
> echo(off);
> fgets(pass,length,stdin);
> echo(on);

You want something like:

  struct termios tio;
  struct termios saved_tio;

  tcgetattr(fileno(stdin), &tio);
  saved_tio = tio;
  tio.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
  tcsetattr(fileno(stdin), TCSANOW, &tio);

  (read stuff)

  tcsetattr(fileno(f), TCSANOW, &saved_tio);


 Peter Naulls - peter at
 RISC OS Projects Initiative  -
 Java for RISC OS and ARM     -
 Debian Linux on RiscPCs      -

More information about the gcc mailing list