I tried posting this to [EMAIL PROTECTED], but it didn't get posted.

I recently tried to configure nmh 1.0.2 to work as a POP client on a 
Mandrake Linux 6.1 system, which uses glibc 2.1.1, and it didn't work.

The problem is the glibc edition of 'ruserpass.c', which is called by 'inc'
to get the user password.  The glibc edition of ruserpass won't prompt the user
for a password, and their policy at present is not to change it (see attached
note).

The first thing that comes to mind is to use the 'ruserpass.c' routine supplied
as part of the compatibility routines with nmh.  This is not enough, at 
least if one wants 'nmh' to work with 'exmh'.  The nmh version of ruserpass.c
uses a standard Unix function called 'getpass()' to pick up the password from
the use.  However, the glibc version of 'getpass()' flushes standard input
before prompting the user for a password.  So, since exmh uses code like:

        exec inc +inbox -truncate -nochangecur -width 100 << password

it can't work, since the glibc getpass() function throws the password string
away before issuing the prompt.

I threw together this patch for nmh/sbr/ruserpass.c that works for inc with
exmh:

*** ruserpass.c.orig    Fri Apr 30 14:08:34 1999
--- ruserpass.c Mon Nov 29 14:45:04 1999
***************
*** 178,183 ****
--- 178,210 ----
      return(-1);
  }
  
+ #include <termios.h>
+ char *getpass(const char *prompt)
+ {
+     static char buff[50];
+     char *s;
+     struct termios tio, tioO;
+     int in;
+ 
+     fputs(prompt, stdout);
+     fflush(stdout);
+ 
+     in = fileno(stdin);
+     tcgetattr(in, &tioO);
+     tio = tioO;
+     tio.c_lflag &= ~ECHO;
+     tcsetattr(in, TCSANOW, &tio);
+ 
+     s = fgets(buff, sizeof(buff), stdin);
+     if (!s) buff[0] = 0;
+ 
+     tcsetattr(in, TCSANOW, &tioO);
+ 
+     if (buff[strlen(buff)-1] == '\n') buff[strlen(buff)-1] = 0;
+ 
+     return buff;
+ }
+ 
  static int
  token(void)
  {

Reply via email to