static int mod_authn_gssapi_create_krb5_ccache(server *srv, connection *con, plugin_data *p, krb5_context kcontext, krb5_principal princ, krb5_ccache *ccache) { buffer * const kccname = buffer_init_string("FILE:/tmp/krb5cc_gssapi_XXXXXX"); char * const ccname = kccname->ptr + sizeof("FILE:")-1; const size_t ccnamelen = buffer_string_length(kccname)-(sizeof("FILE:")-1); /*(future: might consider using server.upload-dirs instead of /tmp)*/ /* coverity[secure_temp : FALSE] */ int fd = mkstemp(ccname); if (fd < 0) { log_error_write(srv, __FILE__, __LINE__, "ss", "mkstemp():", strerror(errno)); buffer_free(kccname); return -1; } close(fd); do { krb5_error_code problem; problem = krb5_cc_resolve(kcontext, kccname->ptr, ccache); if (problem) { mod_authn_gssapi_log_krb5_error(srv, __FILE__, __LINE__, "krb5_cc_resolve", NULL, kcontext, problem); break; } problem = krb5_cc_initialize(kcontext, *ccache, princ); if (problem) { mod_authn_gssapi_log_krb5_error(srv, __FILE__, __LINE__, "krb5_cc_initialize", kccname->ptr, kcontext, problem); break; } con->plugin_ctx[p->id] = kccname; array_set_key_value(con->environment, CONST_STR_LEN("KRB5CCNAME"), ccname, ccnamelen); array_set_key_value(con->request.headers, CONST_STR_LEN("X-Forwarded-Keytab"), ccname, ccnamelen); return 0; } while (0); if (*ccache) { krb5_cc_destroy(kcontext, *ccache); *ccache = NULL; } unlink(ccname); buffer_free(kccname); return -1; }
static int magnet_cgi_set(lua_State *L) { connection *con = magnet_get_connection(L); /* __newindex: param 1 is the (empty) table the value is supposed to be set in */ const_buffer key = magnet_checkconstbuffer(L, 2); const_buffer val = magnet_checkconstbuffer(L, 2); array_set_key_value(con->environment, key.ptr, key.len, val.ptr, val.len); return 0; }
static void mod_deflate_note_ratio(server *srv, connection *con, handler_ctx *hctx) { /* store compression ratio in con->environment * for possible logging by mod_accesslog * (late in response handling, so not seen by most other modules) */ /*(should be called only at end of successful response compression)*/ char ratio[LI_ITOSTRING_LENGTH]; if (0 == hctx->bytes_in) return; li_itostrn(ratio, sizeof(ratio), hctx->bytes_out * 100 / hctx->bytes_in); array_set_key_value(con->environment, CONST_STR_LEN("ratio"), ratio, strlen(ratio)); UNUSED(srv); }
static int magnet_cgi_set(lua_State *L) { connection *con; const char *key = luaL_checkstring(L, 2); const char *val = luaL_checkstring(L, 3); lua_pushstring(L, "lighty.con"); lua_gettable(L, LUA_REGISTRYINDEX); con = lua_touserdata(L, -1); lua_pop(L, 1); array_set_key_value(con->environment, key, strlen(key), val, strlen(val)); return 0; }