From 750bbcf9a80c2613245b47a366ed66e0abace561 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Fri, 14 Aug 2009 15:01:35 +0200 Subject: added support for %prompt-ing private key passhprases in strokes "ipsec secrets" --- src/stroke/stroke.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/stroke') 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) { -- cgit v1.2.3