Skip to content

Commit

Permalink
auth: Added %{auth_user/username/domain} variables
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed May 2, 2016
1 parent d12abd7 commit ce3f527
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/auth/auth-request-var-expand.c
Expand Up @@ -42,6 +42,9 @@ auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT+1] = {
{ '\0', NULL, "orig_user" },
{ '\0', NULL, "orig_username" },
{ '\0', NULL, "orig_domain" },
{ '\0', NULL, "auth_user" },
{ '\0', NULL, "auth_username" },
{ '\0', NULL, "auth_domain" },
/* be sure to update AUTH_REQUEST_VAR_TAB_COUNT */
{ '\0', NULL, NULL }
};
Expand All @@ -68,7 +71,7 @@ auth_request_get_var_expand_table_full(const struct auth_request *auth_request,
const unsigned int auth_count =
N_ELEMENTS(auth_request_var_expand_static_tab);
struct var_expand_table *tab, *ret_tab;
const char *orig_user;
const char *orig_user, *auth_user;

if (escape_func == NULL)
escape_func = escape_none;
Expand Down Expand Up @@ -154,6 +157,16 @@ auth_request_get_var_expand_table_full(const struct auth_request *auth_request,
tab[29].value = strchr(orig_user, '@');
if (tab[29].value != NULL)
tab[29].value = escape_func(tab[29].value+1, auth_request);

if (auth_request->master_user != NULL)
auth_user = auth_request->master_user;
else
auth_user = orig_user;
tab[30].value = escape_func(auth_user, auth_request);
tab[31].value = escape_func(t_strcut(auth_user, '@'), auth_request);
tab[32].value = strchr(auth_user, '@');
if (tab[32].value != NULL)
tab[32].value = escape_func(tab[32].value+1, auth_request);
return ret_tab;
}

Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth-request-var-expand.h
Expand Up @@ -8,7 +8,7 @@ auth_request_escape_func_t(const char *string,
#define AUTH_REQUEST_VAR_TAB_USER_IDX 0
#define AUTH_REQUEST_VAR_TAB_USERNAME_IDX 1
#define AUTH_REQUEST_VAR_TAB_DOMAIN_IDX 2
#define AUTH_REQUEST_VAR_TAB_COUNT 30
#define AUTH_REQUEST_VAR_TAB_COUNT 33
extern const struct var_expand_table
auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT+1];

Expand Down

0 comments on commit ce3f527

Please sign in to comment.