Lines 66-74
typedef struct {
Link Here
|
66 |
const char *file_name; |
66 |
const char *file_name; |
67 |
const char *function_name; |
67 |
const char *function_name; |
68 |
ap_lua_vm_spec *spec; |
68 |
ap_lua_vm_spec *spec; |
69 |
apr_array_header_t *args; |
|
|
70 |
} lua_authz_provider_spec; |
69 |
} lua_authz_provider_spec; |
71 |
|
70 |
|
|
|
71 |
typedef struct { |
72 |
lua_authz_provider_spec *spec; |
73 |
apr_array_header_t *args; |
74 |
} lua_authz_provider_func; |
75 |
|
72 |
apr_hash_t *lua_authz_providers; |
76 |
apr_hash_t *lua_authz_providers; |
73 |
|
77 |
|
74 |
typedef struct |
78 |
typedef struct |
Lines 1692-1697
static const char *lua_authz_parse(cmd_parms *cmd, const char *require_line,
Link Here
|
1692 |
{ |
1696 |
{ |
1693 |
const char *provider_name; |
1697 |
const char *provider_name; |
1694 |
lua_authz_provider_spec *spec; |
1698 |
lua_authz_provider_spec *spec; |
|
|
1699 |
lua_authz_provider_func *func = apr_pcalloc(cmd->pool, sizeof(lua_authz_provider_func)); |
1695 |
|
1700 |
|
1696 |
apr_pool_userdata_get((void**)&provider_name, AUTHZ_PROVIDER_NAME_NOTE, |
1701 |
apr_pool_userdata_get((void**)&provider_name, AUTHZ_PROVIDER_NAME_NOTE, |
1697 |
cmd->temp_pool); |
1702 |
cmd->temp_pool); |
Lines 1699-1714
static const char *lua_authz_parse(cmd_parms *cmd, const char *require_line,
Link Here
|
1699 |
|
1704 |
|
1700 |
spec = apr_hash_get(lua_authz_providers, provider_name, APR_HASH_KEY_STRING); |
1705 |
spec = apr_hash_get(lua_authz_providers, provider_name, APR_HASH_KEY_STRING); |
1701 |
ap_assert(spec != NULL); |
1706 |
ap_assert(spec != NULL); |
|
|
1707 |
func->spec = spec; |
1702 |
|
1708 |
|
1703 |
if (require_line && *require_line) { |
1709 |
if (require_line && *require_line) { |
1704 |
const char *arg; |
1710 |
const char *arg; |
1705 |
spec->args = apr_array_make(cmd->pool, 2, sizeof(const char *)); |
1711 |
func->args = apr_array_make(cmd->pool, 2, sizeof(const char *)); |
1706 |
while ((arg = ap_getword_conf(cmd->pool, &require_line)) && *arg) { |
1712 |
while ((arg = ap_getword_conf(cmd->pool, &require_line)) && *arg) { |
1707 |
APR_ARRAY_PUSH(spec->args, const char *) = arg; |
1713 |
APR_ARRAY_PUSH(func->args, const char *) = arg; |
1708 |
} |
1714 |
} |
1709 |
} |
1715 |
} |
1710 |
|
1716 |
|
1711 |
*parsed_require_line = spec; |
1717 |
*parsed_require_line = func; |
1712 |
return NULL; |
1718 |
return NULL; |
1713 |
} |
1719 |
} |
1714 |
|
1720 |
|
Lines 1722-1728
static authz_status lua_authz_check(request_rec *r, const char *require_line,
Link Here
|
1722 |
&lua_module); |
1728 |
&lua_module); |
1723 |
const ap_lua_dir_cfg *cfg = ap_get_module_config(r->per_dir_config, |
1729 |
const ap_lua_dir_cfg *cfg = ap_get_module_config(r->per_dir_config, |
1724 |
&lua_module); |
1730 |
&lua_module); |
1725 |
const lua_authz_provider_spec *prov_spec = parsed_require_line; |
1731 |
const lua_authz_provider_func *prov_func = parsed_require_line; |
|
|
1732 |
const lua_authz_provider_spec *prov_spec = prov_func->spec; |
1726 |
int result; |
1733 |
int result; |
1727 |
int nargs = 0; |
1734 |
int nargs = 0; |
1728 |
|
1735 |
|
Lines 1744-1762
static authz_status lua_authz_check(request_rec *r, const char *require_line,
Link Here
|
1744 |
return AUTHZ_GENERAL_ERROR; |
1751 |
return AUTHZ_GENERAL_ERROR; |
1745 |
} |
1752 |
} |
1746 |
ap_lua_run_lua_request(L, r); |
1753 |
ap_lua_run_lua_request(L, r); |
1747 |
if (prov_spec->args) { |
1754 |
if (prov_func->args) { |
1748 |
int i; |
1755 |
int i; |
1749 |
if (!lua_checkstack(L, prov_spec->args->nelts)) { |
1756 |
if (!lua_checkstack(L, prov_func->args->nelts)) { |
1750 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02315) |
1757 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02315) |
1751 |
"Error: authz provider %s: too many arguments", prov_spec->name); |
1758 |
"Error: authz provider %s: too many arguments", prov_spec->name); |
1752 |
ap_lua_release_state(L, spec, r); |
1759 |
ap_lua_release_state(L, spec, r); |
1753 |
return AUTHZ_GENERAL_ERROR; |
1760 |
return AUTHZ_GENERAL_ERROR; |
1754 |
} |
1761 |
} |
1755 |
for (i = 0; i < prov_spec->args->nelts; i++) { |
1762 |
for (i = 0; i < prov_func->args->nelts; i++) { |
1756 |
const char *arg = APR_ARRAY_IDX(prov_spec->args, i, const char *); |
1763 |
const char *arg = APR_ARRAY_IDX(prov_func->args, i, const char *); |
1757 |
lua_pushstring(L, arg); |
1764 |
lua_pushstring(L, arg); |
1758 |
} |
1765 |
} |
1759 |
nargs = prov_spec->args->nelts; |
1766 |
nargs = prov_func->args->nelts; |
1760 |
} |
1767 |
} |
1761 |
if (lua_pcall(L, 1 + nargs, 1, 0)) { |
1768 |
if (lua_pcall(L, 1 + nargs, 1, 0)) { |
1762 |
const char *err = lua_tostring(L, -1); |
1769 |
const char *err = lua_tostring(L, -1); |