aboutsummaryrefslogtreecommitdiff
path: root/riemann.fmi.uni-sofia.bg/programs/nlogin-0.3-pre/read_password.c
blob: 544e63627057cdee3133237ffc5984e763b11765 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <unistd.h>

int read_password(char *buf) /*EXTRACT_INCL*/{
  int n;
  alarm(120);
  write(1, "Password: ", 10);
  n = read(0, buf, 100);
  alarm(0);
  write(1,"\n",1);
  if (n<0) return -1;
  while (n && buf[n-1] == '\n') --n;
  buf[n] = 0;
  return 0;
}