krb5_error_code krb5_ldap_db_init(krb5_context context, krb5_ldap_context *ctx) { krb5_error_code ret; int i, version = LDAP_VERSION3; unsigned int conns; krb5_ldap_server_info *info; struct timeval local_timelimit = { 10, 0 }; ret = validate_context(context, ctx); if (ret) return ret; #ifdef LDAP_OPT_DEBUG_LEVEL ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &ctx->ldap_debug); #endif ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &version); #ifdef LDAP_OPT_NETWORK_TIMEOUT ldap_set_option(NULL, LDAP_OPT_NETWORK_TIMEOUT, &local_timelimit); #elif defined LDAP_X_OPT_CONNECT_TIMEOUT ldap_set_option(NULL, LDAP_X_OPT_CONNECT_TIMEOUT, &local_timelimit); #endif HNDL_LOCK(ctx); for (i = 0; ctx->server_info_list[i] != NULL; i++) { info = ctx->server_info_list[i]; if (info->server_status == NOTSET) { krb5_clear_error_message(context); #ifdef LDAP_MOD_INCREMENT info->modify_increment = has_modify_increment(context, info->server_name); #else info->modify_increment = 0; #endif for (conns = 0; conns < ctx->max_server_conns; conns++) { ret = initialize_server(ctx, info); if (ret) break; } /* If we opened a connection, don't try any more servers. */ if (info->server_status == ON) break; } } HNDL_UNLOCK(ctx); return ret; }
/* one iteration of the central loop called repeatedly by mainloop() */ int eval(Xpost_Context *ctx) { int ret; Xpost_Object t = xpost_stack_topdown_fetch(ctx->lo, ctx->es, 0); ctx->currentobject = t; /* for _onerror to determine if hold stack contents are restoreable. if opexec(opcode) discovers opcode != ctx->currentobject.mark_.padw it sets a flag indicating the hold stack does not contain ctx->currentobject's arguments. if an error is encountered, currentobject is reported as the errant object since it is the "entry point" to the interpreter. */ if (!validate_context(ctx)) return unregistered; if (_xpost_interpreter_is_tracing) { XPOST_LOG_DUMP("eval(): Executing: "); xpost_object_dump(t); XPOST_LOG_DUMP("Stack: "); xpost_stack_dump(ctx->lo, ctx->os); XPOST_LOG_DUMP("Dict Stack: "); xpost_stack_dump(ctx->lo, ctx->ds); XPOST_LOG_DUMP("Exec Stack: "); xpost_stack_dump(ctx->lo, ctx->es); } ret = idleproc(ctx); /* periodically process asynchronous events */ if (ret) return ret; { /* check object for sanity before using jump table */ Xpost_Object_Type type = xpost_object_get_type(t); if (type == invalidtype || type >= XPOST_OBJECT_NTYPES) return unregistered; } if ( xpost_object_is_exe(t) ) /* if executable */ ret = evaltype[xpost_object_get_type(t)](ctx); else ret = evalpush(ctx); return ret; }
/* called by mainloop() after propagated error codes. pushes postscript-level error procedures and resumes normal execution. */ static void _onerror(Xpost_Context *ctx, unsigned int err) { Xpost_Object sd; Xpost_Object ed; Xpost_Object dollarerror; if (err > unknownerror) err = unknownerror; if (!validate_context(ctx)) XPOST_LOG_ERR("context not valid"); if (itpdata->in_onerror > 5) { fprintf(stderr, "LOOP in error handler\nabort\n"); ++ctx->quit; /*exit(undefinedresult); */ } ++itpdata->in_onerror; #ifdef EMITONERROR fprintf(stderr, "err: %s\n", errorname[err]); #endif /* reset stack */ if ((xpost_object_get_type(ctx->currentobject) == operatortype) && (ctx->currentobject.tag & XPOST_OBJECT_TAG_DATA_FLAG_OPARGSINHOLD)) { int n = ctx->currentobject.mark_.pad0; int i; for (i = 0; i < n; i++) { xpost_stack_push(ctx->lo, ctx->os, xpost_stack_bottomup_fetch(ctx->lo, ctx->hold, i)); } } /* printf("1\n"); */ sd = xpost_stack_bottomup_fetch(ctx->lo, ctx->ds, 0); /* printf("2\n"); */ dollarerror = xpost_dict_get(ctx, sd, namedollarerror); if (xpost_object_get_type(dollarerror) == invalidtype) { XPOST_LOG_ERR("cannot load $error dict for error: %s", errorname[err]); xpost_stack_push(ctx->lo, ctx->es, xpost_object_cvx(xpost_name_cons(ctx, "stop"))); /*itpdata->in_onerror = 0; */ return; } /* printf("3\n"); */ /* printf("4\n"); */ /* printf("5\n"); */ xpost_stack_push(ctx->lo, ctx->os, ctx->currentobject); #if 0 /* printf("6\n"); */ xpost_stack_push(ctx->lo, ctx->os, xpost_object_cvlit(xpost_name_cons(ctx, errorname[err]))); /* printf("7\n"); */ xpost_stack_push(ctx->lo, ctx->es, xpost_object_cvx(xpost_name_cons(ctx, "signalerror"))); #endif ed = xpost_dict_get(ctx, sd, nameerrordict); xpost_stack_push(ctx->lo, ctx->es, xpost_dict_get(ctx, ed, xpost_name_cons(ctx, errorname[err]))); /* printf("8\n"); */ itpdata->in_onerror = 0; }