[dovecot-cvs] dovecot/src/master askpass.c, NONE, 1.1 askpass.h,
NONE, 1.1
cras at dovecot.org
cras at dovecot.org
Sun Jan 15 15:20:59 EET 2006
- Previous message: [dovecot-cvs] dovecot/src/master Makefile.am, 1.17, 1.18 common.h,
1.24, 1.25 login-process.c, 1.69, 1.70 main.c, 1.70,
1.71 master-settings.c, 1.100, 1.101 master-settings.h, 1.66, 1.67
- Next message: [dovecot-cvs] dovecot/src/auth db-passwd-file.c, 1.18,
1.19 db-passwd-file.h, 1.9, 1.10 passdb-passwd-file.c, 1.24,
1.25 userdb-passwd-file.c, 1.19, 1.20
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/master
In directory talvi:/tmp/cvs-serv20337
Added Files:
askpass.c askpass.h
Log Message:
Forgot to add in last commit
--- NEW FILE: askpass.c ---
/* Copyright (C) 2006 Timo Sirainen */
#include "lib.h"
#include "askpass.h"
#include <stdio.h>
#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
void askpass(const char *prompt, char *buf, size_t buf_size)
{
struct termios old_tio, tio;
bool restore_tio = FALSE;
ssize_t ret;
size_t pos;
char ch;
int fd;
if (!isatty(STDIN_FILENO))
i_fatal("stdin isn't a TTY");
fputs(prompt, stderr);
fflush(stderr);
fd = open("/dev/tty", O_RDONLY);
if (fd < 0)
i_fatal("open(/dev/tty) failed: %m");
/* turn off echo */
if (tcgetattr(fd, &old_tio) == 0) {
restore_tio = TRUE;
tio = old_tio;
tio.c_lflag &= ~(ECHO | ECHONL);
(void)tcsetattr(fd, TCSAFLUSH, &tio);
}
/* read the password */
pos = 0;
while ((ret = read(fd, &ch, 1)) > 0) {
if (pos >= buf_size-1)
break;
if (ch == '\n' || ch == '\r')
break;
buf[pos++] = ch;
}
buf[pos] = '\0';
if (restore_tio)
(void)tcsetattr(fd, TCSAFLUSH, &old_tio);
fputs("\n", stderr); fflush(stderr);
(void)close(fd);
}
--- NEW FILE: askpass.h ---
#ifndef __ASKPASS_H
#define __ASKPASS_H
void askpass(const char *prompt, char *buf, size_t buf_size);
#endif
- Previous message: [dovecot-cvs] dovecot/src/master Makefile.am, 1.17, 1.18 common.h,
1.24, 1.25 login-process.c, 1.69, 1.70 main.c, 1.70,
1.71 master-settings.c, 1.100, 1.101 master-settings.h, 1.66, 1.67
- Next message: [dovecot-cvs] dovecot/src/auth db-passwd-file.c, 1.18,
1.19 db-passwd-file.h, 1.9, 1.10 passdb-passwd-file.c, 1.24,
1.25 userdb-passwd-file.c, 1.19, 1.20
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list