summaryrefslogtreecommitdiff
path: root/gpg2ssh.c
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2008-04-09 12:46:33 -0400
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2008-04-09 12:46:33 -0400
commitea04bfffe93df1f3467a5c33c0dda335ff0a11f6 (patch)
tree1763cac016122b07af979a23eb101a57fa72059a /gpg2ssh.c
parent91ab8af41d77490776ea4e7853fd855f4aad573a (diff)
gpg2ssh: check the return status of the base64 pipe so we can fail properly if it does.
Diffstat (limited to 'gpg2ssh.c')
-rw-r--r--gpg2ssh.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gpg2ssh.c b/gpg2ssh.c
index f696f65..6155549 100644
--- a/gpg2ssh.c
+++ b/gpg2ssh.c
@@ -48,6 +48,7 @@ int main(int argc, char* argv[]) {
char* const args[] = {"/usr/bin/base64", "--wrap=0", NULL};
const char* algoname;
int mpicount;
+ int pipestatus;
init_gnutls();
@@ -258,23 +259,27 @@ int main(int argc, char* argv[]) {
snprintf(output_data, sizeof(output_data), "%s %s ", userid, algoname);
- write(1, output_data, strlen(output_data));
-
pipefd = create_writing_pipe(&child_pid, args[0], args);
if (pipefd < 0) {
err("failed to create a writing pipe (returned %d)\n", pipefd);
return pipefd;
}
+ write(1, output_data, strlen(output_data));
+
if (0 != write_data_fd_with_length(pipefd, all, mpicount)) {
err("was not able to write out RSA key data\n");
return 1;
}
close(pipefd);
- if (child_pid != waitpid(child_pid, NULL, 0)) {
+ if (child_pid != waitpid(child_pid, &pipestatus, 0)) {
err("could not wait for child process to return for some reason.\n");
return 1;
}
+ if (pipestatus != 0) {
+ err("base64 pipe died with return code %d\n", pipestatus);
+ return pipestatus;
+ }
write(1, "\n", 1);