put previously global error handling and key hashes into ptx (pcp context) to make libpcp threadsafe.

This commit is contained in:
TLINDEN
2014-05-04 17:11:03 +02:00
parent d1c87d1001
commit da9891ff81
58 changed files with 1330 additions and 958 deletions

View File

@@ -58,13 +58,13 @@ pcp_readpass(char ** passwd, const char * prompt,
/* If we're reading from a terminal, try to disable echo. */
if ((usingtty = isatty(fileno(readfrom))) != 0) {
if (tcgetattr(fileno(readfrom), &term_old)) {
fatal("Cannot read terminal settings");
fatal(ptx, "Cannot read terminal settings");
goto err1;
}
memcpy(&term, &term_old, sizeof(struct termios));
term.c_lflag = (term.c_lflag & ~ECHO) | ECHONL;
if (tcsetattr(fileno(readfrom), TCSANOW, &term)) {
fatal("Cannot set terminal settings");
fatal(ptx, "Cannot set terminal settings");
goto err1;
}
}
@@ -76,7 +76,7 @@ retry:
/* Read the password. */
if (fgets(passbuf, MAXPASSLEN, readfrom) == NULL) {
fatal("Cannot read password");
fatal(ptx, "Cannot read password");
goto err2;
}
@@ -85,7 +85,7 @@ retry:
if (usingtty)
fprintf(stderr, "%s: ", confirmprompt);
if (fgets(confpassbuf, MAXPASSLEN, readfrom) == NULL) {
fatal("Cannot read password");
fatal(ptx, "Cannot read password");
goto err2;
}
if (strcmp(passbuf, confpassbuf)) {
@@ -108,7 +108,7 @@ retry:
/* Copy the password out. */
if ((*passwd = strdup(passbuf)) == NULL) {
fatal("Cannot allocate memory");
fatal(ptx, "Cannot allocate memory");
goto err1;
}