static int uwsgi_sqlite3_config_callback(void *magic_table, int field_count, char **fields, char **col) { // make a copy of the string if (field_count >= 2) { size_t value_len = strlen(fields[1]) + 1; char *value = magic_sub(fields[1], value_len, &value_len, (char **) magic_table); add_exported_option(uwsgi_strncopy(fields[0], strlen(fields[0])), value, 0); } return 0; }
/* this is the dynamic loader, it loads app reading information from a wsgi_request */ PyObject *uwsgi_dyn_loader(void *arg1) { PyObject *callable = NULL; char *tmpstr; struct wsgi_request *wsgi_req = (struct wsgi_request *) arg1; // MANAGE UWSGI_SCRIPT if (wsgi_req->script_len > 0) { tmpstr = uwsgi_strncopy(wsgi_req->script, wsgi_req->script_len); callable = uwsgi_uwsgi_loader((void *)tmpstr); free(tmpstr); } // MANAGE UWSGI_MODULE else if (wsgi_req->module_len > 0) { if (wsgi_req->callable_len > 0) { tmpstr = uwsgi_concat3n(wsgi_req->module, wsgi_req->module_len, ":", 1, wsgi_req->callable, wsgi_req->callable_len); } else { tmpstr = uwsgi_strncopy(wsgi_req->module, wsgi_req->module_len); } callable = uwsgi_uwsgi_loader((void *)tmpstr); free(tmpstr); } // MANAGE UWSGI_FILE else if (wsgi_req->file_len > 0) { tmpstr = uwsgi_strncopy(wsgi_req->file, wsgi_req->file_len); callable = uwsgi_file_loader((void *)tmpstr); free(tmpstr); } // TODO MANAGE UWSGI_PASTE /* else if (wsgi_req->wsgi_paste_len > 0) { tmpstr = uwsgi_strncopy(wsgi_req->paste, wsgi_req->paste_len); callable = uwsgi_paste_loader((void *)tmpstr); free(tmpstr); } */ return callable; }
static int uwsgi_ssh_request(struct wsgi_request *wsgi_req) { #if !defined(UWSGI_PLUGIN_API) || UWSGI_PLUGIN_API == 1 if (!wsgi_req->uh->pktsize) #else if (!wsgi_req->len) #endif { uwsgi_log("[SSH] skipping empty request.\n"); return -1; } if (uwsgi_parse_vars(wsgi_req)) { uwsgi_error("uwsgi_ssh_request()/uwsgi_parse_vars()"); return -1; } if (wsgi_req->path_info_len == 0 || wsgi_req->path_info_len > PATH_MAX || wsgi_req->path_info[wsgi_req->path_info_len - 1] == '/') { uwsgi_403(wsgi_req); return UWSGI_OK; } wsgi_req->app_id = uwsgi_get_app_id(wsgi_req, wsgi_req->appid, wsgi_req->appid_len, libssh2_plugin.modifier1); if (wsgi_req->app_id == -1 && !uwsgi.no_default_app && uwsgi.default_app > -1) { if (uwsgi_apps[uwsgi.default_app].modifier1 == libssh2_plugin.modifier1) { wsgi_req->app_id = uwsgi.default_app; } } if (wsgi_req->app_id == -1) { uwsgi_404(wsgi_req); return UWSGI_OK; } struct uwsgi_app *ua = &uwsgi_apps[wsgi_req->app_id]; struct uwsgi_ssh_mountpoint *usm_list = (struct uwsgi_ssh_mountpoint *) ua->callable; char *complete_filepath = NULL; char *filepath = NULL; if (wsgi_req->path_info_len > ua->mountpoint_len && memcmp(wsgi_req->path_info, ua->mountpoint, ua->mountpoint_len) == 0) { filepath = uwsgi_strncopy( wsgi_req->path_info + ua->mountpoint_len, wsgi_req->path_info_len - ua->mountpoint_len ); } else { filepath = uwsgi_strncopy(wsgi_req->path_info, wsgi_req->path_info_len); } complete_filepath = uwsgi_concat2(usm_list->path, filepath); free(filepath); int return_status = 500; struct uwsgi_ssh_mountpoint *usm = usm_list; do { return_status = uwsgi_ssh_request_file( wsgi_req, complete_filepath, usm ); } while (return_status == 500 && ((usm = usm->next) != NULL)); free(complete_filepath); switch (return_status) { case 404: uwsgi_404(wsgi_req); break; case 500: default: uwsgi_500(wsgi_req); } return 0; }