/* max. size for auth_client_request_continue.data[] */
#define AUTH_CLIENT_MAX_REQUEST_DATA_SIZE 4096
+/* sizeof(struct auth_client_request_new->protocol) */
+#define AUTH_CLIENT_PROTOCOL_BUF_SIZE 12
+
/* Client process must finish with single authentication requests in this time,
or the whole connection will be killed. */
#define AUTH_REQUEST_TIMEOUT 120
AUTH_MECH_COUNT
};
-enum auth_protocol {
- AUTH_PROTOCOL_IMAP = 0x01,
- AUTH_PROTOCOL_POP3 = 0x02
-};
-
enum auth_client_request_new_flags {
AUTH_CLIENT_FLAG_SSL_VALID_CLIENT_CERT = 0x01
};
unsigned int id; /* unique ID for the request */
enum auth_mech mech;
- enum auth_protocol protocol;
- enum auth_client_request_new_flags flags;
+ enum auth_client_request_new_flags flags;
+ char protocol[AUTH_CLIENT_PROTOCOL_BUF_SIZE];
};
/* Continue authentication request */
auth_request->created = ioloop_time;
auth_request->conn = conn;
auth_request->id = request->id;
- auth_request->protocol = request->protocol;
+ strocpy(auth_request->protocol, request->protocol,
+ sizeof(auth_request->protocol));
hash_insert(conn->auth_requests, POINTER_CAST(request->id),
auth_request);
tab[2].value = strchr(auth_request->user, '@');
if (tab[2].value != NULL)
tab[2].value = escape_func(tab[2].value+1);
-
- switch (auth_request->protocol) {
- case AUTH_PROTOCOL_IMAP:
- tab[3].value = "IMAP";
- break;
- case AUTH_PROTOCOL_POP3:
- tab[3].value = "POP3";
- break;
- }
-
+ tab[3].value = auth_request->protocol;
return tab;
}
unsigned int id;
time_t created;
- enum auth_protocol protocol;
+ char protocol[AUTH_CLIENT_PROTOCOL_BUF_SIZE];
mech_callback_t *callback;
int (*auth_continue)(struct auth_request *auth_request,
int fd[2];
pid_t pid;
- service = service_name != NULL ? service_name :
- request->protocol == AUTH_PROTOCOL_IMAP ? "imap" :
- request->protocol == AUTH_PROTOCOL_POP3 ? "pop3" : NULL;
- if (service == NULL) {
- i_error("Unknown protocol %d in auth request",
- request->protocol);
- }
-
+ service = service_name != NULL ? service_name : request->protocol;
if (pipe(fd) < 0) {
i_error("PAM: pipe() failed: %m");
callback(PASSDB_RESULT_INTERNAL_FAILURE, request);
}
if (((vpw->pw_gid & NO_IMAP) != 0 &&
- request->protocol == AUTH_PROTOCOL_IMAP) ||
+ strcmp(request->protocol, "IMAP") == 0) ||
((vpw->pw_gid & NO_POP) != 0 &&
- request->protocol == AUTH_PROTOCOL_POP3)) {
+ strcmp(request->protocol, "POP3") == 0)) {
if (verbose) {
i_info("vpopmail(%s@%s): %s disabled",
- vpop_user, vpop_domain,
- request->protocol == AUTH_PROTOCOL_IMAP ?
- "IMAP" : "POP3");
+ vpop_user, vpop_domain, request->protocol);
}
callback(PASSDB_RESULT_USER_DISABLED, request);
return;
client_ref(client);
client->common.auth_request =
- auth_client_request_new(auth_client, AUTH_MECH_PLAIN,
- AUTH_PROTOCOL_IMAP,
+ auth_client_request_new(auth_client, AUTH_MECH_PLAIN, "IMAP",
client_get_auth_flags(client),
login_callback, client, &error);
if (client->common.auth_request == NULL) {
client_ref(client);
client->common.auth_request =
- auth_client_request_new(auth_client, mech->mech,
- AUTH_PROTOCOL_IMAP,
+ auth_client_request_new(auth_client, mech->mech, "IMAP",
client_get_auth_flags(client),
authenticate_callback,
client, &error);
happens for the request. */
struct auth_request *
auth_client_request_new(struct auth_client *client,
- enum auth_mech mech, enum auth_protocol protocol,
+ enum auth_mech mech, const char *protocol,
enum auth_client_request_new_flags flags,
auth_request_callback_t *callback, void *context,
const char **error_r);
struct auth_server_connection *conn;
enum auth_mech mech;
- enum auth_protocol protocol;
+ char protocol[AUTH_CLIENT_PROTOCOL_BUF_SIZE];
enum auth_client_request_new_flags flags;
unsigned int id;
auth_request.type = AUTH_CLIENT_REQUEST_NEW;
auth_request.id = request->id;
- auth_request.protocol = request->protocol;
+ strocpy(auth_request.protocol, request->protocol,
+ sizeof(auth_request.protocol));
auth_request.mech = request->mech;
auth_request.flags = request->flags;
struct auth_request *
auth_client_request_new(struct auth_client *client,
- enum auth_mech mech, enum auth_protocol protocol,
+ enum auth_mech mech, const char *protocol,
enum auth_client_request_new_flags flags,
auth_request_callback_t *callback, void *context,
const char **error_r)
request = i_new(struct auth_request, 1);
request->conn = conn;
request->mech = mech;
- request->protocol = protocol;
+ strocpy(request->protocol, protocol, sizeof(request->protocol));
request->flags = flags;
request->id = ++client->request_id_counter;
if (request->id == 0) {
client_ref(client);
client->common.auth_request =
- auth_client_request_new(auth_client, AUTH_MECH_PLAIN,
- AUTH_PROTOCOL_POP3,
+ auth_client_request_new(auth_client, AUTH_MECH_PLAIN, "POP3",
client_get_auth_flags(client),
login_callback, client, &error);
if (client->common.auth_request != NULL) {
client_ref(client);
client->common.auth_request =
- auth_client_request_new(auth_client, mech->mech,
- AUTH_PROTOCOL_POP3,
+ auth_client_request_new(auth_client, mech->mech, "POP3",
client_get_auth_flags(client),
authenticate_callback, client, &error);
if (client->common.auth_request != NULL) {