diff options
author | Martin Willi <martin@strongswan.org> | 2009-08-14 15:01:35 +0200 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2009-08-26 11:23:50 +0200 |
commit | 750bbcf9a80c2613245b47a366ed66e0abace561 (patch) | |
tree | 83e122bd1b717bc0f2d8570bcd4d09d8f4d3288c /src/stroke | |
parent | 7c2d883af79ded800a19179bdb061210ac30e4fc (diff) | |
download | strongswan-750bbcf9a80c2613245b47a366ed66e0abace561.tar.bz2 strongswan-750bbcf9a80c2613245b47a366ed66e0abace561.tar.xz |
added support for %prompt-ing private key passhprases in strokes "ipsec secrets"
Diffstat (limited to 'src/stroke')
-rw-r--r-- | src/stroke/stroke.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/stroke/stroke.c b/src/stroke/stroke.c index c27a8ca3e..186e480d1 100644 --- a/src/stroke/stroke.c +++ b/src/stroke/stroke.c @@ -55,7 +55,7 @@ static int send_stroke_msg (stroke_msg_t *msg) { struct sockaddr_un ctl_addr; int sock; - char buffer[64]; + char buffer[512]; int byte_count; ctl_addr.sun_family = AF_UNIX; @@ -89,6 +89,16 @@ static int send_stroke_msg (stroke_msg_t *msg) { buffer[byte_count] = '\0'; printf("%s", buffer); + + /* we prompt if we receive the "Passphrase:" magic keyword */ + if (byte_count >= 12 && + strcmp(buffer + byte_count - 12, "Passphrase:\n") == 0) + { + if (fgets(buffer, sizeof(buffer), stdin)) + { + if (write(sock, buffer, strlen(buffer))); + } + } } if (byte_count < 0) { |