25 RCSID(
"$Id: 61a40c71174e995a08f9d9a1c243f524b8d33155 $")
27 #include <freeradius-devel/radiusd.h>
28 #include <freeradius-devel/modules.h>
68 fdp = talloc_zero(ctx,
int);
79 static size_t read_all(
int *fdp,
char *buf,
size_t len)
94 n = read(*fdp, &buf[total], len - total);
105 if (n == 0)
return 0;
112 retval = select(1, &fds, NULL, NULL, &tv);
126 static int write_all(
int *fdp,
char const *buf,
size_t len)
132 n = write(*fdp, &buf[len - left], left);
134 if ((errno == EINTR) || (errno == EPIPE)) {
159 struct sockaddr_un sa;
160 if (strlen(inst->
socket) > (
sizeof(sa.sun_path) - 1)) {
193 bufsize =
read_all(fdp, buffer,
sizeof(buffer));
195 REDEBUG(
"Failed reading from socket");
202 #define WRITE_ALL(_a,_b,_c) if (write_all(_a,_b,_c) < 0) goto done;
205 RDEBUG(
"Found reply to access challenge");
208 snprintf(output,
sizeof(output),
"check otp for %s\n",
209 request->username->vp_strvalue);
212 (void)
read_all(fdp, buffer,
sizeof(buffer));
215 snprintf(output,
sizeof(output),
"user otp is %s\n",
216 request->password->vp_strvalue);
219 (void)
read_all(fdp, buffer,
sizeof(buffer));
222 snprintf(output,
sizeof(output),
"otp id is %s\n",
226 (void)
read_all(fdp, buffer,
sizeof(buffer));
229 WRITE_ALL(fdp,
"get check result\n", 17);
231 (void)
read_all(fdp, buffer,
sizeof(buffer));
236 RDEBUG(
"answer is %s", buffer);
237 if (strcmp(buffer,
"OK") == 0) {
247 snprintf(output,
sizeof(output),
"generate otp for %s\n",
248 request->username->vp_strvalue);
251 (void)
read_all(fdp, buffer,
sizeof(buffer));
256 RDEBUG(
"Unique ID is %s", buffer);
259 if (strcmp(buffer,
"FAILED") == 0) {
276 DEBUG(
"rlm_smsotp: Sending Access-Challenge");
301 DEBUG(
"rlm_smsotp: Found reply to access challenge (AUTZ), Adding Auth-Type '%s'",inst->
authtype);
326 .config = module_config,
static int mod_instantiate(CONF_SECTION *conf, void *instance)
RFC2865 - Access-Challenge.
The module is OK, continue.
Metadata exported by the module.
static rlm_rcode_t mod_authorize(void *instance, REQUEST *request)
Handle authorization requests using Couchbase document data.
#define RLM_TYPE_THREAD_SAFE
Module is threadsafe.
int fr_socket_client_unix(char const *path, bool async)
#define CONF_PARSER_TERMINATOR
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
static rlm_rcode_t mod_authenticate(void *instance, REQUEST *request) CC_HINT(nonnull)
Defines a CONF_PAIR to C data type mapping.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
fr_connection_pool_t * module_connection_pool_init(CONF_SECTION *module, void *opaque, fr_connection_create_t c, fr_connection_alive_t a, char const *prefix)
Initialise a module specific connection pool.
#define pair_make_config(_a, _b, _c)
static int _mod_conn_free(int *fdp)
#define WRITE_ALL(_a, _b, _c)
Stores an attribute, a value and various bits of other data.
fr_connection_pool_t * pool
void void cf_log_err_cs(CONF_SECTION const *cs, char const *fmt,...) CC_HINT(format(printf
0 methods index for authenticate section.
enum rlm_rcodes rlm_rcode_t
Return codes indicating the result of the module call.
static void * mod_conn_create(TALLOC_CTX *ctx, void *instance, struct timeval const *timeout)
void fr_pair_delete_by_num(VALUE_PAIR **head, unsigned int vendor, unsigned int attr, int8_t tag)
Delete matching pairs.
static rlm_rcode_t CC_HINT(nonnull)
uint64_t magic
Used to validate module struct.
Module failed, don't reply.
static int write_all(int *fdp, char const *buf, size_t len)
#define FR_CONF_OFFSET(_n, _t, _s, _f)
#define pair_make_reply(_a, _b, _c)
void * fr_connection_get(fr_connection_pool_t *pool)
Reserve a connection in the connection pool.
struct rlm_smsotp_t rlm_smsotp_t
VALUE_PAIR * fr_pair_find_by_num(VALUE_PAIR *head, unsigned int vendor, unsigned int attr, int8_t tag)
Find the pair with the matching attribute.
static size_t read_all(int *fdp, char *buf, size_t len)
void fr_connection_release(fr_connection_pool_t *pool, void *conn)
Release a connection.
static const CONF_PARSER module_config[]
String of printable characters.
1 methods index for authorize section.
int fr_socket_wait_for_connect(int sockfd, struct timeval const *timeout)
Wait for a socket to be connected, with an optional timeout.
The module handled the request, so stop.