29#ifdef ENABLE_MANAGEMENT
57#define MANAGEMENT_ECHO_PULL_INFO 0
59#if MANAGEMENT_ECHO_PULL_INFO
60#define MANAGEMENT_ECHO_FLAGS LOG_PRINT_INTVAL
62#define MANAGEMENT_ECHO_FLAGS 0
91 msg(
M_CLIENT,
"auth-retry t : Auth failure retry mode (none,interact,nointeract).");
92 msg(
M_CLIENT,
"bytecount n : Show bytes in/out, update every n secs (0=off).");
93 msg(
M_CLIENT,
"echo [on|off] [N|all] : Like log, but only show messages in echo buffer.");
95 "cr-response response : Send a challenge response answer via CR_RESPONSE to server");
96 msg(
M_CLIENT,
"exit|quit : Close management session.");
97 msg(
M_CLIENT,
"forget-passwords : Forget passwords entered so far.");
99 msg(
M_CLIENT,
"hold [on|off|release] : Set/show hold flag to on/off state, or");
100 msg(
M_CLIENT,
" release current hold and start tunnel.");
101 msg(
M_CLIENT,
"kill cn : Kill the client instance(s) having common name cn.");
102 msg(
M_CLIENT,
"kill IP:port : Kill the client instance connecting from IP:port.");
103 msg(
M_CLIENT,
"load-stats : Show global server load stats.");
104 msg(
M_CLIENT,
"log [on|off] [N|all] : Turn on/off realtime log display");
105 msg(
M_CLIENT,
" + show last N lines or 'all' for entire history.");
107 "mute [n] : Set log mute level to n, or show level if n is absent.");
108 msg(
M_CLIENT,
"needok type action : Enter confirmation for NEED-OK request of 'type',");
109 msg(
M_CLIENT,
" where action = 'ok' or 'cancel'.");
110 msg(
M_CLIENT,
"needstr type action : Enter confirmation for NEED-STR request of 'type',");
112 msg(
M_CLIENT,
"net : (Windows only) Show network info and routing table.");
113 msg(
M_CLIENT,
"password type p : Enter password p for a queried OpenVPN password.");
114 msg(
M_CLIENT,
"password type : (version >=5) Enter password base64-encoded on");
115 msg(
M_CLIENT,
" subsequent lines followed by END.");
116 msg(
M_CLIENT,
"remote type [host port] : Override remote directive, type=ACCEPT|MOD|SKIP.");
117 msg(
M_CLIENT,
"remote-entry-count : Get number of available remote entries.");
118 msg(
M_CLIENT,
"remote-entry-get i|all [j]: Get remote entry at index = i to to j-1 or all.");
119 msg(
M_CLIENT,
"proxy type [host port flags] : Enter dynamic proxy server info.");
120 msg(
M_CLIENT,
"pid : Show process ID of the current OpenVPN process.");
122 msg(
M_CLIENT,
"pkcs11-id-count : Get number of available PKCS#11 identities.");
123 msg(
M_CLIENT,
"pkcs11-id-get index : Get PKCS#11 identity at index.");
125 msg(
M_CLIENT,
"client-auth CID KID : Authenticate client-id/key-id CID/KID (MULTILINE)");
126 msg(
M_CLIENT,
"client-auth-nt CID KID : Authenticate client-id/key-id CID/KID");
128 "client-deny CID KID R [CR] : Deny auth client-id/key-id CID/KID with log reason");
129 msg(
M_CLIENT,
" text R and optional client reason text CR");
131 "client-pending-auth CID KID MSG timeout : Instruct OpenVPN to send AUTH_PENDING and INFO_PRE msg");
133 " to the client and wait for a final client-auth/client-deny");
134 msg(
M_CLIENT,
"client-kill CID [M] : Kill client instance CID with message M (def=RESTART)");
135 msg(
M_CLIENT,
"env-filter [level] : Set env-var filter level");
136 msg(
M_CLIENT,
"rsa-sig : Enter a signature in response to >RSA_SIGN challenge");
138 " Enter signature base64 on subsequent lines followed by END");
139 msg(
M_CLIENT,
"pk-sig : Enter a signature in response to >PK_SIGN challenge");
141 " Enter signature base64 on subsequent lines followed by END");
143 "certificate : Enter a client certificate in response to >NEED-CERT challenge");
145 " Enter certificate base64 on subsequent lines followed by END");
146 msg(
M_CLIENT,
"signal s : Send signal s to daemon,");
147 msg(
M_CLIENT,
" s = SIGHUP|SIGTERM|SIGUSR1|SIGUSR2.");
148 msg(
M_CLIENT,
"state [on|off] [N|all] : Like log, but show state history.");
149 msg(
M_CLIENT,
"status [n] : Show current daemon status info using format #n.");
150 msg(
M_CLIENT,
"test n : Produce n lines of output for testing/debugging.");
151 msg(
M_CLIENT,
"username type u : Enter username u for a queried OpenVPN username.");
152 msg(
M_CLIENT,
"verb [n] : Set log verbosity level to n, or show if n is absent.");
153 msg(
M_CLIENT,
"version [n] : Set client's version to n or show current version of daemon.");
154 msg(
M_CLIENT,
"push-update-broad options : Broadcast a message to update the specified options.");
155 msg(
M_CLIENT,
" Ex. push-update-broad \"route something, -dns\"");
156 msg(
M_CLIENT,
"push-update-cid CID options : Send an update message to the client identified by CID.");
190 return "RECONNECTING";
199 return "TCP_CONNECT";
202 return "AUTH_PENDING";
212 msg(
M_CLIENT,
">INFO:OpenVPN Management Interface Version %d -- type 'help' for more info",
249 msg(
M_WARN,
"MAN: client connection rejected after %d failed password attempts",
281 volatile int signal_received = 0;
328 msg(
M_CLIENT,
"SUCCESS: %s command succeeded", command);
332 msg(
M_CLIENT,
"ERROR: %s command failed", command);
342 socket_delete_unix(&man->
settings.local_unix);
367 static int recursive_level = 0;
369#define AF_DID_PUSH (1 << 0)
370#define AF_DID_RESET (1 << 1)
371 if (recursive_level < 5)
375 unsigned int action_flags = 0;
397 const char *out = NULL;
442 printf(
"virtual_output: message to management interface "
443 "dropped due to recursion: <%s>\n",
492 msg(
M_CLIENT,
"ERROR: signal '%s' is currently ignored", name);
501 msg(
M_CLIENT,
"ERROR: signal '%s' is not a known signal type", name);
508 msg(
M_CLIENT,
"ERROR: The '%s' command is not supported by the current daemon mode",
535 if (update_seconds > 0)
567 msg(
M_CLIENT,
"SUCCESS: bytecount interval changed");
607 buf_set_read(&buf, (uint8_t *)victim, strlen(victim) + 1);
612 if (strlen(p1) && strlen(p2) && strlen(p3))
620 const int port = atoi(p3);
625 if ((port > 0 && port <= UINT16_MAX) && (proto !=
PROTO_NONE))
628 addr, (uint16_t)port, proto);
631 msg(
M_CLIENT,
"SUCCESS: %d client(s) at address %s:%s:%d killed", n_killed,
637 msg(
M_CLIENT,
"ERROR: client at address %s:%s:%d not found",
644 msg(
M_CLIENT,
"ERROR: port number or protocol out of range: %s %s", p3, p1);
649 msg(
M_CLIENT,
"ERROR: error parsing IP address: %s", p2);
658 msg(
M_CLIENT,
"SUCCESS: common name '%s' found, %d client(s) killed", p1, n_killed);
662 msg(
M_CLIENT,
"ERROR: common name '%s' not found", p1);
684 bool *realtime,
const unsigned int lep_flags)
689 if (
streq(parm,
"on"))
692 msg(
M_CLIENT,
"SUCCESS: real-time %s notification set to ON", type);
694 else if (
streq(parm,
"off"))
697 msg(
M_CLIENT,
"SUCCESS: real-time %s notification set to OFF", type);
699 else if (
streq(parm,
"all") || (n = atoi(parm)) > 0)
702 const int start = (n ? n : size) - 1;
705 for (i = start; i >= 0; --i)
718 msg(
M_CLIENT,
"ERROR: %s parameter must be 'on' or 'off' or some number n or 'all'", type);
784 const char *prompt,
char *dest,
int len)
793 msg(
M_CLIENT,
"SUCCESS: '%s' %s entered, but not yet verified", type, prompt);
797 msg(
M_CLIENT,
"ERROR: %s of type '%s' entered, but we need one of type '%s'", prompt,
803 msg(
M_CLIENT,
"ERROR: no %s is currently needed at this time", prompt);
855 msg(
M_CLIENT,
"SUCCESS: Passwords were forgotten");
877 message, parameters);
895man_pkcs11_id_count(
const struct management *man)
897 msg(
M_CLIENT,
">PKCS11ID-COUNT:%d", pkcs11_management_id_count());
901man_pkcs11_id_get(
struct management *man,
const int index)
906 if (pkcs11_management_id_get(index, &
id, &base64))
908 msg(
M_CLIENT,
">PKCS11ID-ENTRY:'%d', ID:'%s', BLOB:'%s'", index,
id, base64);
945 unsigned int from = (
unsigned int)atoi(p1);
946 unsigned int to = p2 ? (
unsigned int)atoi(p2) : from + 1;
948 if (!strcmp(p1,
"all"))
954 for (
unsigned int i = from; i <
min_uint(to, count); i++)
978 if (
streq(cmd,
"on"))
983 else if (
streq(cmd,
"off"))
988 else if (
streq(cmd,
"release"))
995 msg(
M_CLIENT,
"ERROR: bad hold command parameter");
1051 msg(
M_CLIENT,
"ERROR: no password is currently needed at this time");
1056 msg(
M_CLIENT,
"ERROR: password of type '%s' entered, but we need one of type '%s'",
1137 if (buf &&
BLEN(buf) > 0)
1149 msg(
M_CLIENT,
"ERROR: could not base64-decode password");
1153 decoded[
len] =
'\0';
1169 if (sscanf(str,
"%lu", cid) == 1)
1183 if (sscanf(str,
"%u", uint) == 1)
1207 const char *extra,
const char *timeout_str)
1209 unsigned long cid = 0;
1210 unsigned int kid = 0;
1211 unsigned int timeout = 0;
1213 &&
parse_uint(timeout_str,
"TIMEOUT", &timeout))
1218 kid, extra, timeout);
1222 msg(
M_CLIENT,
"SUCCESS: client-pending-auth command succeeded");
1226 msg(
M_CLIENT,
"ERROR: client-pending-auth command failed."
1227 " Extra parameter might be too long");
1239 const char *kid_str)
1279 const char *reason,
const char *client_reason)
1281 unsigned long cid = 0;
1282 unsigned int kid = 0;
1291 msg(
M_CLIENT,
"SUCCESS: client-deny command succeeded");
1295 msg(
M_CLIENT,
"ERROR: client-deny command failed");
1308 unsigned long cid = 0;
1317 msg(
M_CLIENT,
"SUCCESS: client-kill command succeeded");
1321 msg(
M_CLIENT,
"ERROR: client-kill command failed");
1349 msg(
M_CLIENT,
"SUCCESS: env_filter_level=%d", level);
1365 msg(
M_CLIENT,
"ERROR: The %s command is not currently available", cmd_name);
1381 msg(
M_CLIENT,
"ERROR: The certificate command is not currently available");
1398#define MN_AT_LEAST (1 << 0)
1409man_need(
const char **p,
const int n,
unsigned int flags)
1412 for (
int i = 1; i <= n; ++i)
1416 msg(
M_CLIENT,
"ERROR: the '%s' command requires %s%d parameter%s", p[0],
1417 (flags &
MN_AT_LEAST) ?
"at least " :
"", n, n > 1 ?
"s" :
"");
1452#ifdef TARGET_ANDROID
1454man_network_change(
struct management *man,
bool samenetwork)
1465 msg(
M_CLIENT,
"PROTECTFD: fd '%d' sent to be protected", fd);
1488 msg(
M_CLIENT,
"ERROR: Invalid value specified for management client version");
1515 unsigned long cid = 0;
1519 msg(
M_CLIENT,
"ERROR: push-update-cid fail during cid parsing");
1528 msg(
M_CLIENT,
"SUCCESS: push-update command succeeded");
1531 msg(
M_CLIENT,
"ERROR: push-update command failed");
1538 if (
streq(p[0],
"exit") ||
streq(p[0],
"quit"))
1542 else if (
streq(p[0],
"help"))
1546 else if (
streq(p[0],
"version") && p[1])
1550 else if (
streq(p[0],
"version"))
1556 else if (
streq(p[0],
"pid"))
1560 else if (
streq(p[0],
"nclients"))
1564 else if (
streq(p[0],
"env-filter"))
1573 else if (
streq(p[0],
"signal"))
1580#ifdef TARGET_ANDROID
1581 else if (
streq(p[0],
"network-change"))
1583 bool samenetwork =
false;
1584 if (p[1] &&
streq(p[1],
"samenetwork"))
1589 man_network_change(man, samenetwork);
1592 else if (
streq(p[0],
"load-stats"))
1596 else if (
streq(p[0],
"status"))
1601 version = atoi(p[1]);
1605 else if (
streq(p[0],
"kill"))
1612 else if (
streq(p[0],
"verb"))
1616 const int level = atoi(p[1]);
1623 msg(
M_CLIENT,
"ERROR: verb level is out of range");
1631 else if (
streq(p[0],
"mute"))
1635 const int level = atoi(p[1]);
1642 msg(
M_CLIENT,
"ERROR: mute level is out of range");
1650 else if (
streq(p[0],
"auth-retry"))
1656 msg(
M_CLIENT,
"SUCCESS: auth-retry parameter changed");
1668 else if (
streq(p[0],
"state"))
1683 else if (
streq(p[0],
"log"))
1697 else if (
streq(p[0],
"echo"))
1711 else if (
streq(p[0],
"username"))
1718 else if (
streq(p[0],
"password"))
1732 msg(
M_CLIENT,
"ERROR: the 'password' command requires 2 parameters");
1736 else if (
streq(p[0],
"forget-passwords"))
1740 else if (
streq(p[0],
"needok"))
1747 else if (
streq(p[0],
"needstr"))
1754 else if (
streq(p[0],
"cr-response"))
1761 else if (
streq(p[0],
"net"))
1765 else if (
streq(p[0],
"hold"))
1769 else if (
streq(p[0],
"bytecount"))
1776 else if (
streq(p[0],
"client-kill"))
1783 else if (
streq(p[0],
"client-deny"))
1790 else if (
streq(p[0],
"client-auth-nt"))
1797 else if (
streq(p[0],
"client-auth"))
1804 else if (
streq(p[0],
"client-pending-auth"))
1811 else if (
streq(p[0],
"client-acc-msg"))
1818 else if (
streq(p[0],
"acc-msg"))
1822 else if (
streq(p[0],
"rsa-sig"))
1826 else if (
streq(p[0],
"pk-sig"))
1830 else if (
streq(p[0],
"certificate"))
1835 else if (
streq(p[0],
"pkcs11-id-count"))
1837 man_pkcs11_id_count(man);
1839 else if (
streq(p[0],
"pkcs11-id-get"))
1843 man_pkcs11_id_get(man, atoi(p[1]));
1847 else if (
streq(p[0],
"remote-entry-count"))
1851 else if (
streq(p[0],
"remote-entry-get"))
1858 else if (
streq(p[0],
"proxy"))
1865 else if (
streq(p[0],
"remote"))
1872 else if (
streq(p[0],
"push-update-broad"))
1879 else if (
streq(p[0],
"push-update-cid"))
1887 else if (
streq(p[0],
"test"))
1892 const int n = atoi(p[1]);
1893 for (i = 0; i < n; ++i)
1896 "[%d] The purpose of this command is to generate large amounts of output.", i);
1903 msg(
M_CLIENT,
"ERROR: unknown command [%s], enter 'help' for more options", p[0]);
1963#if UNIX_SOCK_SUPPORT
1967 sockaddr_unix_name(&man->
settings.local_unix,
"NULL"));
1978 struct sockaddr_storage addr;
1979 socklen_t addrlen =
sizeof(addr);
1980 if (!getpeername(man->
connection.
sd_cli, (
struct sockaddr *)&addr, &addrlen))
2003#if UNIX_SOCK_SUPPORT
2009 static const char err_prefix[] =
2010 "MANAGEMENT: unix domain socket client connection rejected --";
2018 "%s UID of socket peer (%d) doesn't match required value (%d) as given by --management-client-user",
2019 err_prefix, uid, man->
settings.user.uid);
2025 "%s GID of socket peer (%d) doesn't match required value (%d) as given by --management-client-group",
2026 err_prefix, gid, man->
settings.group.gid);
2032 msg(
D_MANAGEMENT,
"%s cannot get UID/GID of socket peer", err_prefix);
2049#if UNIX_SOCK_SUPPORT
2052 struct sockaddr_un remote;
2096#if UNIX_SOCK_SUPPORT
2108 "MANAGEMENT",
false);
2116 msg(
M_ERR,
"MANAGEMENT: listen() failed");
2124#if UNIX_SOCK_SUPPORT
2128 sockaddr_unix_name(&man->
settings.local_unix,
"NULL"));
2133 const struct sockaddr *man_addr = man->
settings.
local->ai_addr;
2134 struct sockaddr_storage addr;
2135 socklen_t addrlen =
sizeof(addr);
2136 if (!getsockname(man->
connection.
sd_top, (
struct sockaddr *)&addr, &addrlen))
2138 man_addr = (
struct sockaddr *)&addr;
2161 int signal_received = 0;
2169#if UNIX_SOCK_SUPPORT
2192 if (signal_received)
2200#if UNIX_SOCK_SUPPORT
2204 sockaddr_unix_name(&man->
settings.local_unix,
"NULL"));
2289 if (parms[0] &&
streq(parms[0],
"password"))
2293 else if (!
streq(line,
"load-stats"))
2302 for (i = 0; i < nparms; ++i)
2323 bool crt_error =
false;
2329 msg(
D_MANAGEMENT,
"MANAGEMENT: TCP %s error: %s", prefix, strerror(err));
2339#ifdef TARGET_ANDROID
2341man_send_with_fd(
int fd,
const void *ptr,
size_t nbytes,
int flags,
int sendfd)
2343 struct msghdr
msg = { 0 };
2344 struct iovec iov[1];
2349 char control[CMSG_SPACE(
sizeof(
int))];
2351 struct cmsghdr *cmptr;
2353 msg.msg_control = control_un.control;
2354 msg.msg_controllen =
sizeof(control_un.control);
2356 cmptr = CMSG_FIRSTHDR(&
msg);
2357 cmptr->cmsg_len = CMSG_LEN(
sizeof(
int));
2358 cmptr->cmsg_level = SOL_SOCKET;
2359 cmptr->cmsg_type = SCM_RIGHTS;
2360 *((
int *)CMSG_DATA(cmptr)) = sendfd;
2362 msg.msg_name = NULL;
2363 msg.msg_namelen = 0;
2367 iov[0].iov_base = (
void *)ptr;
2368 iov[0].iov_len = nbytes;
2372 return sendmsg(fd, &
msg, flags);
2376man_recv_with_fd(
int fd,
void *ptr,
size_t nbytes,
int flags,
int *recvfd)
2378 struct msghdr msghdr = { 0 };
2379 struct iovec iov[1];
2385 char control[CMSG_SPACE(
sizeof(
int))];
2387 struct cmsghdr *cmptr;
2389 msghdr.msg_control = control_un.control;
2390 msghdr.msg_controllen =
sizeof(control_un.control);
2392 msghdr.msg_name = NULL;
2393 msghdr.msg_namelen = 0;
2395 iov[0].iov_base = ptr;
2396 iov[0].iov_len = nbytes;
2397 msghdr.msg_iov = iov;
2398 msghdr.msg_iovlen = 1;
2400 if ((n = recvmsg(fd, &msghdr, flags)) <= 0)
2405 if ((cmptr = CMSG_FIRSTHDR(&msghdr)) != NULL && cmptr->cmsg_len == CMSG_LEN(
sizeof(
int)))
2407 if (cmptr->cmsg_level != SOL_SOCKET)
2409 msg(
M_ERR,
"control level != SOL_SOCKET");
2411 if (cmptr->cmsg_type != SCM_RIGHTS)
2413 msg(
M_ERR,
"control type != SCM_RIGHTS");
2415 *recvfd = *((
int *)CMSG_DATA(cmptr));
2429management_android_control(
const struct management *man,
const char *command,
const char *
msg)
2433 msg(
M_FATAL,
"Required management interface not available.");
2437 strlcpy(up.username,
msg,
sizeof(up.username));
2440 return strcmp(
"ok", up.password) == 0;
2450managment_android_persisttun_action(
struct management *man)
2454 strcpy(up.username,
"tunmethod");
2457 if (!strcmp(
"NOACTION", up.password))
2459 return ANDROID_KEEP_OLD_TUN;
2461 else if (!strcmp(
"OPEN_BEFORE_CLOSE", up.password))
2463 return ANDROID_OPEN_BEFORE_CLOSE;
2467 msg(
M_ERR,
"Got unrecognised '%s' from management for PERSIST_TUN_ACTION query",
2472 return ANDROID_OPEN_BEFORE_CLOSE;
2484 unsigned char buf[256];
2487#ifdef TARGET_ANDROID
2504 bool processed_command =
false;
2506 ASSERT(len <= (ssize_t)
sizeof(buf));
2523 if (!strcmp(line,
"END"))
2541 processed_command =
true;
2555 if (processed_command)
2575 const int size_hint = 1024;
2580 if (buf &&
BLEN(buf))
2583#ifdef TARGET_ANDROID
2631 const int state_buffer_size)
2689 const char *pass_file,
const char *client_user,
const char *client_group,
2690 const int log_history_cache,
const int echo_buffer_size,
2691 const int state_buffer_size,
const int remap_sigusr1,
const unsigned int flags)
2707#if UNIX_SOCK_SUPPORT
2724 sockaddr_unix_init(&ms->local_unix, addr);
2763 if (remap_sigusr1 ==
SIGHUP)
2767 else if (remap_sigusr1 ==
SIGTERM)
2781 freeaddrinfo(ms->
local);
2877 const char *client_user,
const char *client_group,
const int log_history_cache,
2878 const int echo_buffer_size,
const int state_buffer_size,
const int remap_sigusr1,
2879 const unsigned int flags)
2888 log_history_cache, echo_buffer_size, state_buffer_size, remap_sigusr1, flags);
2942 const in_addr_t *tun_local_ip,
const struct in6_addr *tun_local_ip6,
2950 const char *out = NULL;
2997 static const char *env_names[] = {
"username=",
3003 "ifconfig_netmask=",
3004 "daemon_start_time=",
3007 "ifconfig_pool_remote_ip=",
3008 "ifconfig_pool_netmask=",
3015 "acc_message_len=" };
3017 if (env_filter_level == 0)
3021 else if (env_filter_level <= 1 && !strncmp(env_str,
"X509_", 5))
3025 else if (env_filter_level <= 2)
3028 for (i = 0; i <
SIZE(env_names); ++i)
3030 const char *en = env_names[i];
3031 const size_t len = strlen(en);
3032 if (!strncmp(env_str, en, len))
3049 for (e = es->
list; e != NULL; e = e->
next)
3090 msg(
M_CLIENT,
">NOTIFY:%s,%s,%s", severity, type, text);
3104 const char *peer_info =
3111 buf_set_read(&buf, (
const uint8_t *)peer_info, strlen(peer_info));
3112 while (
buf_parse(&buf,
'\n', line,
sizeof(line)))
3121 msg(
D_MANAGEMENT,
"validation failed on peer_info line received from client");
3134 const char *mode =
"CONNECT";
3152 const struct env_set *es,
const char *response)
3159 msg(
M_CLIENT,
">CLIENT:CR_RESPONSE,%lu,%u,%s", mdac->
cid, mda_key_id, response);
3196 const struct mroute_addr *addr,
const bool primary)
3214 const char *out = NULL;
3253 char buf[INET_ADDRSTRLEN];
3255 ia.s_addr = htonl(tun_local_ip);
3256 inet_ntop(AF_INET, &ia, buf,
sizeof(buf));
3278 msg(
M_CLIENT,
">PASSWORD:Verification Failed: '%s' ['%s']", type, reason);
3282 msg(
M_CLIENT,
">PASSWORD:Verification Failed: '%s'", type);
3297 if (*persistent == (
unsigned int)n)
3310 unsigned int *persistent)
3355 if (net_events & FD_CLOSE)
3363 if (net_events & FD_ACCEPT)
3372 if (net_events & FD_READ)
3380 if (net_events & FD_WRITE)
3383 if (
status < 0 && WSAGetLastError() == WSAEWOULDBLOCK)
3397 unsigned int *persistent)
3466 if (signal_received)
3469 if (*signal_received)
3517 else if (expire &&
now >= expire)
3521 if (signal_received)
3523 *signal_received =
SIGINT;
3551 if (signal_received && *signal_received)
3564 const time_t expire)
3578#define MWCC_PASSWORD_WAIT (1 << 0)
3579#define MWCC_HOLD_WAIT (1 << 1)
3580#define MWCC_OTHER_WAIT (1 << 2)
3587 const time_t expire,
unsigned int flags)
3594 msg(
D_MANAGEMENT,
"Need password(s) from management interface, waiting...");
3598 msg(
D_MANAGEMENT,
"Need hold release from management interface, waiting...");
3602 msg(
D_MANAGEMENT,
"Need information from management interface, waiting...");
3607 if (signal_received && *signal_received)
3623 volatile int signal_received = 0;
3639 if (signal_received)
3648 if (!signal_received)
3652 if (signal_received)
3657 }
while (expire && expire >
now);
3673 const unsigned int flags,
const char *static_challenge)
3680 volatile int signal_received = 0;
3683 const char *alert_type = NULL;
3684 const char *prefix = NULL;
3685 unsigned int up_query_mode = 0;
3686 const char *sc = NULL;
3698 alert_type =
"confirmation";
3703 prefix =
"NEED-STR";
3704 alert_type =
"string";
3709 prefix =
"PASSWORD";
3710 alert_type =
"password";
3715 prefix =
"PASSWORD";
3716 alert_type =
"username";
3721 prefix =
"PASSWORD";
3722 alert_type =
"username/password";
3723 if (static_challenge)
3725 sc = static_challenge;
3728 buf_printf(&alert_msg,
">%s:Need '%s' %s", prefix, type, alert_type);
3743 char *user64 = NULL;
3745 if (user64_len == -1)
3749 else if (user64_len + 4 > 128)
3751 msg(
M_WARN |
M_INFO,
"Preferred username too long for user-pass prompt sent to management; omitting UN:<username> hint.");
3767 msg(
M_WARN |
M_INFO,
"SC:<challenge-text> in user-pass prompt sent to management got truncated.");
3772 if (signal_received)
3790 if (!signal_received)
3794 if (signal_received)
3833 const char *cmd,
int *state,
struct buffer_list **input)
3837 volatile int signal_received = 0;
3852 alert_msg =
alloc_buf_gc(strlen(b64_data) + strlen(prompt) + 3, &
gc);
3853 buf_printf(&alert_msg,
">%s:%s", prompt, b64_data);
3863 if (signal_received)
3875 if (!signal_received)
3879 if (signal_received)
3891 msg(
M_CLIENT,
"SUCCESS: %s command succeeded", cmd);
3911 const char *prompt,
const char *cmd,
int *state,
3915 char *result = NULL;
3922 if (buf &&
BLEN(buf) > 0)
3924 result = (
char *)malloc(
BLENZ(buf) + 1);
3927 result[
BLEN(buf)] =
'\0';
3940 const char *cmd,
int *state,
struct buffer_list **input)
3942 char *result = NULL;
3949 if (buf &&
BLEN(buf) > 0)
3951 result = (
char *)malloc(
BLENZ(buf) + 1);
3954 result[
BLEN(buf)] =
'\0';
3968 const char *prompt =
"PK_SIGN";
3969 const char *desc =
"pk-sign";
3970 struct buffer buf_data =
alloc_buf(strlen(b64_data) + strlen(algorithm) + 20);
3974 prompt =
"RSA_SIGN";
3978 buf_write(&buf_data, b64_data, (
int)strlen(b64_data));
3981 buf_write(&buf_data,
",", (
int)strlen(
","));
3982 buf_write(&buf_data, algorithm, (
int)strlen(algorithm));
3994 const char prompt_1[] =
"NEED-CERTIFICATE:";
3996 buf_write(&buf_prompt, prompt_1, strlen(prompt_1));
3997 buf_write(&buf_prompt, cert_name, strlen(cert_name) + 1);
4025 volatile int signal_received = 0;
4036 if (!signal_received)
4039 buf_printf(&out,
">HOLD:Waiting for hold release:%d", holdtime);
4047 if (!signal_received)
4051 if (signal_received)
4106 for (
size_t i = 0; i < len; ++i)
4121 const char *ret = NULL;
4257 for (i = 0; i < h->
size; ++i)
4303 for (i = 0; i < h->
size; ++i)
4316 if (index >= 0 && index < h->size)
4434 if (!input || input->
size < 3)
4436 msg(
M_CLIENT,
"not enough input lines for sending acc message, "
4437 "missing protocol, flag and/or messages lines");
4449 const char *acc_err_reason = NULL;
4453 msg(
M_CLIENT,
"ERROR: parsing acc message flags failed: %s", acc_err_reason);
4465 msg(
M_CLIENT,
"ERROR: protocol not in the list of negotiated protocols: %s",
bool send_acc_message(struct context *c, struct tls_multi *multi, struct tls_session *session, const char *protocol, bool fragment, const char *acc_msg_payload, bool base64)
int parse_acc_message_flags(const char *flags, const char **err_reason, struct gc_arena *gc)
Parses the flags field of an app control message If there is an error parsing the flags field the met...
@ ACC_MESSAGE_FLAGS_FRAGMENT
@ ACC_MESSAGE_FLAGS_BASE64
#define OPENVPN_BASE64_DECODED_LENGTH(base64_length)
Compute the maximal number of bytes encoded in a base64 string.
#define OPENVPN_BASE64_LENGTH(binary_length)
Compute resulting base64 length.
bool buffer_list_defined(const struct buffer_list *ol)
Checks if the list is valid and non-empty.
void free_buf(struct buffer *buf)
Free the memory allocated for a buffer.
void buffer_list_aggregate_separator(struct buffer_list *bl, const size_t max_len, const char *sep)
Aggregates as many buffers as possible from bl in a new buffer of maximum length max_len .
void buf_clear(struct buffer *buf)
Zeroise and reset a buffer.
void buffer_list_reset(struct buffer_list *ol)
Empty the list ol and frees all the contained buffers.
void buffer_list_aggregate(struct buffer_list *bl, const size_t max)
Aggregates as many buffers as possible from bl in a new buffer of maximum length max_len .
void buffer_list_pop(struct buffer_list *ol)
Remove and free the head buffer of the list.
bool buf_printf(struct buffer *buf, const char *format,...)
printf-style append to a buffer with overflow check.
struct buffer_list * buffer_list_new(void)
Allocate an empty buffer list of capacity max_size.
void chomp(char *str)
Remove trailing newline and carriage-return characters from a string.
struct buffer * buffer_list_peek(struct buffer_list *ol)
Retrieve the head buffer.
void buffer_list_free(struct buffer_list *ol)
Frees a buffer list and all the buffers in it.
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Allocate a buffer of the given size under garbage collection.
struct buffer alloc_buf(size_t size)
Allocate a buffer of the given size.
void buffer_list_advance(struct buffer_list *ol, ssize_t n)
Advance past n bytes in the head buffer, popping it if it becomes empty.
bool buf_parse(struct buffer *buf, const int delim, char *line, const int size)
Extract the next token from a buffer, delimited by a given character.
char * string_alloc(const char *str, struct gc_arena *gc)
Duplicate a string, allocating memory under garbage collection.
void buffer_list_push(struct buffer_list *ol, const char *str)
Allocates and appends a new buffer containing str as data to ol.
void buf_chomp(struct buffer *buf)
Remove trailing newline and carriage-return characters from a buffer.
bool char_class(const unsigned char c, const unsigned int flags)
Test whether a character belongs to one or more character classes.
int buf_substring_len(const struct buffer *buf, int delim)
Return the number of bytes in a buffer up to and including a delimiter.
#define ALLOC_OBJ(dptr, type)
Allocate memory for a single object of the given type.
static uint8_t * buf_bptr(struct buffer *buf)
Return a pointer to the start of the buffer content.
#define BSTR(buf)
Return the buffer content pointer cast to char *.
static bool buf_copy(struct buffer *dest, const struct buffer *src)
Copy the content of one buffer to the end of another.
#define ALLOC_ARRAY_CLEAR(dptr, type, n)
Allocate and zero-initialise an array of n elements of the given type.
static bool buf_copy_excess(struct buffer *dest, struct buffer *src, int len)
Truncate src to len bytes and copy any excess to dest.
#define streq(x, y)
helper to work around the semantics of the strcmp() return value
#define CC_NEWLINE
newline
static const char * buf_cstr(const struct buffer *buf)
Return the buffer content pointer cast to const char *.
static void buf_set_read(struct buffer *buf, const uint8_t *data, size_t size)
Initialise a buffer with an externally provided read-only memory region.
#define CBPTR(buf)
Return a const pointer to the start of the buffer content.
static void secure_memzero(void *data, size_t len)
Securely zeroise memory.
static bool buf_write(struct buffer *dest, const void *src, size_t size)
Append data to a buffer.
static bool buf_write_u8(struct buffer *dest, uint8_t data)
Append a uint8_t to a buffer.
#define BLEN(buf)
Return the length of the buffer content in bytes.
#define BLENZ(buf)
Return the length of the buffer content as a size_t.
static void check_malloc_return(void *p)
Abort if a memory allocation returned NULL.
static void gc_free(struct gc_arena *a)
Free all allocations in a garbage collection arena.
#define CBSTR(buf)
Return the buffer content pointer cast to const char *.
#define CC_PRINT
printable (>= 32, != 127)
#define ALLOC_OBJ_CLEAR(dptr, type)
Allocate and zero-initialise memory for a single object of the given type.
static struct gc_arena gc_new(void)
Allocate and return a new, empty garbage collection arena.
size_t strlcpy(char *dest, const char *src, size_t maxlen)
int memcmp_constant_time(const void *a, const void *b, size_t size)
As memcmp(), but constant-time.
static int dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_err)
static int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err)
void setenv_int(struct env_set *es, const char *name, int value)
struct env_set * env_set_create(struct gc_arena *gc)
#define D_MANAGEMENT_DEBUG
struct event_set * event_set_init(int *maxevents, unsigned int flags)
#define EVENT_METHOD_FAST
static void event_free(struct event_set *es)
static int event_wait(struct event_set *es, const struct timeval *tv, struct event_set_return *out, int outlen)
const struct rw_handle * event_t
static void event_reset(struct event_set *es)
static void event_ctl(struct event_set *es, event_t event, unsigned int rwflags, void *arg)
void set_nonblock(socket_descriptor_t fd)
counter_type link_write_bytes_global
counter_type link_read_bytes_global
void reset_coarse_timers(struct context *c)
static size_t min_size(size_t x, size_t y)
static unsigned int min_uint(unsigned int x, unsigned int y)
static int min_int(int x, int y)
static int modulo_add(int x, int y, int mod)
static SERVICE_STATUS status
bool event_timeout_trigger(struct event_timeout *et, struct timeval *tv, const int et_const_retry)
This is the principal function for testing and triggering recurring timers.
static void event_timeout_init(struct event_timeout *et, interval_t n, const time_t last)
Initialises a timer struct.
static void event_timeout_clear(struct event_timeout *et)
Clears the timeout and reset all values to 0.
void hash_iterator_free(struct hash_iterator *hi)
struct hash_element * hash_iterator_next(struct hash_iterator *hi)
void hash_iterator_init(struct hash *hash, struct hash_iterator *hi)
void management_pre_tunnel_close(struct management *man)
void log_history_close(struct log_history *h)
static void man_history(struct management *man, const char *parm, const char *type, const struct log_history *log, bool *realtime, const unsigned int lep_flags)
static void man_status(struct management *man, const int version, struct status_output *so)
void management_check_bytecount_server(struct multi_context *multi, struct timeval *timeval)
static void man_up_finalize(struct management *man)
static bool man_io_error(struct management *man, const char *prefix)
struct command_line * command_line_new(const size_t len)
static void man_log(struct management *man, const char *parm)
void management_auth_token(const char *token)
static void man_reset_client_socket(struct management *man, const bool exiting)
static void man_bytecount(struct management *man, const int update_seconds)
static void man_connect(struct management *man)
void management_notify_client_needing_auth(struct management *man, const unsigned int mda_key_id, struct man_def_auth_context *mdac, const struct env_set *es)
static ssize_t man_read(struct management *man)
static bool man_check_for_signals(volatile int *signal_received)
static void man_bytecount_output_server(const counter_type bytes_in_total, const counter_type bytes_out_total, struct man_def_auth_context *mdac)
static void man_output_list_push(struct management *man, const char *str)
void management_socket_set(struct management *man, struct event_set *es, void *arg, unsigned int *persistent)
void command_line_free(struct command_line *cl)
static int man_block(struct management *man, volatile int *signal_received, const time_t expire)
static void man_certificate(struct management *man)
void command_line_next(struct command_line *cl)
void management_clear_callback(struct management *man)
static void man_persist_init(struct management *man, const int log_history_cache, const int echo_buffer_size, const int state_buffer_size)
char * management_query_cert(struct management *man, const char *cert_name)
static bool man_standalone_ok(const struct management *man)
bool management_send_acc_message(struct context *c, struct tls_multi *multi, struct tls_session *session, struct buffer_list *input)
void management_connection_established(struct management *man, struct man_def_auth_context *mdac, const struct env_set *es)
bool management_hold(struct management *man, int holdtime)
static void man_settings_init(struct man_settings *ms, const char *addr, const char *port, const char *pass_file, const char *client_user, const char *client_group, const int log_history_cache, const int echo_buffer_size, const int state_buffer_size, const int remap_sigusr1, const unsigned int flags)
static int log_index(const struct log_history *h, int i)
static void man_connection_clear(struct man_connection *mc)
static void man_start_ne32(struct management *man)
static void man_connection_settings_reset(struct management *man)
static void man_help(void)
static void man_update_io_state(struct management *man)
static void man_bytecount_stop(struct management *man)
static void man_check_password(struct management *man, const char *line)
static bool man_persist_state(unsigned int *persistent, const int n)
static void man_connection_init(struct management *man)
static bool env_filter_match(const char *env_str, const int env_filter_level)
static void man_client_pending_auth(struct management *man, const char *cid_str, const char *kid_str, const char *extra, const char *timeout_str)
Will send a notification to the client that succesful authentication will require an additional step ...
static void man_connection_close(struct management *man)
static void man_query_password(struct management *man, const char *type, const char *string)
static void man_client_kill(struct management *man, const char *cid_str, const char *kill_msg)
struct log_history * log_history_init(const int capacity)
static void man_listen(struct management *man)
static void man_stop_ne32(struct management *man)
static void man_forget_passwords(void)
static void man_query_username(struct management *man, const char *type, const char *string)
static void man_push_update(struct management *man, const char **p, const push_update_type type)
#define MWCC_PASSWORD_WAIT
static void virtual_output_callback_func(void *arg, const unsigned int flags, const char *str)
static void man_signal(struct management *man, const char *name)
static void man_prompt(struct management *man)
static void man_state(struct management *man, const char *parm)
static void man_client_deny(struct management *man, const char *cid_str, const char *kid_str, const char *reason, const char *client_reason)
static void man_echo(struct management *man, const char *parm)
static char * management_query_multiline_flatten(struct management *man, const char *b64_data, const char *prompt, const char *cmd, int *state, struct buffer_list **input)
static void man_proxy(struct management *man, const char **p)
struct management * management_init(void)
static void in_extra_reset(struct man_connection *mc, const int mode)
void command_line_reset(struct command_line *cl)
static void man_query_need_str(struct management *man, const char *type, const char *action)
bool management_would_hold(struct management *man)
bool management_query_user_pass(struct management *man, struct user_pass *up, const char *type, const unsigned int flags, const char *static_challenge)
static void man_bytecount_output_client(counter_type bytes_in_total, counter_type bytes_out_total)
void log_history_add(struct log_history *h, const struct log_entry *le)
void management_notify_client_close(const struct management *man, struct man_def_auth_context *mdac, const struct env_set *es)
static void log_entry_free_contents(struct log_entry *e)
static int man_mod_signal(const struct management *man, const int signum)
void management_notify_generic(const char *str)
void management_event_loop_n_seconds(struct management *man, int sec)
static void man_persist_close(struct man_persist *mp)
static void man_kill(struct management *man, const char *victim)
void management_close(struct management *man)
static void man_pk_sig(struct management *man, const char *cmd_name)
void management_set_state(struct management *man, const int state, const char *detail, const in_addr_t *tun_local_ip, const struct in6_addr *tun_local_ip6, const struct openvpn_sockaddr *local, const struct openvpn_sockaddr *remote)
static void man_output_list_push_finalize(struct management *man)
static bool man_need(const char **p, const int n, unsigned int flags)
Checks if the correct number of arguments to a management command are present and otherwise prints an...
static void man_load_stats(struct management *man)
static bool man_password_needed(struct management *man)
static void set_client_version(struct management *man, const char *version)
const char * log_entry_print(const struct log_entry *e, unsigned int flags, struct gc_arena *gc)
static void man_accept(struct management *man)
static void man_client_auth(struct management *man, const char *cid_str, const char *kid_str, const bool extra)
static bool parse_cid(const char *str, unsigned long *cid)
static void man_send_cc_message(struct management *man, const char *message, const char *parameters)
void management_io(struct management *man)
static void man_acc_msg(struct management *man)
static void man_wait_for_client_connection(struct management *man, volatile int *signal_received, const time_t expire, unsigned int flags)
static void man_output_peer_info_env(struct management *man, const struct man_def_auth_context *mdac)
bool management_open(struct management *man, const char *addr, const char *port, const char *pass_file, const char *client_user, const char *client_group, const int log_history_cache, const int echo_buffer_size, const int state_buffer_size, const int remap_sigusr1, const unsigned int flags)
static void man_welcome(struct management *man)
static void man_query_need_ok(struct management *man, const char *type, const char *action)
static char * management_query_multiline_flatten_newline(struct management *man, const char *b64_data, const char *prompt, const char *cmd, int *state, struct buffer_list **input)
static void man_output_extra_env(struct management *man, const char *prefix)
void man_persist_client_stats(struct management *man, struct context *c)
void management_auth_failure(const struct management *man, const char *type, const char *reason)
static void man_new_connection_post(struct management *man, const char *description)
static void log_history_obj_init(struct log_history *h, int capacity)
static void man_query_password_base64(struct management *man, const char *type)
Enter multi-line base64 mode for receiving a password that exceeds the single-line parameter size lim...
static void report_command_status(const bool status, const char *command)
Small function to report the success or failure of a command to the management interface.
static void man_close_socket(struct management *man, const socket_descriptor_t sd)
static bool parse_uint(const char *str, const char *what, unsigned int *uint)
void management_set_callback(struct management *man, const struct management_callback *cb)
static void man_client_n_clients(struct management *man)
static void man_output_standalone(struct management *man, volatile int *signal_received)
void management_notify_client_cr_response(unsigned mda_key_id, const struct man_def_auth_context *mdac, const struct env_set *es, const char *response)
void management_echo(struct management *man, const char *string, const bool pull)
static void man_remote_entry_get(struct management *man, const char *p1, const char *p2)
static void man_delete_unix_socket(const struct management *man)
const struct log_entry * log_history_ref(const struct log_history *h, const int index)
static void man_remote_entry_count(struct management *man)
static void man_settings_close(struct man_settings *ms)
void management_check_bytecount_client(struct context *c, struct management *man, struct timeval *timeval)
void management_notify(const char *severity, const char *type, const char *text)
static void man_env_filter(struct management *man, const int level)
#define MANAGEMENT_ECHO_FLAGS
static void man_client_acc_msg(struct management *man, const char *cid_str, const char *kid_str)
static void man_dispatch_command(struct management *man, struct status_output *so, const char **p)
static void man_output_list_push_str(struct management *man, const char *str)
char * management_query_pk_sig(struct management *man, const char *b64_data, const char *algorithm)
static void man_remote(struct management *man, const char **p)
void management_learn_addr(struct man_def_auth_context *mdac, const struct mroute_addr *addr, const bool primary)
void command_line_add(struct command_line *cl, const unsigned char *buf, const size_t len)
static int man_standalone_event_loop(struct management *man, volatile int *signal_received, const time_t expire)
static void man_process_command(struct management *man, const char *line)
static int management_query_multiline(struct management *man, const char *b64_data, const char *prompt, const char *cmd, int *state, struct buffer_list **input)
static void man_output_env(const struct env_set *es, const bool tail, const int env_filter_level, const char *prefix)
const char * command_line_get(struct command_line *cl)
static void log_history_free_contents(struct log_history *h)
void management_sleep(const int n)
A sleep function that services the management layer for n seconds rather than doing nothing.
static const char * man_state_name(const int state)
void log_history_resize(struct log_history *h, const int capacity)
static void in_extra_dispatch(struct management *man)
static void man_command_unsupported(const char *command_name)
static void man_net(const struct management *man)
void management_post_tunnel_open(struct management *man, const in_addr_t tun_local_ip)
static void man_query_user_pass(struct management *man, const char *type, const char *string, const bool needed, const char *prompt, char *dest, int len)
static ssize_t man_write(struct management *man)
void management_up_down(const struct management *man, const char *updown, const struct env_set *es)
static void man_hold(struct management *man, const char *cmd)
#define MANSIG_MAP_USR1_TO_TERM
#define OPENVPN_STATE_ADD_ROUTES
#define UP_QUERY_USER_PASS
#define OPENVPN_STATE_INITIAL
#define MF_FORGET_DISCONNECT
#define UP_QUERY_DISABLED
#define MANAGEMENT_STATE_BUFFER_SIZE
#define MANAGEMENT_VERSION
#define OPENVPN_STATE_CONNECTING
#define LOG_PRINT_REMOTE_IP
#define LOG_PRINT_STATE_PREFIX
#define OPENVPN_STATE_RECONNECTING
#define LOG_PRINT_INT_DATE
#define MANSIG_MAP_USR1_TO_HUP
#define LOG_PRINT_ECHO_PREFIX
#define LOG_PRINT_LOCAL_IP
#define MANAGEMENT_ECHO_BUFFER_SIZE
#define DAF_CONNECTION_CLOSED
#define OPENVPN_STATE_CLIENT_BASE
#define OPENVPN_STATE_CONNECTED
#define OPENVPN_STATE_RESOLVE
#define UP_QUERY_NEED_STR
#define OPENVPN_STATE_EXITING
static bool management_connected(const struct management *man)
#define MANAGEMENT_LOG_HISTORY_INITIAL_SIZE
#define OPENVPN_STATE_AUTH_PENDING
static int log_history_size(const struct log_history *h)
#define MANSIG_IGNORE_USR1_HUP
#define OPENVPN_STATE_AUTH
#define LOG_PRINT_LOG_PREFIX
#define OPENVPN_STATE_WAIT
#define DAF_CONNECTION_ESTABLISHED
#define OPENVPN_STATE_ASSIGN_IP
#define MANAGEMENT_N_PASSWORD_RETRIES
#define IEC_CLIENT_ACC_MSG
#define OPENVPN_STATE_GET_CONFIG
#define MF_CONNECT_AS_CLIENT
#define OPENVPN_STATE_TCP_CONNECT
#define LOG_PRINT_MSG_FLAGS
#define UP_QUERY_USERNAME
bool validate_peer_info_line(char *line)
#define GET_USER_PASS_STATIC_CHALLENGE_CONCAT
indicates password and response should be concatenated
#define GET_USER_PASS_PASSWORD_ONLY
#define GET_USER_PASS_USERNAME_ONLY
indicate that only username should be prompted for auth-user-pass
#define GET_USER_PASS_STATIC_CHALLENGE_ECHO
SCRV1 protocol – echo response.
#define GET_USER_PASS_NEED_OK
static const char blank_up[]
static bool get_user_pass(struct user_pass *up, const char *auth_file, const char *prefix, const unsigned int flags)
Retrieves the user credentials from various sources depending on the flags.
#define GET_USER_PASS_NEED_STR
const char * mroute_addr_print_ex(const struct mroute_addr *ma, const unsigned int flags, struct gc_arena *gc)
static const char * np(const char *str)
Header file for server-mode related structures and functions.
msglvl_t get_debug_level(void)
bool set_mute_cutoff(const int cutoff)
int get_mute_cutoff(void)
bool set_debug_level(const int level, const unsigned int flags)
const char * msg_flags_string(const msglvl_t flags, struct gc_arena *gc)
static void msg_set_virtual_output(const struct virtual_output *vo)
static bool ignore_sys_error(const int err, bool crt_error)
static int openvpn_errno_maybe_crt(bool *crt_error)
const char * auth_retry_print(void)
const char title_string[]
bool auth_retry_set(const msglvl_t msglevel, const char *option)
static bool dco_enabled(const struct options *o)
Returns whether the current configuration has dco enabled.
int parse_line(const char *line, char *p[], const int n, const char *file, const int line_num, msglvl_t msglevel, struct gc_arena *gc)
static void update_time(void)
int openvpn_getaddrinfo(unsigned int flags, const char *hostname, const char *servname, int resolve_retry_seconds, struct signal_info *sig_info, int ai_family, struct addrinfo **res)
in_addr_t getaddr(unsigned int flags, const char *hostname, int resolve_retry_seconds, bool *succeeded, struct signal_info *sig_info)
Translate an IPv4 addr or hostname from string form to in_addr_t.
#define GETADDR_MSG_VIRT_OUT
#define GETADDR_HOST_ORDER
#define GETADDR_WARN_ON_SIGNAL
void throw_signal_soft(const int signum, const char *signal_text)
Throw a soft global signal.
const char * signal_name(const int sig, const bool upper)
void throw_signal(const int signum)
Throw a hard signal.
int parse_signal(const char *signame)
static void get_signal(volatile int *sig)
Copy the global signal_received (if non-zero) to the passed-in argument sig.
void socket_bind(socket_descriptor_t sd, const struct addrinfo *local, int ai_family, const char *prefix, bool ipv6only)
socket_descriptor_t socket_do_accept(socket_descriptor_t sd, struct link_socket_actual *act, const bool nowait)
int openvpn_connect(socket_descriptor_t sd, const struct sockaddr *remote, int connect_timeout, volatile int *signal_received)
socket_descriptor_t create_socket_tcp(struct addrinfo *addrinfo)
void sd_close(socket_descriptor_t *sd)
#define openvpn_close_socket(s)
const char * proto2ascii(int proto, sa_family_t af, bool display_form)
const char * print_sockaddr_ex(const struct sockaddr *sa, const char *separator, const unsigned int flags, struct gc_arena *gc)
const char * print_in6_addr(struct in6_addr a6, unsigned int flags, struct gc_arena *gc)
const char * print_in_addr_t(in_addr_t addr, unsigned int flags, struct gc_arena *gc)
#define IA_EMPTY_IF_UNDEF
static const char * print_sockaddr(const struct sockaddr *addr, struct gc_arena *gc)
static bool addr_defined(const struct openvpn_sockaddr *addr)
#define PS_DONT_SHOW_FAMILY
int openvpn_base64_decode(const char *str, void *data, int size)
int openvpn_base64_encode(const void *data, int size, char **str)
void ssl_purge_auth(const bool auth_user_pass_only)
bool ssl_clean_auth_token(void)
Control Channel SSL/Data channel negotiation module.
bool tls_item_in_cipher_list(const char *item, const char *list)
Return true iff item is present in the colon-separated zero-terminated cipher list.
Control Channel SSL/Data dynamic negotiation Module This file is split from ssl.h to be able to unit ...
struct status_output * status_open(const char *filename, const int refresh_freq, const int msglevel, const struct virtual_output *vout, const unsigned int flags)
bool status_close(struct status_output *so)
A singly-linked list of buffers, with head/tail pointers for O(1) push.
size_t size
Current number of entries.
Wrapper structure for dynamically allocated memory.
int capacity
Size in bytes of memory allocated by malloc().
uint8_t * data
Pointer to the allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
struct tuntap * tuntap
Tun/tap virtual network interface.
Level 2 context containing state that is reset on both SIGHUP and SIGUSR1 restarts.
counter_type link_read_bytes
counter_type link_write_bytes
counter_type dco_read_bytes
struct man_def_auth_context mda_context
counter_type dco_write_bytes
Contains all state information for one tunnel.
struct context_2 c2
Level 2 context.
struct options options
Options loaded from command line or configuration file.
struct context_1 c1
Level 1 context.
Garbage collection arena used to keep track of dynamically allocated memory.
struct openvpn_sockaddr dest
struct in6_addr local_ip6
struct openvpn_sockaddr local_sock
struct openvpn_sockaddr remote_sock
unsigned long in_extra_cid
const char * up_query_type
struct user_pass up_query
socket_descriptor_t sd_top
struct buffer_list * ext_cert_input
unsigned int in_extra_kid
struct openvpn_sockaddr remote
socket_descriptor_t sd_cli
struct buffer_list * ext_key_input
int bytecount_update_seconds
struct buffer_list * in_extra
struct event_timeout bytecount_update_interval
struct net_event_win32 ne32
struct log_history * state
struct management_callback callback
struct virtual_output vout
struct log_history * echo
const char * special_state_msg
bool management_over_tunnel
bool(* client_acc_msg)(void *arg, const unsigned long cid, const unsigned int mda_key_id, struct buffer_list *msg)
char *(* get_peer_info)(void *arg, const unsigned long cid)
bool(* client_auth)(void *arg, const unsigned long cid, const unsigned int mda_key_id, const bool auth, const char *reason, const char *client_reason, struct buffer_list *cc_config)
int(* kill_by_addr)(void *arg, const in_addr_t addr, const uint16_t port, const uint8_t proto)
void(* delete_event)(void *arg, event_t event)
bool(* push_update_broadcast)(void *arg, const char *options)
bool(* push_update_by_cid)(void *arg, unsigned long cid, const char *options)
bool(* acc_msg)(void *arg, struct buffer_list *msg)
bool(* client_pending_auth)(void *arg, const unsigned long cid, const unsigned int kid, const char *extra, unsigned int timeout)
int(* n_clients)(void *arg)
void(* status)(void *arg, const int version, struct status_output *so)
bool(* remote_entry_get)(void *arg, unsigned int index, char **remote)
unsigned int(* remote_entry_count)(void *arg)
bool(* send_cc_message)(void *arg, const char *message, const char *parameter)
bool(* proxy_cmd)(void *arg, const char **p)
void(* show_net)(void *arg, const msglvl_t msglevel)
bool(* remote_cmd)(void *arg, const char **p)
int(* kill_by_cn)(void *arg, const char *common_name)
bool(* kill_by_cid)(void *arg, const unsigned long cid, const char *kill_msg)
struct man_persist persist
struct man_connection connection
struct man_settings settings
Main OpenVPN server state structure.
struct hash * hash
VPN tunnel instances indexed by real address of the remote peer.
struct context top
Storage structure for process-wide configuration.
Server-mode state structure for one single VPN tunnel.
struct context context
The context structure storing state for this VPN tunnel.
union openvpn_sockaddr::@051240265251124304325377241125360350250341115171 addr
Security parameter state for a single VPN tunnel.
char * acc_negotiated_protocols
the protocols that are negotiated with the peer.
Security parameter state of a single session within a VPN tunnel.
char password[USER_PASS_LEN]
char username[USER_PASS_LEN]
unsigned int flags_default
void(* func)(void *arg, const unsigned int flags, const char *str)
SOCKET socket_descriptor_t
static int socket_defined(const socket_descriptor_t sd)
void net_event_win32_init(struct net_event_win32 *ne)
void net_event_win32_close(struct net_event_win32 *ne)
void net_event_win32_reset_write(struct net_event_win32 *ne)
void net_event_win32_start(struct net_event_win32 *ne, long network_events, socket_descriptor_t sd)
void win32_sleep(const int n)
void net_event_win32_reset(struct net_event_win32 *ne)
void net_event_win32_stop(struct net_event_win32 *ne)
static long net_event_win32_get_event_mask(const struct net_event_win32 *ne)
static void net_event_win32_clear_selected_events(struct net_event_win32 *ne, long selected_events)
static struct rw_handle * net_event_win32_get_event(struct net_event_win32 *ne)