chroot stub, getpass advice

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


In message <Pine.LNX.4.44.0203061848540.25224-100000 at portal.acad.cai.cam.ac.uk>
          Theo Markettos <theo at markettos.org.uk> 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);


HTH.


-- 
------------------------------------------------------------------------
 Peter Naulls - peter at chocky.org
 RISC OS Projects Initiative  -  http://www.chocky.org/initiative/
 Java for RISC OS and ARM     -  http://www.chocky.org/java/
 Debian Linux on RiscPCs      -  http://www.chocky.org/debian/
------------------------------------------------------------------------



More information about the gcc mailing list