diff --git a/include/oauth2/apache.h b/include/oauth2/apache.h index 1850871..a9bf3c5 100644 --- a/include/oauth2/apache.h +++ b/include/oauth2/apache.h @@ -184,6 +184,20 @@ int oauth2_apache_post_config(apr_pool_t *pool, apr_pool_t *p1, apr_pool_t *p2, return func(srv_cfg->log, member, v1, v2, v3); \ } +#define OAUTH2_APACHE_CMD_ARGSV4(module, type, primitive, func, member) \ + static const char *apache_##module##_set_##primitive( \ + cmd_parms *cmd, void *m, int argc, char *const argv[]) \ + { \ + oauth2_apache_cfg_srv_t *srv_cfg = ap_get_module_config( \ + cmd->server->module_config, &module##_module); \ + type *cfg = (type *)m; \ + (void)cfg; \ + return func(srv_cfg->log, member, argc > 0 ? argv[0] : NULL, \ + argc > 1 ? argv[1] : NULL, \ + argc > 2 ? argv[2] : NULL, \ + argc > 3 ? argv[3] : NULL); \ + } + #define OAUTH2_APACHE_CMD_ARGS(module, nargs, cmd, member, desc) \ AP_INIT_TAKE##nargs(cmd, apache_##module##_set_##member, NULL, \ RSRC_CONF | ACCESS_CONF | OR_AUTHCFG, desc) diff --git a/include/oauth2/nginx.h b/include/oauth2/nginx.h index bd115f7..be53062 100644 --- a/include/oauth2/nginx.h +++ b/include/oauth2/nginx.h @@ -113,6 +113,31 @@ oauth2_mem_free(v1); \ OAUTH2_NGINX_CFG_FUNC_END(cf, rv) +#define OAUTH2_NGINX_CFG_FUNC_ARGS4(module, type, primitive, func, member) \ + OAUTH2_NGINX_CFG_FUNC_START(module, type, primitive) \ + char *v1 = cf->args->nelts > 1 \ + ? oauth2_strndup((const char *)value[1].data, \ + (size_t)value[1].len) \ + : NULL; \ + char *v2 = cf->args->nelts > 2 \ + ? oauth2_strndup((const char *)value[2].data, \ + (size_t)value[2].len) \ + : NULL; \ + char *v3 = cf->args->nelts > 3 \ + ? oauth2_strndup((const char *)value[3].data, \ + (size_t)value[3].len) \ + : NULL; \ + char *v4 = cf->args->nelts > 4 \ + ? oauth2_strndup((const char *)value[3].data, \ + (size_t)value[4].len) \ + : NULL; \ + rv = func(cfg->log, member, v1, v2, v3, v4); \ + oauth2_mem_free(v4); \ + oauth2_mem_free(v3); \ + oauth2_mem_free(v2); \ + oauth2_mem_free(v1); \ + OAUTH2_NGINX_CFG_FUNC_END(cf, rv) + // commands // clang-format off diff --git a/src/server/nginx.c b/src/server/nginx.c index bc7feb0..93f8bc5 100644 --- a/src/server/nginx.c +++ b/src/server/nginx.c @@ -110,10 +110,12 @@ static void _oauth2_nginx_port_copy(oauth2_nginx_request_context_t *ctx) sin6 = (struct sockaddr_in6 *)ctx->r->connection->local_sockaddr; port = ntohs(sin6->sin6_port); + break; #endif #if (NGX_HAVE_UNIX_DOMAIN) case AF_UNIX: port = 0; + break; #endif default: /* AF_INET */ sin = (struct sockaddr_in *)ctx->r->connection->local_sockaddr;