OpenVPN
|
#include <security/pam_appl.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <signal.h>
#include <syslog.h>
#include <limits.h>
#include "utils.h"
#include <arpa/inet.h>
#include <openvpn-plugin.h>
Go to the source code of this file.
Data Structures | |
struct | auth_pam_context |
struct | name_value |
struct | name_value_list |
struct | user_pass |
Macros | |
#define | DEBUG(verb) ((verb) >= 4) |
#define | COMMAND_VERIFY 0 |
#define | COMMAND_EXIT 1 |
#define | RESPONSE_INIT_SUCCEEDED 10 |
#define | RESPONSE_INIT_FAILED 11 |
#define | RESPONSE_VERIFY_SUCCEEDED 12 |
#define | RESPONSE_VERIFY_FAILED 13 |
#define | RESPONSE_DEFER 14 |
#define | N_NAME_VALUE 16 |
Functions | |
static void | pam_server (int fd, const char *service, int verb, const struct name_value_list *name_value_list) |
static int | recv_control (int fd) |
static int | send_control (int fd, int code) |
static int | recv_string (int fd, char *buffer, int len) |
static int | send_string (int fd, const char *string) |
static void | close_fds_except (int keep) |
static void | set_signals (void) |
static int | name_value_match (const char *query, const char *match) |
static void | split_scrv1_password (struct user_pass *up) |
OPENVPN_EXPORT int | openvpn_plugin_open_v3 (const int v3structver, struct openvpn_plugin_args_open_in const *args, struct openvpn_plugin_args_open_return *ret) |
OPENVPN_EXPORT int | openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[]) |
OPENVPN_EXPORT void | openvpn_plugin_close_v1 (openvpn_plugin_handle_t handle) |
OPENVPN_EXPORT void | openvpn_plugin_abort_v1 (openvpn_plugin_handle_t handle) |
static int | my_conv (int n, const struct pam_message **msg_array, struct pam_response **response_array, void *appdata_ptr) |
static int | pam_auth (const char *service, const struct user_pass *up) |
static void | do_deferred_pam_auth (int fd, const char *ac_file_name, const char *service, const struct user_pass *up) |
Variables | |
static plugin_log_t | plugin_log = NULL |
static plugin_secure_memzero_t | plugin_secure_memzero = NULL |
static plugin_base64_decode_t | plugin_base64_decode = NULL |
static char * | MODULE = "AUTH-PAM" |
#define COMMAND_EXIT 1 |
Definition at line 59 of file auth-pam.c.
#define COMMAND_VERIFY 0 |
Definition at line 58 of file auth-pam.c.
#define DEBUG | ( | verb | ) | ((verb) >= 4) |
Definition at line 55 of file auth-pam.c.
#define N_NAME_VALUE 16 |
Definition at line 101 of file auth-pam.c.
#define RESPONSE_DEFER 14 |
Definition at line 66 of file auth-pam.c.
#define RESPONSE_INIT_FAILED 11 |
Definition at line 63 of file auth-pam.c.
#define RESPONSE_INIT_SUCCEEDED 10 |
Definition at line 62 of file auth-pam.c.
#define RESPONSE_VERIFY_FAILED 13 |
Definition at line 65 of file auth-pam.c.
#define RESPONSE_VERIFY_SUCCEEDED 12 |
Definition at line 64 of file auth-pam.c.
|
static |
Definition at line 251 of file auth-pam.c.
References name_value_list::len.
Referenced by openvpn_plugin_open_v3().
|
static |
Definition at line 850 of file auth-pam.c.
References MODULE, pam_auth(), plugin_log, RESPONSE_DEFER, send_control(), service, user_pass::username, and write.
Referenced by pam_server().
|
static |
Definition at line 648 of file auth-pam.c.
References user_pass::common_name, name_value_list::data, DEBUG, name_value_list::len, MODULE, msg, name_value::name, user_pass::name_value_list, name_value_match(), user_pass::password, plugin_log, user_pass::response, searchandreplace(), user_pass::username, name_value::value, and user_pass::verb.
Referenced by pam_auth().
|
static |
Definition at line 284 of file auth-pam.c.
References name_value_list::len.
Referenced by my_conv().
OPENVPN_EXPORT void openvpn_plugin_abort_v1 | ( | openvpn_plugin_handle_t | handle | ) |
Definition at line 631 of file auth-pam.c.
References COMMAND_EXIT, and send_control().
OPENVPN_EXPORT void openvpn_plugin_close_v1 | ( | openvpn_plugin_handle_t | handle | ) |
Definition at line 600 of file auth-pam.c.
References COMMAND_EXIT, DEBUG, MODULE, plugin_log, and send_control().
OPENVPN_EXPORT int openvpn_plugin_func_v1 | ( | openvpn_plugin_handle_t | handle, |
const int | type, | ||
const char * | argv[], | ||
const char * | envp[] | ||
) |
Definition at line 523 of file auth-pam.c.
References COMMAND_VERIFY, DEBUG, get_env(), MODULE, plugin_log, recv_control(), RESPONSE_DEFER, RESPONSE_VERIFY_SUCCEEDED, send_control(), send_string(), and status.
OPENVPN_EXPORT int openvpn_plugin_open_v3 | ( | const int | v3structver, |
struct openvpn_plugin_args_open_in const * | args, | ||
struct openvpn_plugin_args_open_return * | ret | ||
) |
Definition at line 358 of file auth-pam.c.
References argv::argv, close_fds_except(), daemonize(), name_value_list::data, get_env(), name_value_list::len, MODULE, N_NAME_VALUE, name_value::name, pam_server(), plugin_base64_decode, plugin_log, plugin_secure_memzero, recv_control(), RESPONSE_INIT_SUCCEEDED, set_signals(), status, string_array_len(), and name_value::value.
|
static |
Definition at line 791 of file auth-pam.c.
References name_value_list::len, MODULE, my_conv(), user_pass::name_value_list, plugin_log, user_pass::remote, service, status, and user_pass::username.
Referenced by do_deferred_pam_auth(), and pam_server().
|
static |
Definition at line 917 of file auth-pam.c.
References COMMAND_EXIT, COMMAND_VERIFY, user_pass::common_name, DEBUG, do_deferred_pam_auth(), MODULE, user_pass::name_value_list, pam_auth(), user_pass::password, plugin_log, plugin_secure_memzero, recv_control(), recv_string(), user_pass::remote, user_pass::response, RESPONSE_INIT_FAILED, RESPONSE_INIT_SUCCEEDED, RESPONSE_VERIFY_FAILED, RESPONSE_VERIFY_SUCCEEDED, send_control(), service, split_scrv1_password(), user_pass::username, and user_pass::verb.
Referenced by openvpn_plugin_open_v3().
|
static |
Definition at line 138 of file auth-pam.c.
References name_value_list::len, and read.
Referenced by openvpn_plugin_func_v1(), openvpn_plugin_open_v3(), and pam_server().
|
static |
Definition at line 169 of file auth-pam.c.
References name_value_list::len, and read.
Referenced by pam_server().
|
static |
Definition at line 154 of file auth-pam.c.
References name_value_list::len, and write.
Referenced by do_deferred_pam_auth(), openvpn_plugin_abort_v1(), openvpn_plugin_close_v1(), openvpn_plugin_func_v1(), and pam_server().
|
static |
Definition at line 186 of file auth-pam.c.
References name_value_list::len, and write.
Referenced by openvpn_plugin_func_v1().
|
static |
Definition at line 269 of file auth-pam.c.
References name_value_list::len.
Referenced by openvpn_plugin_open_v3().
|
static |
Definition at line 303 of file auth-pam.c.
References DEBUG, name_value_list::len, MODULE, user_pass::password, plugin_base64_decode, plugin_log, plugin_secure_memzero, user_pass::response, and user_pass::verb.
Referenced by pam_server().
|
static |
Definition at line 74 of file auth-pam.c.
Referenced by do_deferred_pam_auth(), my_conv(), openvpn_plugin_close_v1(), openvpn_plugin_func_v1(), openvpn_plugin_open_v3(), pam_auth(), pam_server(), and split_scrv1_password().
|
static |
Definition at line 71 of file auth-pam.c.
Referenced by openvpn_plugin_open_v3(), and split_scrv1_password().
|
static |
Definition at line 69 of file auth-pam.c.
Referenced by do_deferred_pam_auth(), my_conv(), openvpn_plugin_close_v1(), openvpn_plugin_func_v1(), openvpn_plugin_open_v3(), pam_auth(), pam_server(), and split_scrv1_password().
|
static |
Definition at line 70 of file auth-pam.c.
Referenced by openvpn_plugin_open_v3(), pam_server(), and split_scrv1_password().