OpenVPN
|
#include "service.h"
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <userenv.h>
#include <accctrl.h>
#include <aclapi.h>
#include <stdio.h>
#include <sddl.h>
#include <shellapi.h>
#include <mstcpip.h>
#include <inttypes.h>
#include <versionhelpers.h>
#include "openvpn-msg.h"
#include "validate.h"
#include "wfp_block.h"
Go to the source code of this file.
Data Structures | |
struct | STARTUP_DATA |
struct | _list_item |
struct | wfp_block_data_t |
struct | dns_domains_undo_data_t |
union | pipe_message_t |
struct | nrpt_exclude_data_t |
Macros | |
#define | IO_TIMEOUT 2000 /*ms*/ |
#define | ERROR_OPENVPN_STARTUP 0x20000000 |
#define | ERROR_STARTUP_DATA 0x20000001 |
#define | ERROR_MESSAGE_DATA 0x20000002 |
#define | ERROR_MESSAGE_TYPE 0x20000003 |
#define | RDNS_TIMEOUT 600 /* seconds to wait for the semaphore */ |
#define | TUN_IOCTL_REGISTER_RINGS CTL_CODE(51820U, 0x970U, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA) |
Typedefs | |
typedef struct _list_item | list_item_t |
typedef list_item_t * | undo_lists_t[_undo_type_max] |
typedef BOOL(* | match_fn_t) (LPVOID item, LPVOID ctx) |
Enumerations | |
enum | undo_type_t { address , route , wfp_block , undo_dns4 , undo_dns6 , undo_nrpt , undo_domains , undo_wins , _undo_type_max } |
enum | async_op_t { peek , read , write } |
Functions | |
static DWORD | AddListItem (list_item_t **pfirst, LPVOID data) |
static LPVOID | RemoveListItem (list_item_t **pfirst, match_fn_t match, LPVOID ctx) |
static HANDLE | CloseHandleEx (LPHANDLE handle) |
static HANDLE | InitOverlapped (LPOVERLAPPED overlapped) |
static BOOL | ResetOverlapped (LPOVERLAPPED overlapped) |
static DWORD | AsyncPipeOp (async_op_t op, HANDLE pipe, LPVOID buffer, DWORD size, DWORD count, LPHANDLE events) |
static DWORD | PeekNamedPipeAsync (HANDLE pipe, DWORD count, LPHANDLE events) |
static DWORD | ReadPipeAsync (HANDLE pipe, LPVOID buffer, DWORD size, DWORD count, LPHANDLE events) |
static DWORD | WritePipeAsync (HANDLE pipe, LPVOID data, DWORD size, DWORD count, LPHANDLE events) |
static VOID | ReturnProcessId (HANDLE pipe, DWORD pid, DWORD count, LPHANDLE events) |
static VOID | ReturnError (HANDLE pipe, DWORD error, LPCWSTR func, DWORD count, LPHANDLE events) |
static VOID | ReturnLastError (HANDLE pipe, LPCWSTR func) |
static BOOL | ValidateOptions (HANDLE pipe, const WCHAR *workdir, const WCHAR *options, WCHAR *errmsg, DWORD capacity) |
static BOOL | GetStartupData (HANDLE pipe, STARTUP_DATA *sud) |
static VOID | FreeStartupData (STARTUP_DATA *sud) |
static SOCKADDR_INET | sockaddr_inet (short family, inet_address_t *addr) |
static DWORD | InterfaceLuid (const char *iface_name, PNET_LUID luid) |
static BOOL | CmpAddress (LPVOID item, LPVOID address) |
static DWORD | DeleteAddress (PMIB_UNICASTIPADDRESS_ROW addr_row) |
static DWORD | HandleAddressMessage (address_message_t *msg, undo_lists_t *lists) |
static BOOL | CmpRoute (LPVOID item, LPVOID route) |
static DWORD | DeleteRoute (PMIB_IPFORWARD_ROW2 fwd_row) |
static DWORD | HandleRouteMessage (route_message_t *msg, undo_lists_t *lists) |
static DWORD | HandleFlushNeighborsMessage (flush_neighbors_message_t *msg) |
static void | BlockDNSErrHandler (DWORD err, const char *msg) |
static BOOL | CmpAny (LPVOID item, LPVOID any) |
static DWORD | DeleteWfpBlock (const wfp_block_message_t *msg, undo_lists_t *lists) |
static DWORD | AddWfpBlock (const wfp_block_message_t *msg, undo_lists_t *lists) |
static DWORD | HandleWfpBlockMessage (const wfp_block_message_t *msg, undo_lists_t *lists) |
static DWORD | ExecCommand (const WCHAR *argv0, const WCHAR *cmdline, DWORD timeout) |
static DWORD WINAPI | RegisterDNS (LPVOID unused) |
static DWORD | HandleRegisterDNSMessage (void) |
static DWORD | netsh_wins_cmd (const wchar_t *action, const wchar_t *if_name, const wchar_t *addr) |
Run the command: netsh interface ip $action wins $if_name [static] $addr. | |
static BOOL | CmpWString (LPVOID item, LPVOID str) |
static BOOL | ApplyGpolSettings32 (void) |
Signal the DNS resolver (and others potentially) to reload the group policy (DNS) settings on 32 bit Windows systems. | |
static BOOL | ApplyGpolSettings64 (void) |
Signal the DNS resolver (and others potentially) to reload the group policy (DNS) settings on 64 bit Windows systems. | |
static BOOL | ApplyGpolSettings (void) |
Signal the DNS resolver (and others potentially) to reload the group policy (DNS) settings. | |
static BOOL | ApplyDnsSettings (BOOL apply_gpol) |
Signal the DNS resolver to reload its settings. | |
static DWORD | InterfaceIdString (PCSTR itf_name, PWSTR str, size_t len) |
Get the string interface UUID (with braces) for an interface alias name. | |
static BOOL | HasValidSearchList (HKEY key) |
Check for a valid search list in a certain key of the registry. | |
static BOOL | GetDnsSearchListKey (PCSTR itf_name, PBOOL gpol, PHKEY key) |
Find the registry key for storing the DNS domains for the VPN interface. | |
static BOOL | InitialSearchListExists (HKEY key) |
Check if a initial list had already been created. | |
static BOOL | StoreInitialDnsSearchList (HKEY key, PCWSTR list) |
Prepare DNS domain "SearchList" registry value, so additional VPN domains can be added and its original state can be restored in case the system cannot clean up regularly. | |
static BOOL | AddDnsSearchDomains (HKEY key, BOOL have_list, PCWSTR domains) |
Append domain suffixes to an existing search list. | |
static BOOL | ResetDnsSearchDomains (HKEY key) |
Reset the DNS search list to its original value. | |
static void | RemoveDnsSearchDomains (HKEY key, PCWSTR domains) |
Remove domain suffixes from an existing search list. | |
static void | UndoDnsSearchDomains (dns_domains_undo_data_t *undo_data) |
Removes DNS domains from a search list they were previously added to. | |
static DWORD | SetDnsSearchDomains (PCSTR itf_name, PCSTR domains, PBOOL gpol, undo_lists_t *lists) |
Add or remove DNS search domains. | |
static BOOL | GetInterfacesKey (short family, PHKEY key) |
Return the interfaces registry key for the specified address family. | |
static DWORD | SetNameServersValue (PCWSTR itf_id, short family, PCSTR value) |
Set the DNS name servers in a registry interface configuration. | |
static DWORD | SetNameServers (PCWSTR itf_id, short family, PCSTR addrs) |
Set the DNS name servers in a registry interface configuration. | |
static DWORD | ResetNameServers (PCWSTR itf_id, short family) |
Delete all DNS name servers from a registry interface configuration. | |
static DWORD | HandleDNSConfigMessage (const dns_cfg_message_t *msg, undo_lists_t *lists) |
static BOOL | IsDhcpEnabled (HKEY key) |
Checks if DHCP is enabled for an interface. | |
static LSTATUS | SetNameServerAddresses (PWSTR itf_id, const nrpt_address_t *addresses) |
Set name servers from a NRPT address list. | |
static LSTATUS | GetItfDnsServersV4 (HKEY itf_key, PSTR addrs, PDWORD size) |
Get DNS server IPv4 addresses of an interface. | |
static LSTATUS | GetItfDnsServersV6 (HKEY itf_key, PSTR addrs, PDWORD size) |
Get DNS server IPv6 addresses of an interface. | |
static BOOL | ListContainsDomain (PCWSTR list, PCWSTR domain, size_t len) |
Check if a domain is contained in a comma separated list of domains. | |
static LSTATUS | GetItfDnsDomains (HKEY itf, PCWSTR search_domains, PWSTR domains, PDWORD size) |
Return interface specific domain suffix(es) | |
static BOOL | IsInterfaceConnected (PWSTR iid_str) |
Check if an interface is connected and up. | |
static void | GetNrptExcludeData (PCWSTR search_domains, nrpt_exclude_data_t *data, size_t data_size) |
Collect interface DNS settings to be used in excluding NRPT rules. | |
static DWORD | SetNrptRule (HKEY nrpt_key, PCWSTR subkey, PCSTR address, PCWSTR domains, DWORD dom_size, BOOL dnssec) |
Set a NRPT rule (subkey) and its values in the registry. | |
static void | SetNrptExcludeRules (HKEY nrpt_key, DWORD ovpn_pid, PCWSTR search_domains) |
Set NRPT exclude rules to accompany a catch all rule. | |
static DWORD | SetNrptRules (HKEY nrpt_key, const nrpt_address_t *addresses, const char *domains, const char *search_domains, BOOL dnssec, DWORD ovpn_pid) |
Set NRPT rules for a openvpn process. | |
static LSTATUS | OpenNrptBaseKey (PHKEY key, PBOOL gpol) |
Return the registry key where NRPT rules are stored. | |
static BOOL | DeleteNrptRules (DWORD pid, PBOOL gpol) |
Delete OpenVPN NRPT rules from the registry. | |
static void | UndoNrptRules (DWORD ovpn_pid) |
Delete a process' NRPT rules and apply the reduced set of rules. | |
static DWORD | HandleDNSConfigNrptMessage (const nrpt_dns_cfg_message_t *msg, DWORD ovpn_pid, undo_lists_t *lists) |
Add Name Resolution Policy Table (NRPT) rules as documented in https://msdn.microsoft.com/en-us/library/ff957356.aspx for DNS name resolution, as well as DNS search domain(s), if given. | |
static DWORD | HandleWINSConfigMessage (const wins_cfg_message_t *msg, undo_lists_t *lists) |
static DWORD | HandleEnableDHCPMessage (const enable_dhcp_message_t *dhcp) |
static DWORD | HandleMTUMessage (const set_mtu_message_t *mtu) |
static DWORD | HandleCreateAdapterMessage (const create_adapter_message_t *msg) |
Creates a VPN adapter of the specified type by invoking tapctl.exe. | |
static VOID | HandleMessage (HANDLE pipe, PPROCESS_INFORMATION proc_info, DWORD bytes, DWORD count, LPHANDLE events, undo_lists_t *lists) |
static VOID | Undo (undo_lists_t *lists) |
static DWORD WINAPI | RunOpenvpn (LPVOID p) |
static DWORD WINAPI | ServiceCtrlInteractive (DWORD ctrl_code, DWORD event, LPVOID data, LPVOID ctx) |
static HANDLE | CreateClientPipeInstance (VOID) |
static DWORD | UpdateWaitHandles (LPHANDLE *handles_ptr, LPDWORD count, HANDLE io_event, HANDLE exit_event, list_item_t *threads) |
static VOID | FreeWaitHandles (LPHANDLE h) |
static BOOL | CmpHandle (LPVOID item, LPVOID hnd) |
VOID WINAPI | ServiceStartInteractiveOwn (DWORD dwArgc, LPWSTR *lpszArgv) |
static void | CleanupRegistry (void) |
Clean up remains of previous sessions in registry. | |
VOID WINAPI | ServiceStartInteractive (DWORD dwArgc, LPWSTR *lpszArgv) |
Variables | |
static SERVICE_STATUS_HANDLE | service |
static SERVICE_STATUS | status = { .dwServiceType = SERVICE_WIN32_SHARE_PROCESS } |
static HANDLE | exit_event = NULL |
static settings_t | settings |
static HANDLE | rdns_semaphore = NULL |
openvpn_service_t | interactive_service |
#define ERROR_MESSAGE_DATA 0x20000002 |
Definition at line 48 of file interactive.c.
#define ERROR_MESSAGE_TYPE 0x20000003 |
Definition at line 49 of file interactive.c.
#define ERROR_OPENVPN_STARTUP 0x20000000 |
Definition at line 46 of file interactive.c.
#define ERROR_STARTUP_DATA 0x20000001 |
Definition at line 47 of file interactive.c.
#define IO_TIMEOUT 2000 /*ms*/ |
Definition at line 44 of file interactive.c.
#define RDNS_TIMEOUT 600 /* seconds to wait for the semaphore */ |
Definition at line 56 of file interactive.c.
#define TUN_IOCTL_REGISTER_RINGS CTL_CODE(51820U, 0x970U, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA) |
Definition at line 58 of file interactive.c.
typedef struct _list_item list_item_t |
typedef BOOL(* match_fn_t) (LPVOID item, LPVOID ctx) |
Definition at line 146 of file interactive.c.
typedef list_item_t* undo_lists_t[_undo_type_max] |
Definition at line 95 of file interactive.c.
enum async_op_t |
Enumerator | |
---|---|
peek | |
read | |
write |
Definition at line 205 of file interactive.c.
enum undo_type_t |
Enumerator | |
---|---|
address | |
route | |
wfp_block | |
undo_dns4 | |
undo_dns6 | |
undo_nrpt | |
undo_domains | |
undo_wins | |
_undo_type_max |
Definition at line 84 of file interactive.c.
|
static |
Append domain suffixes to an existing search list.
key | HKEY the list is stored at |
have_list | BOOL to indicate if a search list already exists |
domains | domain suffixes as comma separated string |
Definition at line 1458 of file interactive.c.
References M_SYSERR, MsgToEventLog(), pos(), and StoreInitialDnsSearchList().
Referenced by SetDnsSearchDomains().
|
static |
Definition at line 131 of file interactive.c.
References _list_item::data, and _list_item::next.
Referenced by AddWfpBlock(), HandleAddressMessage(), HandleDNSConfigMessage(), HandleDNSConfigNrptMessage(), HandleRouteMessage(), HandleWINSConfigMessage(), ServiceStartInteractive(), and SetDnsSearchDomains().
|
static |
Definition at line 790 of file interactive.c.
References add_wfp_block_filters(), AddListItem(), BlockDNSErrHandler(), delete_wfp_block_filters(), DeleteWfpBlock(), wfp_block_data_t::engine, settings_t::exe_path, get_interface_metric(), wfp_block_data_t::index, wfp_block_data_t::metric_v4, wfp_block_data_t::metric_v6, msg, set_interface_metric(), settings, wfp_block, wfp_block_dns, and WFP_BLOCK_IFACE_METRIC.
Referenced by HandleWfpBlockMessage().
|
static |
Signal the DNS resolver to reload its settings.
apply_gpol | BOOL reload setting from group policy hives as well |
Definition at line 1173 of file interactive.c.
References ApplyGpolSettings(), M_ERR, MsgToEventLog(), and status.
Referenced by CleanupRegistry(), HandleDNSConfigMessage(), HandleDNSConfigNrptMessage(), UndoDnsSearchDomains(), and UndoNrptRules().
|
static |
Signal the DNS resolver (and others potentially) to reload the group policy (DNS) settings.
Definition at line 1157 of file interactive.c.
References ApplyGpolSettings32(), and ApplyGpolSettings64().
Referenced by ApplyDnsSettings().
|
static |
Signal the DNS resolver (and others potentially) to reload the group policy (DNS) settings on 32 bit Windows systems.
Definition at line 1080 of file interactive.c.
Referenced by ApplyGpolSettings().
|
static |
Signal the DNS resolver (and others potentially) to reload the group policy (DNS) settings on 64 bit Windows systems.
Definition at line 1120 of file interactive.c.
Referenced by ApplyGpolSettings().
|
static |
Definition at line 212 of file interactive.c.
References CloseHandleEx(), InitOverlapped(), IO_TIMEOUT, peek, and write.
Referenced by PeekNamedPipeAsync(), ReadPipeAsync(), and WritePipeAsync().
|
static |
Definition at line 731 of file interactive.c.
References M_ERR, msg, and MsgToEventLog().
Referenced by AddWfpBlock().
|
static |
Clean up remains of previous sessions in registry.
These remains can happen with unclean shutdowns or crashes and would interfere with normal operation of the system with and without active tunnels.
Definition at line 3729 of file interactive.c.
References ApplyDnsSettings(), DeleteNrptRules(), GetDnsSearchListKey(), and ResetDnsSearchDomains().
Referenced by ServiceStartInteractive().
|
static |
Definition at line 173 of file interactive.c.
Referenced by AsyncPipeOp(), RunOpenvpn(), and ServiceStartInteractive().
|
static |
Definition at line 558 of file interactive.c.
References address.
Referenced by HandleAddressMessage().
|
static |
Definition at line 755 of file interactive.c.
Referenced by DeleteWfpBlock(), HandleDNSConfigMessage(), HandleDNSConfigNrptMessage(), and SetDnsSearchDomains().
|
static |
Definition at line 3710 of file interactive.c.
Referenced by ServiceStartInteractive().
|
static |
|
static |
Definition at line 1068 of file interactive.c.
Referenced by HandleWINSConfigMessage().
|
static |
Definition at line 3603 of file interactive.c.
References _L, M_SYSERR, MsgToEventLog(), PACKAGE, and service_instance.
Referenced by ServiceStartInteractive().
|
static |
Definition at line 564 of file interactive.c.
Referenced by HandleAddressMessage(), and Undo().
|
static |
Delete OpenVPN NRPT rules from the registry.
If the pid parameter is 0 all NRPT rules added by OpenVPN are deleted. In all other cases only rules matching the pid are deleted.
pid | PID of the process to delete the rules for or 0 |
gpol |
Definition at line 2687 of file interactive.c.
References M_SYSERR, MsgToEventLog(), and OpenNrptBaseKey().
Referenced by CleanupRegistry(), HandleDNSConfigNrptMessage(), and UndoNrptRules().
|
static |
Definition at line 642 of file interactive.c.
Referenced by HandleRouteMessage(), and Undo().
|
static |
Definition at line 761 of file interactive.c.
References CmpAny(), delete_wfp_block_filters(), wfp_block_data_t::engine, M_ERR, wfp_block_data_t::metric_v4, wfp_block_data_t::metric_v6, msg, MsgToEventLog(), RemoveListItem(), set_interface_metric(), and wfp_block.
Referenced by AddWfpBlock(), and HandleWfpBlockMessage().
|
static |
Definition at line 879 of file interactive.c.
References M_ERR, M_INFO, M_SYSERR, and MsgToEventLog().
Referenced by HandleCreateAdapterMessage(), HandleEnableDHCPMessage(), netsh_wins_cmd(), and RegisterDNS().
|
static |
Definition at line 516 of file interactive.c.
References STARTUP_DATA::directory.
Referenced by RunOpenvpn().
|
static |
Definition at line 3704 of file interactive.c.
Referenced by ServiceStartInteractive().
|
static |
Find the registry key for storing the DNS domains for the VPN interface.
itf_name | PCSTR that contains the alias name of the interface the domains are related to. If this is NULL the interface probing is skipped. |
gpol | PBOOL to indicate if the key returned is the group policy hive |
key | PHKEY in which the found registry key is returned in |
The correct location to add them is where a non-empty "SearchList" value exists, or in the interface configuration itself. However, the system-wide and then the group policy search lists overrule the previous one respectively, so we need to probe to find the effective list.
Definition at line 1325 of file interactive.c.
References HasValidSearchList(), and InterfaceIdString().
Referenced by CleanupRegistry(), SetDnsSearchDomains(), and UndoDnsSearchDomains().
|
static |
Return the interfaces registry key for the specified address family.
family | the internet address family to open the key for |
key | PHKEY to return the key in |
Definition at line 1733 of file interactive.c.
References M_SYSERR, and MsgToEventLog().
Referenced by GetNrptExcludeData(), and SetNameServersValue().
|
static |
Return interface specific domain suffix(es)
The domains
paramter will be set to a MULTI_SZ domains string. In case of an error or if no domains are found for the interface size
is set to 0 and the contents of domains
are invalid. Note that the domains could have been set by DHCP or manually. Note that domains are ignored if they match a pushed search domain.
itf | HKEY of the interface to read from |
search_domains | optional list of search domains |
domains | PWSTR buffer to return the domain(s) in |
size | pointer to size of the domains buffer in bytes. Will be set to the size of the string returned, including the terminating zeros or 0. |
Definition at line 2182 of file interactive.c.
References buf_len(), ListContainsDomain(), and pos().
Referenced by GetNrptExcludeData().
|
static |
Get DNS server IPv4 addresses of an interface.
itf_key | registry key of the IPv4 interface data |
addrs | pointer to the buffer addresses are returned in |
size | pointer to the size of the buffer, contains the size of the addresses on return |
Definition at line 2021 of file interactive.c.
References IsDhcpEnabled().
Referenced by GetNrptExcludeData().
|
static |
Get DNS server IPv6 addresses of an interface.
itf_key | registry key of the IPv6 interface data |
addrs | pointer to the buffer addresses are returned in |
size | pointer to the size of the buffer |
Definition at line 2066 of file interactive.c.
References IsDhcpEnabled(), and pos().
Referenced by GetNrptExcludeData().
|
static |
Collect interface DNS settings to be used in excluding NRPT rules.
This is needed so that local DNS keeps working even when a catch all NRPT rule is installed by a VPN connection.
search_domains | optional list of search domains |
data | pointer to the data structures the values are returned in |
data_size | number of exclude data structures pointed to |
Definition at line 2325 of file interactive.c.
References nrpt_exclude_data_t::addresses, nrpt_exclude_data_t::domains, nrpt_exclude_data_t::domains_size, GetInterfacesKey(), GetItfDnsDomains(), GetItfDnsServersV4(), GetItfDnsServersV6(), IsInterfaceConnected(), M_SYSERR, MsgToEventLog(), and NRPT_ADDR_SIZE.
Referenced by SetNrptExcludeRules().
|
static |
Definition at line 440 of file interactive.c.
References STARTUP_DATA::directory, ERROR_STARTUP_DATA, exit_event, M_ERR, M_SYSERR, MsgToEventLog(), STARTUP_DATA::options, PeekNamedPipeAsync(), read, ReadPipeAsync(), ReturnError(), ReturnLastError(), and STARTUP_DATA::std_input.
Referenced by RunOpenvpn().
|
static |
Definition at line 570 of file interactive.c.
References AddListItem(), address, CmpAddress(), DeleteAddress(), InterfaceLuid(), msg, msg_add_address, RemoveListItem(), and sockaddr_inet().
Referenced by HandleMessage().
|
static |
Creates a VPN adapter of the specified type by invoking tapctl.exe.
msg | Adapter creation request specifying the type. |
Definition at line 3042 of file interactive.c.
References ADAPTER_TYPE_DCO, ADAPTER_TYPE_TAP, settings_t::bin_dir, ExecCommand(), msg, and settings.
Referenced by HandleMessage().
|
static |
Definition at line 1828 of file interactive.c.
References AddListItem(), ApplyDnsSettings(), CmpAny(), dns_cfg_message_t::domains, ERROR_MESSAGE_DATA, dns_cfg_message_t::iface, InterfaceIdString(), msg, msg_del_dns_cfg, interface_t::name, RemoveListItem(), ResetNameServers(), SetDnsSearchDomains(), SetNameServers(), undo_dns4, and undo_dns6.
Referenced by HandleMessage().
|
static |
Add Name Resolution Policy Table (NRPT) rules as documented in https://msdn.microsoft.com/en-us/library/ff957356.aspx for DNS name resolution, as well as DNS search domain(s), if given.
msg | config messages sent by the openvpn process |
ovpn_pid | process id of the sending openvpn process |
lists | undo lists for this process |
Definition at line 2767 of file interactive.c.
References AddListItem(), nrpt_dns_cfg_message_t::addresses, ApplyDnsSettings(), CmpAny(), DeleteNrptRules(), ERROR_MESSAGE_DATA, nrpt_dns_cfg_message_t::iface, InterfaceIdString(), M_INFO, msg, msg_add_nrpt_cfg, msg_del_nrpt_cfg, MsgToEventLog(), interface_t::name, NRPT_ADDR_NUM, nrpt_dnssec, OpenNrptBaseKey(), RemoveListItem(), ResetNameServers(), nrpt_dns_cfg_message_t::resolve_domains, nrpt_dns_cfg_message_t::search_domains, SetDnsSearchDomains(), SetNameServerAddresses(), SetNrptRules(), and undo_nrpt.
Referenced by HandleMessage().
|
static |
Definition at line 2974 of file interactive.c.
References ExecCommand(), and get_win_sys_path().
Referenced by HandleMessage().
|
static |
|
static |
Definition at line 3077 of file interactive.c.
References ERROR_MESSAGE_DATA, ERROR_MESSAGE_TYPE, ack_message_t::error_number, HandleAddressMessage(), HandleCreateAdapterMessage(), HandleDNSConfigMessage(), HandleDNSConfigNrptMessage(), HandleEnableDHCPMessage(), HandleFlushNeighborsMessage(), HandleMTUMessage(), HandleRegisterDNSMessage(), HandleRouteMessage(), HandleWfpBlockMessage(), HandleWINSConfigMessage(), ack_message_t::header, message_header_t::message_id, msg, msg_acknowledgement, msg_add_address, msg_add_dns_cfg, msg_add_nrpt_cfg, msg_add_route, msg_add_wfp_block, msg_add_wins_cfg, msg_create_adapter, msg_del_address, msg_del_dns_cfg, msg_del_nrpt_cfg, msg_del_route, msg_del_wfp_block, msg_del_wins_cfg, msg_enable_dhcp, MSG_FLAGS_ERROR, msg_flush_neighbors, msg_register_dns, msg_set_mtu, MsgToEventLog(), read, ReadPipeAsync(), message_header_t::type, and WritePipeAsync().
Referenced by RunOpenvpn().
|
static |
Definition at line 3012 of file interactive.c.
References set_mtu_message_t::family, set_mtu_message_t::iface, interface_t::index, and set_mtu_message_t::mtu.
Referenced by HandleMessage().
|
static |
Definition at line 985 of file interactive.c.
References RegisterDNS().
Referenced by HandleMessage().
|
static |
Definition at line 648 of file interactive.c.
References AddListItem(), CmpRoute(), DeleteRoute(), InterfaceLuid(), msg, msg_add_route, RemoveListItem(), route, and sockaddr_inet().
Referenced by HandleMessage().
|
static |
Definition at line 861 of file interactive.c.
References AddWfpBlock(), DeleteWfpBlock(), msg, and msg_add_wfp_block.
Referenced by HandleMessage().
|
static |
Definition at line 2894 of file interactive.c.
References AddListItem(), CmpWString(), ERROR_MESSAGE_DATA, wins_cfg_message_t::iface, msg, msg_del_wins_cfg, interface_t::name, netsh_wins_cmd(), RemoveListItem(), undo_wins, and utf8to16().
Referenced by HandleMessage().
|
static |
Check for a valid search list in a certain key of the registry.
Valid means that a string value "SearchList" exists and that it contains one or more domains. We only check if the string contains a valid domain name character, but the main point is to prevent letting pass whitespace-only lists, so that check is good enough for that purpose.
key | HKEY in which to check for a valid search list |
Definition at line 1288 of file interactive.c.
Referenced by GetDnsSearchListKey().
|
static |
Check if a initial list had already been created.
key | HKEY of the registry subkey to search in |
Definition at line 1393 of file interactive.c.
References M_ERR, and MsgToEventLog().
Referenced by StoreInitialDnsSearchList().
|
static |
Definition at line 184 of file interactive.c.
Referenced by AsyncPipeOp(), and ServiceStartInteractive().
|
static |
Get the string interface UUID (with braces) for an interface alias name.
itf_name | the interface alias name |
str | pointer to the buffer the wide UUID is returned in |
len | size of the str buffer in characters |
Definition at line 1232 of file interactive.c.
References InterfaceLuid(), M_ERR, and MsgToEventLog().
Referenced by GetDnsSearchListKey(), HandleDNSConfigMessage(), and HandleDNSConfigNrptMessage().
|
static |
Definition at line 540 of file interactive.c.
References status, and utf8to16().
Referenced by HandleAddressMessage(), HandleRouteMessage(), and InterfaceIdString().
|
static |
Checks if DHCP is enabled for an interface.
key | HKEY of the interface to check for |
Definition at line 1943 of file interactive.c.
References M_SYSERR, and MsgToEventLog().
Referenced by GetItfDnsServersV4(), and GetItfDnsServersV6().
|
static |
Check if an interface is connected and up.
iid_str | the interface GUID as string |
Definition at line 2279 of file interactive.c.
References M_SYSERR, and MsgToEventLog().
Referenced by GetNrptExcludeData().
|
static |
Check if a domain is contained in a comma separated list of domains.
list | Comma separated list of domains |
domain | Domain string to search for |
len | Length of the domain string, excluding the '\0' |
Definition at line 2138 of file interactive.c.
Referenced by GetItfDnsDomains().
|
static |
Run the command: netsh interface ip $action wins $if_name [static] $addr.
action | "delete", "add" or "set" |
if_name | "name_of_interface" |
addr | IPv4 address as a string |
If addr is null and action = "delete" all addresses are deleted. if action = "set" then "static" is added before $addr
Definition at line 1020 of file interactive.c.
References ExecCommand(), and get_win_sys_path().
Referenced by HandleWINSConfigMessage(), and Undo().
|
static |
Return the registry key where NRPT rules are stored.
key | pointer to the HKEY it is returned in |
gpol | pointer to BOOL the use of GPOL hive is returned in |
Definition at line 2648 of file interactive.c.
Referenced by DeleteNrptRules(), and HandleDNSConfigNrptMessage().
|
static |
Definition at line 276 of file interactive.c.
References AsyncPipeOp(), and peek.
Referenced by GetStartupData(), and RunOpenvpn().
|
static |
Definition at line 282 of file interactive.c.
References AsyncPipeOp(), and read.
Referenced by GetStartupData(), and HandleMessage().
|
static |
Definition at line 940 of file interactive.c.
References ExecCommand(), exit_event, get_win_sys_path(), M_ERR, M_SYSERR, MsgToEventLog(), rdns_semaphore, and RDNS_TIMEOUT.
Referenced by HandleRegisterDNSMessage().
|
static |
Remove domain suffixes from an existing search list.
key | HKEY the list is stored at |
domains | domain suffixes to remove as comma separated string |
Definition at line 1563 of file interactive.c.
References M_ERR, M_SYSERR, MsgToEventLog(), and ResetDnsSearchDomains().
Referenced by SetDnsSearchDomains(), and UndoDnsSearchDomains().
|
static |
Definition at line 149 of file interactive.c.
References _list_item::data, and _list_item::next.
Referenced by DeleteWfpBlock(), HandleAddressMessage(), HandleDNSConfigMessage(), HandleDNSConfigNrptMessage(), HandleRouteMessage(), HandleWINSConfigMessage(), ServiceStartInteractive(), and SetDnsSearchDomains().
|
static |
Reset the DNS search list to its original value.
Looks for a "InitialSearchList" value as the one to reset to. If it doesn't exist, doesn't reset anything, as there was no SearchList in the first place.
key | HKEY of the location in the registry to reset |
Definition at line 1522 of file interactive.c.
References M_SYSERR, and MsgToEventLog().
Referenced by CleanupRegistry(), and RemoveDnsSearchDomains().
|
static |
Delete all DNS name servers from a registry interface configuration.
itf_id | the interface id to clear the servers for |
family | internet address family to clear the servers for |
Definition at line 1822 of file interactive.c.
References SetNameServersValue().
Referenced by HandleDNSConfigMessage(), HandleDNSConfigNrptMessage(), and Undo().
|
static |
Definition at line 192 of file interactive.c.
Referenced by ServiceStartInteractive().
|
static |
Definition at line 309 of file interactive.c.
References ERROR_OPENVPN_STARTUP, MSG_FLAGS_ERROR, MsgToEventLog(), and WritePipeAsync().
Referenced by GetStartupData(), ReturnLastError(), RunOpenvpn(), and ServiceStartInteractive().
|
static |
Definition at line 348 of file interactive.c.
References exit_event, and ReturnError().
Referenced by GetStartupData(), and RunOpenvpn().
|
static |
Definition at line 294 of file interactive.c.
References msg, and WritePipeAsync().
Referenced by RunOpenvpn().
|
static |
Definition at line 3255 of file interactive.c.
References _L, CloseHandleEx(), STARTUP_DATA::directory, ERROR_OPENVPN_STARTUP, ERROR_STARTUP_DATA, settings_t::exe_path, exit_event, FreeStartupData(), GetStartupData(), HandleMessage(), IO_TIMEOUT, IsAuthorizedUser(), MSG_FLAGS_ERROR, MsgToEventLog(), STARTUP_DATA::options, settings_t::ovpn_admin_group, settings_t::ovpn_service_user, PACKAGE, PeekNamedPipeAsync(), settings_t::priority, ReturnError(), ReturnLastError(), ReturnProcessId(), service_instance, settings, STARTUP_DATA::std_input, Undo(), and ValidateOptions().
Referenced by ServiceStartInteractive().
|
static |
Definition at line 3579 of file interactive.c.
References exit_event, ReportStatusToSCMgr(), service, and status.
Referenced by ServiceStartInteractive().
VOID WINAPI ServiceStartInteractive | ( | DWORD | dwArgc, |
LPWSTR * | lpszArgv | ||
) |
Definition at line 3757 of file interactive.c.
References AddListItem(), CleanupRegistry(), CloseHandleEx(), CmpHandle(), CreateClientPipeInstance(), exit_event, FreeWaitHandles(), GetOpenvpnSettings(), InitOverlapped(), interactive_service, M_SYSERR, MsgToEventLog(), openvpn_service_t::name, rdns_semaphore, RemoveListItem(), ReportStatusToSCMgr(), ResetOverlapped(), ReturnError(), RunOpenvpn(), service, ServiceCtrlInteractive(), settings, status, and UpdateWaitHandles().
Referenced by ServiceStartInteractiveOwn(), and wmain().
VOID WINAPI ServiceStartInteractiveOwn | ( | DWORD | dwArgc, |
LPWSTR * | lpszArgv | ||
) |
Definition at line 3717 of file interactive.c.
References ServiceStartInteractive(), and status.
Referenced by wmain().
|
static |
Add or remove DNS search domains.
itf_name | alias name of the interface the domains are set for |
domains | a comma separated list of domain name suffixes |
gpol | PBOOL to indicate if group policy values were modified |
lists | pointer to the undo lists |
If a SearchList is present in the registry already, the domains are added to that list. Otherwise the domains are added to the VPN interface specific list. A group policy search list takes precedence over a system-wide list, and that one itself takes precedence over interface specific ones.
This function will remove previously set domains if the domains parameter is NULL or empty.
The gpol value is only valid if the function returns no error. In the error case nothing is changed.
Definition at line 1666 of file interactive.c.
References AddDnsSearchDomains(), AddListItem(), CmpAny(), dns_domains_undo_data_t::domains, GetDnsSearchListKey(), dns_domains_undo_data_t::itf_name, M_SYSERR, MsgToEventLog(), RemoveDnsSearchDomains(), RemoveListItem(), undo_domains, and utf8to16().
Referenced by HandleDNSConfigMessage(), and HandleDNSConfigNrptMessage().
|
static |
Set name servers from a NRPT address list.
itf_id | the VPN interface ID to set the name servers for |
addresses | the list of NRPT addresses |
Definition at line 1968 of file interactive.c.
References NRPT_ADDR_NUM, NRPT_ADDR_SIZE, and SetNameServers().
Referenced by HandleDNSConfigNrptMessage().
|
static |
Set the DNS name servers in a registry interface configuration.
itf_id | the interface id to set the servers for |
family | internet address family to set the servers for |
addrs | comma separated list of name server addresses |
Definition at line 1808 of file interactive.c.
References SetNameServersValue().
Referenced by HandleDNSConfigMessage(), and SetNameServerAddresses().
|
static |
Set the DNS name servers in a registry interface configuration.
itf_id | the interface id to set the servers for |
family | internet address family to set the servers for |
value | the value to set the name servers to |
Definition at line 1760 of file interactive.c.
References GetInterfacesKey(), M_SYSERR, and MsgToEventLog().
Referenced by ResetNameServers(), and SetNameServers().
|
static |
Set NRPT exclude rules to accompany a catch all rule.
This is done so that local resolution of names is not interfered with in case the VPN resolves all names.
nrpt_key | the registry key to set the rules under |
ovpn_pid | the PID of the openvpn process |
search_domains | optional list of search domains |
Definition at line 2532 of file interactive.c.
References nrpt_exclude_data_t::addresses, nrpt_exclude_data_t::domains, nrpt_exclude_data_t::domains_size, GetNrptExcludeData(), M_ERR, MsgToEventLog(), and SetNrptRule().
Referenced by SetNrptRules().
|
static |
Set a NRPT rule (subkey) and its values in the registry.
nrpt_key | NRPT registry key handle |
subkey | subkey string to create |
address | name server address string |
domains | domains to resolve by this server as MULTI_SZ |
dom_size | size of domains in bytes including the terminators |
dnssec | boolean to determine if DNSSEC is to be enabled |
Definition at line 2445 of file interactive.c.
References address.
Referenced by SetNrptExcludeRules(), and SetNrptRules().
|
static |
Set NRPT rules for a openvpn process.
nrpt_key | the registry key to set the rules under |
addresses | name server addresses |
domains | optional list of split routing domains |
search_domains | optional list of search domains |
dnssec | boolean whether DNSSEC is to be used |
ovpn_pid | the PID of the openvpn process |
Definition at line 2571 of file interactive.c.
References M_ERR, MsgToEventLog(), NRPT_ADDR_NUM, NRPT_ADDR_SIZE, pos(), SetNrptExcludeRules(), SetNrptRule(), utf8to16(), and utf8to16_size().
Referenced by HandleDNSConfigNrptMessage().
|
static |
Definition at line 523 of file interactive.c.
References inet_address_t::ipv4, and inet_address_t::ipv6.
Referenced by HandleAddressMessage(), and HandleRouteMessage().
|
static |
Prepare DNS domain "SearchList" registry value, so additional VPN domains can be added and its original state can be restored in case the system cannot clean up regularly.
key | registry subkey to store the list in |
list | string of comma separated domains to use as the list |
Definition at line 1422 of file interactive.c.
References InitialSearchListExists(), M_ERR, and MsgToEventLog().
Referenced by AddDnsSearchDomains().
|
static |
Definition at line 3186 of file interactive.c.
References _undo_type_max, address, _list_item::data, delete_wfp_block_filters(), DeleteAddress(), DeleteRoute(), wfp_block_data_t::engine, wfp_block_data_t::index, wfp_block_data_t::metric_v4, wfp_block_data_t::metric_v6, netsh_wins_cmd(), _list_item::next, ResetNameServers(), route, set_interface_metric(), undo_dns4, undo_dns6, undo_domains, undo_nrpt, undo_wins, UndoDnsSearchDomains(), UndoNrptRules(), and wfp_block.
Referenced by RunOpenvpn().
|
static |
Removes DNS domains from a search list they were previously added to.
undo_data | pointer to dns_domains_undo_data_t |
Definition at line 1628 of file interactive.c.
References ApplyDnsSettings(), dns_domains_undo_data_t::domains, GetDnsSearchListKey(), dns_domains_undo_data_t::itf_name, and RemoveDnsSearchDomains().
Referenced by Undo().
|
static |
Delete a process' NRPT rules and apply the reduced set of rules.
ovpn_pid | OpenVPN process id to delete rules for |
Definition at line 2746 of file interactive.c.
References ApplyDnsSettings(), and DeleteNrptRules().
Referenced by Undo().
|
static |
Definition at line 3654 of file interactive.c.
References _list_item::data, exit_event, _list_item::next, and pos().
Referenced by ServiceStartInteractive().
|
static |
Definition at line 359 of file interactive.c.
References CheckOption(), IsOption(), settings_t::ovpn_admin_group, and settings.
Referenced by RunOpenvpn().
|
static |
Definition at line 288 of file interactive.c.
References AsyncPipeOp(), and write.
Referenced by HandleMessage(), ReturnError(), and ReturnProcessId().
|
static |
Definition at line 53 of file interactive.c.
Referenced by GetStartupData(), RegisterDNS(), ReturnLastError(), RunOpenvpn(), ServiceCtrlInteractive(), ServiceStartInteractive(), and UpdateWaitHandles().
openvpn_service_t interactive_service |
Definition at line 60 of file interactive.c.
Referenced by ServiceStartInteractive(), and wmain().
|
static |
Definition at line 55 of file interactive.c.
Referenced by RegisterDNS(), and ServiceStartInteractive().
|
static |
Definition at line 51 of file interactive.c.
Referenced by CmdInstallServices(), CmdRemoveServices(), CmdStartService(), do_deferred_pam_auth(), pam_auth(), pam_server(), port_from_servname(), ReportStatusToSCMgr(), ServiceCtrlInteractive(), and ServiceStartInteractive().
|
static |
Definition at line 54 of file interactive.c.
Referenced by AddWfpBlock(), HandleCreateAdapterMessage(), RunOpenvpn(), ServiceStartInteractive(), and ValidateOptions().
|
static |
Definition at line 52 of file interactive.c.
Referenced by add_route(), add_route_ipapi(), add_route_ipv6(), ApplyDnsSettings(), bio_write_post(), check_for_client_reason(), check_status(), close_tun(), CmdRemoveServices(), dco_get_supported_ciphers(), del_route_ipapi(), delete_route(), delete_temp_addresses(), dhcp_release_by_adapter_index(), dhcp_renew_by_adapter_index(), do_open_tun(), do_preresolve(), do_preresolve_host(), do_route_ipv6_service(), establish_http_proxy_passthru(), exec_command(), fork_to_self(), get_adapter_info_list(), get_best_route(), get_console_input_win32(), get_default_gateway(), get_default_gateway_ipv6(), get_device_instance_id_interface(), get_interface_info_list(), get_openvpn_reg_value(), get_pa_var(), get_panel_reg(), get_per_adapter_info(), get_special_addr(), get_tap_reg(), get_windows_routing_table(), getaddr(), GetOpenvpnSettings(), GetRegString(), helper_client_server(), in_extra_dispatch(), in_src_get(), incoming_push_message(), init_route(), InterfaceLuid(), io_wait_dowork(), link_socket_write_win32(), man_block(), man_client_deny(), man_client_kill(), man_connect(), man_kill(), man_proxy(), man_remote(), man_send_cc_message(), man_settings_init(), man_standalone_event_loop(), management_callback_remote_entry_get(), management_callback_send_cc_message(), management_io(), multi_get_create_instance_udp(), multi_io_wait(), multi_process_io_udp(), net_event_win32_reset_write(), openvpn_connect(), openvpn_exit(), openvpn_getaddrinfo(), openvpn_gettimeofday(), openvpn_plugin_func_v1(), openvpn_plugin_open_v3(), openvpn_popen(), openvpn_waitpid_check(), pam_auth(), plugin_call_item(), plugin_call_ssl(), print_sockaddr_ex(), process_io(), read_incoming_link(), read_incoming_tls_ciphertext(), read_incoming_tls_plaintext(), recv_line(), recv_socks_reply(), report_command_status(), ReportStatusToSCMgr(), resolve_bind_local(), resolve_remote(), semaphore_lock(), send_push_options(), send_push_reply(), ServiceCtrlInteractive(), ServiceStartInteractive(), ServiceStartInteractiveOwn(), set_win_sys_path_via_env(), socket_connect(), socket_connection_reset(), socket_listen_accept(), socket_recv_queue(), socket_send_queue(), sockethandle_finalize(), socks_handshake(), socks_username_password_auth(), strerror_win32(), tap_allow_nonadmin_access_handle(), test_adapter_ip_netmask(), tls_pre_decrypt_lite(), tls_process_state(), tun_read_queue(), tun_write_queue(), tun_write_win32(), tunnel_server_loop(), tuntap_abort(), tuntap_is_dco_win_timeout(), tuntap_set_connected(), tuntap_set_ip_addr(), tuntap_set_ptp(), tuntap_stop(), we_wait(), win32_sleep(), win_get_exe_path(), win_wfp_block(), write_outgoing_tls_ciphertext(), and x_check_status().