#include <sys/un.h>
typedef struct rlm_smsotp_t {
- char *socket;
- char *challenge;
- char *authtype;
+ char const *socket;
+ char const *challenge;
+ char const *authtype;
fr_connection_pool_t *pool;
} rlm_smsotp_t;
static const CONF_PARSER module_config[] = {
- { "socket", PW_TYPE_STRING_PTR,
- offsetof(rlm_smsotp_t, socket),
- NULL, "/var/run/smsotp_socket" },
- { "challenge_message", PW_TYPE_STRING_PTR,
- offsetof(rlm_smsotp_t, challenge), NULL, "Enter Mobile PIN" },
- { "challenge_type", PW_TYPE_STRING_PTR,
- offsetof(rlm_smsotp_t, authtype),
- NULL, "smsotp-reply" },
+ { "socket", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_smsotp_t, socket), "/var/run/smsotp_socket" },
+ { "challenge_message", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_smsotp_t, challenge), "Enter Mobile PIN" },
+ { "challenge_type", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_smsotp_t, authtype), "smsotp-reply" },
{ NULL, -1, 0, NULL, NULL } /* end the list */
};
+static int _mod_conn_free(int *fdp)
+{
+ close(*fdp);
+ return 0;
+}
-static void *mod_conn_create(void *instance)
+static void *mod_conn_create(TALLOC_CTX *ctx, void *instance)
{
int fd;
struct sockaddr_un sa;
return NULL;
}
- fdp = talloc_zero(instance, int);
+ fdp = talloc_zero(ctx, int);
+ talloc_set_destructor(fdp, _mod_conn_free);
*fdp = fd;
return fdp;
}
-static int mod_conn_delete(UNUSED void *instance, void *handle)
-{
- int *fdp = handle;
-
- close(*fdp);
- talloc_free(fdp);
- return 0;
-}
-
-
/*
* Full read with logging, and close on failure.
* Returns nread on success, 0 on EOF, -1 on other failures.
/*
* Initialize the socket pool.
*/
- inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, mod_conn_delete, NULL);
+ inst->pool = fr_connection_pool_init(conf, inst, mod_conn_create, NULL, NULL, NULL);
if (!inst->pool) {
return -1;
}
/*
* Authenticate the user with the given password.
*/
-static rlm_rcode_t mod_authenticate(void *instance, REQUEST *request)
+static rlm_rcode_t CC_HINT(nonnull) mod_authenticate(void *instance, REQUEST *request)
{
rlm_smsotp_t *inst = instance;
VALUE_PAIR *state;
char output[1000];
fdp = fr_connection_get(inst->pool);
- if (!fdp) {
- REDEBUG("Failed to get handle from connection pool");
- return RLM_MODULE_FAIL;
- }
+ if (!fdp) return RLM_MODULE_FAIL;
/* Get greeting */
bufsize = read_all(fdp, buffer, sizeof(buffer));
* The server will take care of sending it to the user.
*/
request->reply->code = PW_CODE_ACCESS_CHALLENGE;
- DEBUG("rlm_smsotp: Sending Access-Challenge.");
+ DEBUG("rlm_smsotp: Sending Access-Challenge");
rcode = RLM_MODULE_HANDLED;
* from the database. The authentication code only needs to check
* the password, the rest is done here.
*/
-static rlm_rcode_t mod_authorize(UNUSED void *instance, UNUSED REQUEST *request)
+static rlm_rcode_t CC_HINT(nonnull) mod_authorize(UNUSED void *instance, UNUSED REQUEST *request)
{
VALUE_PAIR *state;
rlm_smsotp_t *inst = instance;