static int
imap_urlauth_backend_trans_set_mailbox_key(struct mailbox *box,
unsigned char mailbox_key_r[IMAP_URLAUTH_KEY_LEN],
- const char **error_r,
+ const char **client_error_r,
enum mail_error *error_code_r)
{
struct mail_attribute_value urlauth_key;
int ret;
if (mailbox_open(box) < 0) {
- *error_r = mailbox_get_last_error(box, error_code_r);
+ *client_error_r = mailbox_get_last_error(box, error_code_r);
return -1;
}
IMAP_URLAUTH_KEY, &urlauth_key);
if (mailbox_transaction_commit(&t) < 0) {
- *error_r = mailbox_get_last_error(box, error_code_r);
+ *client_error_r = mailbox_get_last_error(box, error_code_r);
ret = -1;
}
imap_urlauth_backend_trans_get_mailbox_key(struct mailbox *box,
bool create,
unsigned char mailbox_key_r[IMAP_URLAUTH_KEY_LEN],
- const char **error_r,
+ const char **client_error_r,
enum mail_error *error_code_r)
{
struct mail_user *user = mail_storage_get_user(mailbox_get_storage(box));
buffer_t key_buf;
int ret;
- *error_r = "Internal server error";
+ *client_error_r = "Internal server error";
*error_code_r = MAIL_ERROR_TEMP;
ret = mailbox_attribute_get(box, MAIL_ATTRIBUTE_TYPE_PRIVATE,
ret = imap_urlauth_backend_trans_set_mailbox_key(box,
mailbox_key_r,
- error_r,
+ client_error_r,
error_code_r);
if (ret < 0)
int imap_urlauth_backend_get_mailbox_key(struct mailbox *box, bool create,
unsigned char mailbox_key_r[IMAP_URLAUTH_KEY_LEN],
- const char **error_r,
+ const char **client_error_r,
enum mail_error *error_code_r)
{
int ret;
- ret = imap_urlauth_backend_trans_get_mailbox_key(box, create, mailbox_key_r, error_r, error_code_r);
+ ret = imap_urlauth_backend_trans_get_mailbox_key(box, create,
+ mailbox_key_r,
+ client_error_r,
+ error_code_r);
return ret;
}
static bool
imap_urlauth_check_hostport(struct imap_urlauth_context *uctx,
- struct imap_url *url, const char **error_r)
+ struct imap_url *url, const char **client_error_r)
{
/* validate host */
/* FIXME: allow host ip/ip6 as well? */
if (strcmp(uctx->url_host, URL_HOST_ALLOW_ANY) != 0 &&
strcmp(url->host.name, uctx->url_host) != 0) {
- *error_r = "Invalid URL: Inappropriate host name";
+ *client_error_r = "Invalid URL: Inappropriate host name";
return FALSE;
}
/* validate port */
if ((url->port == 0 && uctx->url_port != 143) ||
(url->port != 0 && uctx->url_port != url->port)) {
- *error_r = "Invalid URL: Inappropriate server port";
+ *client_error_r = "Invalid URL: Inappropriate server port";
return FALSE;
}
return TRUE;
int imap_urlauth_generate(struct imap_urlauth_context *uctx,
const char *mechanism, const char *rumpurl,
- const char **urlauth_r, const char **error_r)
+ const char **urlauth_r, const char **client_error_r)
{
struct mail_user *user = uctx->user;
enum imap_url_parse_flags url_flags =
/* validate mechanism */
if (strcasecmp(mechanism, "INTERNAL") != 0) {
- *error_r = t_strdup_printf("Unsupported URLAUTH mechanism: %s", mechanism);
+ *client_error_r = t_strdup_printf("Unsupported URLAUTH mechanism: %s", mechanism);
return 0;
}
/* validate URL */
if (imap_url_parse(rumpurl, NULL, url_flags, &url, &error) < 0) {
- *error_r = t_strdup_printf("Invalid URL: %s", error);
+ *client_error_r = t_strdup_printf("Invalid URL: %s", error);
return 0;
}
if (url->mailbox == NULL || url->uid == 0 || url->search_program != NULL ||
url->uauth_rumpurl == NULL || url->uauth_mechanism != NULL) {
- *error_r = "Invalid URL: Must be an URLAUTH rump URL";
+ *client_error_r = "Invalid URL: Must be an URLAUTH rump URL";
return 0;
}
time_t now = time(NULL);
if (now > url->uauth_expire) {
- *error_r = t_strdup_printf("URLAUTH has already expired");
+ *client_error_r = t_strdup_printf("URLAUTH has already expired");
return 0;
}
}
/* validate user */
if (url->userid == NULL) {
- *error_r = "Invalid URL: Missing user name";
+ *client_error_r = "Invalid URL: Missing user name";
return 0;
}
if (user->anonymous || strcmp(url->userid, user->username) != 0) {
- *error_r = t_strdup_printf(
+ *client_error_r = t_strdup_printf(
"Not permitted to generate URLAUTH for user %s",
url->userid);
return 0;
}
/* validate host:port */
- if (!imap_urlauth_check_hostport(uctx, url, error_r))
+ if (!imap_urlauth_check_hostport(uctx, url, client_error_r))
return 0;
/* validate mailbox */
if ((ret = imap_msgpart_url_create(user, url, &mpurl, &error)) < 0 ||
imap_msgpart_url_verify(mpurl, &error) <= 0) {
- *error_r = t_strdup_printf("Invalid URL: %s", error);
+ *client_error_r = t_strdup_printf("Invalid URL: %s", error);
if (mpurl != NULL)
imap_msgpart_url_free(&mpurl);
return ret;
/* obtain mailbox key */
ret = imap_urlauth_backend_get_mailbox_key(box, TRUE, mailbox_key,
- error_r, &error_code);
+ client_error_r, &error_code);
if (ret < 0) {
imap_msgpart_url_free(&mpurl);
return ret;