}
}
- if ( cert || key ) {
- if ( glite_gsplugin_init_context(&ctx) ) { perror("init context"); exit(1); }
- if (edg_wll_gss_acquire_cred_gsi(cert, key, &cred, NULL) != 0) {
- fprintf (stderr, "Failed to set credentials\n");
- exit(1);
- }
- glite_gsplugin_set_credential(ctx, cred);
- }
-
soap_init(&soap);
soap_set_namespaces(&soap, namespaces);
- if ( soap_register_plugin_arg(&soap, glite_gsplugin, ctx? : NULL) ) {
+ if ( soap_register_plugin_arg(&soap, glite_gsplugin, NULL) ) {
fprintf(stderr, "Can't register plugin\n");
exit(1);
}
+ if ( cert || key ) {
+ ctx = glite_gsplugin_get_context(&soap);
+ if (ctx == NULL) {
+ fprintf(stderr, "Can't get context\n");
+ exit(1);
+ }
+
+ if (glite_gsplugin_set_credential(ctx, cert, key) != 0) {
+ fprintf(stderr, "Can't set credentials: %s\n",
+ glite_gsplugin_errdesc(&soap));
+ exit(1);
+ }
+ }
+
if ( soap_bind(&soap, NULL, 19999, 100) < 0 ) {
soap_print_fault(&soap, stderr);
exit(1);
{
struct soap soap;
edg_wll_GssStatus gss_code;
+ edg_wll_GssCred cred = NULL;
+ edg_wll_GssConnection connection;
glite_gsplugin_Context ctx;
struct sockaddr_in a;
int alen;
}
}
- if ( edg_wll_gss_acquire_cred_gsi(cert_filename, key_filename, &ctx->cred, &gss_code) ) {
+ if ( edg_wll_gss_acquire_cred_gsi(cert_filename, key_filename, &cred, &gss_code) ) {
edg_wll_gss_get_error(&gss_code, "Failed to read credential", &msg);
fprintf(stderr, "%s\n", msg);
free(msg);
exit(1);
}
- if (ctx->cred->name) {
- printf("server running with certificate: %s\n", ctx->cred->name);
+ if (cred->name) {
+ printf("server running with certificate: %s\n", cred->name);
}
+ glite_gsplugin_use_credential(ctx, cred);
+
soap_init(&soap);
soap_set_namespaces(&soap, namespaces);
a.sin_addr.s_addr = INADDR_ANY;
if ( bind(sock, (struct sockaddr *)&a, sizeof(a)) ) { perror("bind()"); exit(1); }
if ( listen(sock, 100) ) { perror("listen()"); exit(1); }
- if ( !(ctx->connection = malloc(sizeof(*ctx->connection))) ) exit(1);
bzero((char *) &a, alen);
perror("accept");
exit(1);
}
- if ( edg_wll_gss_accept(ctx->cred,conn,ctx->timeout,ctx->connection,&gss_code) ){
+ if ( edg_wll_gss_accept(cred,conn,ctx->timeout,&connection,&gss_code) ){
edg_wll_gss_get_error(&gss_code, "Failed to read credential", &msg);
fprintf(stderr, "%s\n", msg);
free(msg);
exit(1);
}
+ glite_gsplugin_set_connection(ctx, &connection);
+
printf("serving connection\n");
if ( soap_serve(&soap) ) {
soap_print_fault(&soap, stderr);
soap_destroy(&soap); /* clean up class instances */
soap_end(&soap); /* clean up everything and close socket */
+ edg_wll_gss_close(&connection, NULL);
}
soap_done(&soap); /* close master socket */
glite_gsplugin_free_context(ctx);
+ edg_wll_gss_release_cred(&cred, NULL);
return 0;
}
extern void glite_gsplugin_set_udata(struct soap *, void *);
extern void glite_gsplugin_set_timeout(glite_gsplugin_Context, struct timeval const *);
-extern void glite_gsplugin_set_credential(glite_gsplugin_Context, edg_wll_GssCred);
+extern int glite_gsplugin_set_credential(glite_gsplugin_Context, const char *, const char *);
+extern void glite_gsplugin_use_credential(glite_gsplugin_Context, edg_wll_GssCred);
extern int glite_gsplugin_set_connection(glite_gsplugin_Context, edg_wll_GssConnection *);
extern int glite_gsplugin(struct soap *, struct soap_plugin *, void *);
else ctx->timeout = NULL;
}
-#if 0
int
glite_gsplugin_set_credential(glite_gsplugin_Context ctx,
const char *cert,
const char *key)
{
edg_wll_GssStatus gss_code;
+ edg_wll_GssCred cred = NULL;
+
int ret;
- ret = edg_wll_gss_acquire_cred_gsi((char *)cert, (char *)key, &ctx->cred, &gss_code);
+ ret = edg_wll_gss_acquire_cred_gsi((char *)cert, (char *)key, &cred, &gss_code);
if (ret) {
- /* XXX propagate error description */
+ edg_wll_gss_get_error(&gss_code, "failed to load GSI credentials",
+ &ctx->error_msg);
return EINVAL;
}
- free(ctx->cert_filename);
- free(ctx->key_filename);
+ if (ctx->internal_credentials && ctx->cred != NULL)
+ edg_wll_gss_release_cred(&ctx->cred, NULL);
- ctx->cert_filename = strdup(cert);
- ctx->key_filename = strdup(key);
+ ctx->cred = cred;
+ ctx->internal_credentials = 1;
return 0;
}
-#endif
void
-glite_gsplugin_set_credential(glite_gsplugin_Context ctx,
+glite_gsplugin_use_credential(glite_gsplugin_Context ctx,
edg_wll_GssCred cred)
{
ctx->cred = cred;