(proto): with `--fork', create a child and send over/receive creds

with export/import_sec_context


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7927 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2000-02-12 21:34:11 +00:00
parent f8d313b2e0
commit 41fbbd1a82
2 changed files with 72 additions and 2 deletions

View File

@@ -153,7 +153,42 @@ proto (int sock, const char *hostname, const char *service)
}
}
return do_trans (sock, context_hdl);
if (fork_flag) {
pid_t pid;
int pipefd[2];
if (pipe (pipefd) < 0)
err (1, "pipe");
pid = fork ();
if (pid < 0)
err (1, "fork");
if (pid != 0) {
gss_buffer_desc buf;
maj_stat = gss_export_sec_context (&min_stat,
&context_hdl,
&buf);
if (GSS_ERROR(maj_stat))
gss_err (1, min_stat, "gss_export_sec_context");
write_token (pipefd[1], &buf);
exit (0);
} else {
gss_ctx_id_t context_hdl;
gss_buffer_desc buf;
close (pipefd[1]);
read_token (pipefd[0], &buf);
close (pipefd[0]);
maj_stat = gss_import_sec_context (&min_stat, &buf, &context_hdl);
if (GSS_ERROR(maj_stat))
gss_err (1, min_stat, "gss_import_sec_context");
gss_release_buffer (&min_stat, &buf);
return do_trans (sock, context_hdl);
}
} else {
return do_trans (sock, context_hdl);
}
}
int