prevent job_reg coredumping if no credentials found lb_transactions_only
authorMiloš Mulač <mulac@civ.zcu.cz>
Tue, 11 Mar 2008 12:31:43 +0000 (12:31 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Tue, 11 Mar 2008 12:31:43 +0000 (12:31 +0000)
- just hack, needs improving of edg_wll_gss_connect too

org.glite.lb.client/src/prod_proto.c
org.glite.lb.client/src/producer.c

index 00d102a..1a2a3f8 100644 (file)
@@ -646,7 +646,6 @@ int edg_wll_log_proxy_read(edg_wll_Context ctx, edg_wll_PlainConnection *conn)
 int edg_wll_log_direct_connect(edg_wll_Context ctx, edg_wll_GssConnection *conn) 
 {
        int     ret,answer;
-       char    *my_subject_name = NULL;
        edg_wll_GssStatus       gss_stat;
        edg_wll_GssCred cred = NULL;
        char    *host;
@@ -673,14 +672,13 @@ int edg_wll_log_direct_connect(edg_wll_Context ctx, edg_wll_GssConnection *conn)
                answer = edg_wll_SetErrorGss(ctx, "edg_wll_gss_acquire_cred_gsi(): failed to load GSI credentials", &gss_stat);
                goto edg_wll_log_direct_connect_end;
        }
-       my_subject_name = cred->name;
 #ifdef EDG_WLL_LOG_STUB
-       if (my_subject_name) {
+       if (cred && cred->name) {
 /* TODO: merge - shouldn't be probably ctx->p_user_lbproxy but some new parameter, eg. ctx->p_user
        related to the change in producer.c
 */
-               edg_wll_SetParamString(ctx, EDG_WLL_PARAM_LBPROXY_USER, my_subject_name);
-               fprintf(stderr,"edg_wll_log_direct_connect: using certificate: %s\n",my_subject_name);
+               edg_wll_SetParamString(ctx, EDG_WLL_PARAM_LBPROXY_USER, cred->name);
+               fprintf(stderr,"edg_wll_log_direct_connect: using certificate: %s\n", cred->name);
        } else {
                fprintf(stderr,"edg_wll_log_direct_connect: going on anonymously\n");
        }
index 48d571e..7b197fc 100644 (file)
@@ -635,20 +635,28 @@ int edg_wll_SetLoggingJob(
                edg_wll_GssStatus       gss_stat;
                edg_wll_GssCred cred = NULL;
 
-               /* acquire gss credentials */
-               err = edg_wll_gss_acquire_cred_gsi(
-                     ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_cert_filename,
-                     ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_key_filename,
-                     &cred, &gss_stat);
-               /* give up if unable to acquire prescribed credentials */
-               if (err && ctx->p_proxy_filename) {
-                       edg_wll_SetErrorGss(ctx, "failed to load GSI credentials", &gss_stat);
+               if (ctx->p_proxy_filename || (ctx->p_cert_filename && ctx->p_key_filename)) {
+                       /* acquire gss credentials */
+                       err = edg_wll_gss_acquire_cred_gsi(
+                             ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_cert_filename,
+                             ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_key_filename,
+                             &cred, &gss_stat);
+                       /* give up if unable to acquire prescribed credentials */
+                       if (err) {
+                               edg_wll_SetErrorGss(ctx, "failed to load GSI credentials", &gss_stat);
+                       } else {
+                               edg_wll_SetParamString(ctx, EDG_WLL_PARAM_LBPROXY_USER, cred->name);
+                       }
+                       if (cred != NULL)
+                               edg_wll_gss_release_cred(&cred, NULL);
+               }
+               else {
                        edg_wll_SetParamString(ctx, EDG_WLL_PARAM_LBPROXY_USER, EDG_WLL_LOG_USER_DEFAULT);
-               } else {
-                       edg_wll_SetParamString(ctx, EDG_WLL_PARAM_LBPROXY_USER, cred->name);
+
+                       // XXX: stop here - further changes need to be done in 
+                       //      edg_wll_gss_connect() to support annonymous connetion
+                       return edg_wll_SetError(ctx, ENOENT, "No credentials found.");
                }
-               if (cred != NULL)
-                       edg_wll_gss_release_cred(&cred, NULL);
        }
 
        return edg_wll_Error(ctx,NULL,NULL);
@@ -687,21 +695,29 @@ int edg_wll_SetLoggingJobProxy(
                edg_wll_GssStatus       gss_stat;
                edg_wll_GssCred cred = NULL;
 
-               /* acquire gss credentials */
-               err = edg_wll_gss_acquire_cred_gsi(
-                     ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_cert_filename,
-                     ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_key_filename,
-                     &cred, &gss_stat);
-               /* give up if unable to acquire prescribed credentials */
-               if (err && ctx->p_proxy_filename) {
-                       edg_wll_SetErrorGss(ctx, "failed to load GSI credentials", &gss_stat);
-                       edg_wll_SetParamString(ctx, EDG_WLL_PARAM_LBPROXY_USER, EDG_WLL_LOG_USER_DEFAULT);
-               } else {
-                       edg_wll_SetParamString(ctx, EDG_WLL_PARAM_LBPROXY_USER, cred->name);
+               if (ctx->p_proxy_filename || (ctx->p_cert_filename && ctx->p_key_filename)) {
+                       /* acquire gss credentials */
+                       err = edg_wll_gss_acquire_cred_gsi(
+                             ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_cert_filename,
+                             ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_key_filename,
+                             &cred, &gss_stat);
+                       /* give up if unable to acquire prescribed credentials */
+                       if (err && ctx->p_proxy_filename) {
+                               edg_wll_SetErrorGss(ctx, "failed to load GSI credentials", &gss_stat);
+                       } else {
+                               edg_wll_SetParamString(ctx, EDG_WLL_PARAM_LBPROXY_USER, cred->name);
+                       }
+
+                       if (cred != NULL)
+                               edg_wll_gss_release_cred(&cred, NULL);
                }
+               else {
+                       edg_wll_SetParamString(ctx, EDG_WLL_PARAM_LBPROXY_USER, EDG_WLL_LOG_USER_DEFAULT);
 
-               if (cred != NULL)
-                       edg_wll_gss_release_cred(&cred, NULL);
+                       // XXX: stop here - further changes need to be done in 
+                       //      edg_wll_gss_connect() to support annonymous connetion
+                       return edg_wll_SetError(ctx, ENOENT, "No credentials found.");
+               }
        }
 
        /* query LBProxyServer for sequence code if not user-suplied */