Split of gsoap-plugin to the two modules (quite aggressive change but seems working...
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Mon, 11 Jun 2007 15:54:38 +0000 (15:54 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Mon, 11 Jun 2007 15:54:38 +0000 (15:54 +0000)
org.glite.jp.client/src/jpimporter.c
org.glite.jp.index/src/bones_server.c
org.glite.jp.index/src/soap_ps_calls.c
org.glite.jp.primary/src/bones_server.c
org.glite.jp.primary/src/is_client.c
org.glite.jp.server-common/src/db.c
org.glite.jp.ws-interface/src/ws_fault.c
org.glite.lb.server/src/bkserverd.c

index 31e9a3d..453f2b5 100644 (file)
@@ -157,7 +157,7 @@ int main(int argc, char *argv[])
        char                    *name,
                                pidfile[PATH_MAX] = GLITE_JPIMPORTER_PIDFILE;
        glite_gsplugin_Context  plugin_ctx;
-
+       gss_cred_id_t           cred;
 
        name = strrchr(argv[0],'/');
        if (name) name++; else name = argv[0];
@@ -269,9 +269,12 @@ int main(int argc, char *argv[])
        soap_set_namespaces(soap, jpps__namespaces);
 
        glite_gsplugin_init_context(&plugin_ctx);
-       if (server_key) plugin_ctx->key_filename = strdup(server_key);
-       if (server_cert) plugin_ctx->cert_filename = strdup(server_cert);
+       if (edg_wll_gss_acquire_cred_gsi(server_cert, server_key, &cred, NULL, NULL) != 0) {
+               perror("can't acquire credentials");
+               exit(1);
+       }
        glite_gsplugin_set_timeout(plugin_ctx, &to);
+       glite_gsplugin_set_credential(plugin_ctx, mycred);
 
        soap_register_plugin_arg(soap, glite_gsplugin,plugin_ctx);
 
index da846d8..bc3b397 100644 (file)
@@ -14,7 +14,6 @@
 #include <stdsoap2.h>
 #include <glite/security/glite_gss.h>
 #include <glite/security/glite_gsplugin.h>
-#include <glite/security/glite_gsplugin-int.h>
 
 #include "conf.h"
 #include "db_ops.h"
@@ -326,6 +325,7 @@ int newconn(int conn,struct timeval *to,void *data)
        gss_buffer_desc         token = GSS_C_EMPTY_BUFFER;
        OM_uint32               maj_stat,min_stat;
        int                     ret = 0;
+       edg_wll_GssConnection   connection;
 
 
        soap_init2(soap,SOAP_IO_KEEPALIVE,SOAP_IO_KEEPALIVE);
@@ -334,9 +334,6 @@ int newconn(int conn,struct timeval *to,void *data)
        soap_set_namespaces(soap,jp__namespaces);
        soap->user = (void *) private;
 
-       glite_gsplugin_init_context(&plugin_ctx);
-       plugin_ctx->connection = calloc(1,sizeof *plugin_ctx->connection);
-
        switch (edg_wll_gss_watch_creds(server_cert,&cert_mtime)) {
                case 0: break;
                case 1: if (!edg_wll_gss_acquire_cred_gsi(server_cert,server_key,
@@ -354,8 +351,8 @@ int newconn(int conn,struct timeval *to,void *data)
        }
 
        /* TODO: DNS paranoia etc. */
-
-       if (edg_wll_gss_accept(mycred,conn,to,plugin_ctx->connection,&gss_code)) {
+       memset(&connection, 0, sizeof(connection));
+       if (edg_wll_gss_accept(mycred,conn,to,&connection,&gss_code)) {
                char    *et;
 
                edg_wll_gss_get_error(&gss_code,"",&et);
@@ -366,7 +363,7 @@ int newconn(int conn,struct timeval *to,void *data)
                goto cleanup;
        }
 
-       maj_stat = gss_inquire_context(&min_stat,plugin_ctx->connection->context,
+       maj_stat = gss_inquire_context(&min_stat,connection.context,
                        &client_name, NULL, NULL, NULL, NULL, NULL, NULL);
 
        if (!GSS_ERROR(maj_stat))
@@ -387,6 +384,8 @@ int newconn(int conn,struct timeval *to,void *data)
        if (client_name != GSS_C_NO_NAME) gss_release_name(&min_stat, &client_name);
        if (token.value) gss_release_buffer(&min_stat, &token);
 
+       glite_gsplugin_init_context(&plugin_ctx);
+       glite_gsplugin_set_connection(plugin_ctx, &connection);
        soap_register_plugin_arg(soap,glite_gsplugin,plugin_ctx);
 
        return 0;
index cc4595e..3cf4d7c 100644 (file)
@@ -7,7 +7,6 @@
 #include "glite/jp/types.h"
 #include "glite/jp/context.h"
 #include "glite/security/glite_gsplugin.h"
-#include "glite/security/glite_gsplugin-int.h"
 #include "glite/security/glite_gscompat.h"
 
 #include "jp_H.h"
@@ -58,6 +57,7 @@ int MyFeedIndex(glite_jpis_context_t ctx, glite_jp_is_conf *conf, long int uniqu
        int                                     i, dest_index, status;
        struct soap                             *soap = soap_new();
        glite_gsplugin_Context                  plugin_ctx;
+       gss_cred_id_t                           cred;
        glite_jp_error_t err;
        char *src, *desc = NULL;
        // preventive very long timeout
@@ -67,8 +67,15 @@ int MyFeedIndex(glite_jpis_context_t ctx, glite_jp_is_conf *conf, long int uniqu
 
        glite_gsplugin_init_context(&plugin_ctx);
        glite_gsplugin_set_timeout(plugin_ctx, &to);
-       if (ctx->conf->server_key) plugin_ctx->key_filename = strdup(ctx->conf->server_key);
-       if (ctx->conf->server_cert) plugin_ctx->cert_filename = strdup(ctx->conf->server_cert);
+       if (edg_wll_gss_acquire_cred_gsi(ctx->conf->server_cert, ctx->conf->server_key, &cred, NULL, NULL) != 0) {
+
+               err.code = EINVAL;
+               err.desc = "can't set credentials";
+               asprintf(&src, "%s/%s():%d", __FILE__, __FUNCTION__, __LINE__);
+               fprintf(stderr, "%s\n", src);
+               goto err;
+       }
+       glite_gsplugin_set_credential(plugin_ctx, cred);
        
        soap_init(soap);
         soap_set_namespaces(soap, jp__namespaces);
index 49d87ad..552b888 100644 (file)
@@ -243,7 +243,7 @@ static int newconn(int conn,struct timeval *to,void *data)
        gss_name_t              client_name = GSS_C_NO_NAME;
        gss_buffer_desc         token = GSS_C_EMPTY_BUFFER;
        OM_uint32               maj_stat,min_stat;
-
+       edg_wll_GssConnection   connection;
 
        int     ret = 0;
 
@@ -254,9 +254,6 @@ static int newconn(int conn,struct timeval *to,void *data)
        soap_set_namespaces(soap,jpps__namespaces);
        soap->user = (void *) ctx; /* XXX: one instance per slave */
 
-       glite_gsplugin_init_context(&plugin_ctx);
-       plugin_ctx->connection = calloc(1,sizeof *plugin_ctx->connection);
-
        switch (edg_wll_gss_watch_creds(server_cert,&cert_mtime)) {
                case 0: break;
                case 1: if (!edg_wll_gss_acquire_cred_gsi(server_cert,server_key,
@@ -282,7 +279,7 @@ static int newconn(int conn,struct timeval *to,void *data)
 
        /* TODO: DNS paranoia etc. */
 
-       if (edg_wll_gss_accept(mycred,conn,to,plugin_ctx->connection,&gss_code)) {
+       if (edg_wll_gss_accept(mycred,conn,to,&connection,&gss_code)) {
                char    *et;
 
                edg_wll_gss_get_error(&gss_code,"",&et);
@@ -293,7 +290,7 @@ static int newconn(int conn,struct timeval *to,void *data)
                goto cleanup;
        }
 
-       maj_stat = gss_inquire_context(&min_stat,plugin_ctx->connection->context,
+       maj_stat = gss_inquire_context(&min_stat,connection.context,
                        &client_name, NULL, NULL, NULL, NULL, NULL, NULL);
 
        if (!GSS_ERROR(maj_stat))
@@ -314,7 +311,10 @@ static int newconn(int conn,struct timeval *to,void *data)
        if (client_name != GSS_C_NO_NAME) gss_release_name(&min_stat, &client_name);
        if (token.value) gss_release_buffer(&min_stat, &token);
 
+       glite_gsplugin_init_context(&plugin_ctx);
+       glite_gsplugin_set_connection(plugin_ctx, &connection);
        soap_register_plugin_arg(soap,glite_gsplugin,plugin_ctx);
+
        return 0;
 
 cleanup:
index 13c65c6..2444722 100644 (file)
@@ -39,11 +39,16 @@ extern char *server_key, *server_cert;      /* XXX */
 static int check_other_soap(glite_jp_context_t ctx)
 {
        glite_gsplugin_Context  plugin_ctx;
+       int                     ret = 0;
 
        if (!ctx->other_soap) {
                glite_gsplugin_init_context(&plugin_ctx);
-               if (server_key) plugin_ctx->key_filename = strdup(server_key);
-               if (server_cert) plugin_ctx->cert_filename = strdup(server_cert);
+               if (server_key || server_cert) {
+                       gss_cred_id_t cred;
+
+                       ret = edg_wll_gss_acquire_cred_gsi(server_cert, server_key, &cred, NULL, NULL);
+                       glite_gsplugin_set_credential(plugin_ctx, cred);
+               }
 
                ctx->other_soap = soap_new();
                soap_init(ctx->other_soap);
@@ -53,7 +58,7 @@ static int check_other_soap(glite_jp_context_t ctx)
                soap_register_plugin_arg(ctx->other_soap,glite_gsplugin,plugin_ctx);
                ctx->other_soap->user = ctx;
        }
-       return 0;
+       return ret;
 }
 
 static check_fault(glite_jp_context_t ctx,struct soap *soap,int ec)
@@ -118,6 +123,7 @@ static int glite_jpps_single_feed_wrapped(
        in.feedId = (char *) feed; /* XXX: const */
        in.feedDone = done;
        in.__sizejobAttributes = 1;
+#warning FIXME for valtri
        in.jobAttributes = &jrp;
 
        for (i=0; attrs[i].name; i++);
index 5f1b9f4..e5bf905 100644 (file)
@@ -76,7 +76,7 @@ static int jp_err(glite_jp_context_t ctx, int code, const char *desc, const char
        memset(&err,0,sizeof err); 
        err.code = code;
        err.source = fullsource;
-       err.desc = desc
+       err.desc = desc && desc[0] ? desc : "(error without description)";
 
        ret = glite_jp_stack_error(ctx,&err); 
        free(fullsource);
@@ -90,7 +90,7 @@ static int my_err(glite_jp_context_t ctx, const char *source, int line)
 }
 
 
-static int my_errstmt(glite_jp_db_stmt_t jpstmt, const char *source, int line) {       
+static int my_errstmt(glite_jp_db_stmt_t jpstmt, const char *source, int line) {
        return jp_err(jpstmt->ctx, EIO, mysql_stmt_error(jpstmt->stmt), source, line);
 }
 
@@ -116,6 +116,7 @@ static int my_isokstmt(glite_jp_db_stmt_t jpstmt, const char *source, int line,
                                (*retry)--;
                                return 0;
                        } else
+                               jp_err(jpstmt->ctx, EIO, "CR_SERVER_LOST", source, line);
                                return -1;
                        break;
                default:
index 8d1746c..867a0b6 100644 (file)
@@ -133,7 +133,7 @@ static void glite_jp_server_err2fault(const glite_jp_context_t ctx,struct soap *
        // no error in JP context?
        if (!item) return;
 
-       detail = soap_faultdetail(soap);
+       detail = (struct SOAP_ENV__Detail *)soap_faultdetail(soap);
 #if GSOAP_VERSION >= 20700
        detail->fault = (void *)f;
 #else
index 8fe13ae..69b253c 100644 (file)
@@ -198,7 +198,7 @@ static void usage(char *me)
 {
        fprintf(stderr,"usage: %s [option]\n"
                "\t-a, --address\t use this server address (may be faked for debugging)\n"
-               "\t-b, --transactions\t transactions switch\n"
+               "\t-b, --transactions\t transactions switch (0, 1)\n"
                "\t-k, --key\t private key file\n"
                "\t-c, --cert\t certificate file\n"
                "\t-C, --CAdir\t trusted certificates directory\n"
@@ -1017,8 +1017,8 @@ int bk_handle_ws_connection(int conn, struct timeval *timeout, void *data)
                soap_done(soap);
                goto err;
        }
-       gsplugin_ctx->connection = &cdata->ctx->connections->serverConnection->gss;
-       gsplugin_ctx->cred = mycred;
+       glite_gsplugin_set_connection(gsplugin_ctx, &cdata->ctx->connections->serverConnection->gss);
+       glite_gsplugin_set_credential(gsplugin_ctx, mycred);
        cdata->soap = soap;
 
 
@@ -1247,8 +1247,8 @@ int bk_ws_clnt_disconnect(int conn, struct timeval *timeout, void *cdata)
 
 
        gsplugin_ctx = glite_gsplugin_get_context(soap);
-       gsplugin_ctx->cred = GSS_C_NO_CREDENTIAL;
-       gsplugin_ctx->connection = NULL;
+       glite_gsplugin_set_connection(gsplugin_ctx, NULL);
+       glite_gsplugin_set_credential(gsplugin_ctx, GSS_C_NO_CREDENTIAL);
        if ( (rv = bk_clnt_disconnect(conn, timeout, cdata)) )
                return rv;