|
|
@@ -67,18 +67,28 @@ static char* getpassword(const char* prompt) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
// Reads password from stdin and prints encrypted password to stdout. |
|
|
|
// Reads passwords from stdin and prints encrypted passwords to stdout. |
|
|
|
static int encrypt_pipe() { |
|
|
|
char *result = getpassword(NULL); |
|
|
|
if (result) { |
|
|
|
int i; |
|
|
|
|
|
|
|
// We support a maximum of two passwords right now |
|
|
|
for (i = 0;i < 2;i++) { |
|
|
|
char *result = getpassword(NULL); |
|
|
|
if (!result) |
|
|
|
break; |
|
|
|
|
|
|
|
ObfuscatedPasswd obfuscated(result); |
|
|
|
if (fwrite(obfuscated.buf, obfuscated.length, 1, stdout) != 1) { |
|
|
|
fprintf(stderr,"Writing to stdout failed\n"); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
else return 1; |
|
|
|
|
|
|
|
// Did we fail to produce even one password? |
|
|
|
if (i == 0) |
|
|
|
return 1; |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
static ObfuscatedPasswd* readpassword() { |