struct uwsgi_ldap_entry *search_ldap_cache(struct uwsgi_ldap_entry *root, char *name, int count) { int i; struct uwsgi_ldap_entry *ule; for (i = 0; i < count; i++) { ule = &root[i]; if (uwsgi_list_has_str(ule->names, name + 1)) { return ule; } } return NULL; }
void add_exported_option(char *key, char *value, int configured) { struct uwsgi_string_list *blacklist = uwsgi.blacklist; struct uwsgi_string_list *whitelist = uwsgi.whitelist; while (blacklist) { if (!strcmp(key, blacklist->value)) { uwsgi_log("uWSGI error: forbidden option \"%s\" (by blacklist)\n", key); exit(1); } blacklist = blacklist->next; } if (whitelist) { int allowed = 0; while (whitelist) { if (!strcmp(key, whitelist->value)) { allowed = 1; break; } whitelist = whitelist->next; } if (!allowed) { uwsgi_log("uWSGI error: forbidden option \"%s\" (by whitelist)\n", key); exit(1); } } if (uwsgi.blacklist_context) { if (uwsgi_list_has_str(uwsgi.blacklist_context, key)) { uwsgi_log("uWSGI error: forbidden option \"%s\" (by blacklist)\n", key); exit(1); } } if (uwsgi.whitelist_context) { if (!uwsgi_list_has_str(uwsgi.whitelist_context, key)) { uwsgi_log("uWSGI error: forbidden option \"%s\" (by whitelist)\n", key); exit(1); } } if (uwsgi.logic_opt_running) goto add; if (!strcmp(key, "end") || !strcmp(key, "endfor") || !strcmp(key, "endif")) { if (uwsgi.logic_opt_data) { free(uwsgi.logic_opt_data); } uwsgi.logic_opt = NULL; uwsgi.logic_opt_arg = NULL; uwsgi.logic_opt_cycles = 0; uwsgi.logic_opt_data = NULL; } if (uwsgi.logic_opt) { if (uwsgi.logic_opt_data) { free(uwsgi.logic_opt_data); } uwsgi.logic_opt_data = uwsgi_str(uwsgi.logic_opt_arg); uwsgi.logic_opt_cycles++; uwsgi.logic_opt_running = 1; uwsgi.logic_opt(key, value); uwsgi.logic_opt_running = 0; return; } add: if (!uwsgi.exported_opts) { uwsgi.exported_opts = uwsgi_malloc(sizeof(struct uwsgi_opt *)); } else { uwsgi.exported_opts = realloc(uwsgi.exported_opts, sizeof(struct uwsgi_opt *) * (uwsgi.exported_opts_cnt + 1)); if (!uwsgi.exported_opts) { uwsgi_error("realloc()"); exit(1); } } int id = uwsgi.exported_opts_cnt; uwsgi.exported_opts[id] = uwsgi_malloc(sizeof(struct uwsgi_opt)); uwsgi.exported_opts[id]->key = key; uwsgi.exported_opts[id]->value = value; uwsgi.exported_opts[id]->configured = configured; uwsgi.exported_opts_cnt++; uwsgi.dirty_config = 1; struct uwsgi_option *op = uwsgi_opt_get(key); if (op) { // requires master ? if (op->flags & UWSGI_OPT_MASTER) { uwsgi.master_process = 1; } // requires log_master ? if (op->flags & UWSGI_OPT_LOG_MASTER) { uwsgi.master_process = 1; uwsgi.log_master = 1; } if (op->flags & UWSGI_OPT_REQ_LOG_MASTER) { uwsgi.master_process = 1; uwsgi.log_master = 1; uwsgi.req_log_master = 1; } // requires threads ? if (op->flags & UWSGI_OPT_THREADS) { uwsgi.has_threads = 1; } // requires cheaper mode ? if (op->flags & UWSGI_OPT_CHEAPER) { uwsgi.cheaper = 1; } // requires virtualhosting ? if (op->flags & UWSGI_OPT_VHOST) { uwsgi.vhost = 1; } // requires memusage ? if (op->flags & UWSGI_OPT_MEMORY) { uwsgi.force_get_memusage = 1; } // requires auto procname ? if (op->flags & UWSGI_OPT_PROCNAME) { uwsgi.auto_procname = 1; } // requires lazy ? if (op->flags & UWSGI_OPT_LAZY) { uwsgi.lazy = 1; } // requires no_initial ? if (op->flags & UWSGI_OPT_NO_INITIAL) { uwsgi.no_initial_output = 1; } // requires no_server ? if (op->flags & UWSGI_OPT_NO_SERVER) { uwsgi.no_server = 1; } // requires post_buffering ? if (op->flags & UWSGI_OPT_POST_BUFFERING) { if (!uwsgi.post_buffering) uwsgi.post_buffering = 4096; } // requires building mime dict ? if (op->flags & UWSGI_OPT_MIME) { uwsgi.build_mime_dict = 1; } // immediate ? if (op->flags & UWSGI_OPT_IMMEDIATE) { op->func(key, value, op->data); uwsgi.exported_opts[id]->configured = 1; } } }