DWORD index;
ULONG aindex;
wchar_t wbuf[256];
- openvpn_swprintf(wbuf, SIZE(wbuf), L"\\DEVICE\\TCPIP_%S", guid);
+ openvpn_swprintf(wbuf, SIZE(wbuf), L"\\DEVICE\\TCPIP_%hs", guid);
if (GetAdapterIndex(wbuf, &aindex) != NO_ERROR)
{
index = TUN_ADAPTER_INDEX_INVALID;
}
else
{
- msg(M_WARN|M_ERRNO, "openvpn_execve: GetExitCodeProcess %S failed", cmd);
+ msg(M_WARN|M_ERRNO, "openvpn_execve: GetExitCodeProcess %ls failed", cmd);
}
CloseHandle(proc_info.hProcess);
}
else
{
- msg(M_WARN|M_ERRNO, "openvpn_execve: CreateProcess %S failed", cmd);
+ msg(M_WARN|M_ERRNO, "openvpn_execve: CreateProcess %ls failed", cmd);
}
free(env);
gc_free(&gc);
if (status != ERROR_SUCCESS)
{
SetLastError(status);
- return MsgToEventLog(M_SYSERR, TEXT("Error querying registry value: HKLM\\SOFTWARE\\" PACKAGE_NAME "%s\\%s"), service_instance, value);
+ return MsgToEventLog(M_SYSERR, TEXT("Error querying registry value: HKLM\\SOFTWARE\\" PACKAGE_NAME "%ls\\%ls"), service_instance, value);
}
return ERROR_SUCCESS;
TCHAR install_path[MAX_PATH];
TCHAR default_value[MAX_PATH];
- openvpn_swprintf(reg_path, _countof(reg_path), TEXT("SOFTWARE\\" PACKAGE_NAME "%s"), service_instance);
+ openvpn_swprintf(reg_path, _countof(reg_path), TEXT("SOFTWARE\\" PACKAGE_NAME "%ls"), service_instance);
LONG status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_path, 0, KEY_READ, &key);
if (status != ERROR_SUCCESS)
{
SetLastError(status);
- return MsgToEventLog(M_SYSERR, TEXT("Could not open Registry key HKLM\\%s not found"), reg_path);
+ return MsgToEventLog(M_SYSERR, TEXT("Could not open Registry key HKLM\\%ls not found"), reg_path);
}
/* The default value of REG_KEY is the install path */
goto out;
}
- openvpn_swprintf(default_value, _countof(default_value), TEXT("%s\\bin\\openvpn.exe"),
+ openvpn_swprintf(default_value, _countof(default_value), TEXT("%ls\\bin\\openvpn.exe"),
install_path);
error = GetRegString(key, TEXT("exe_path"), s->exe_path, sizeof(s->exe_path), default_value);
if (error != ERROR_SUCCESS)
goto out;
}
- openvpn_swprintf(default_value, _countof(default_value), TEXT("%s\\config"), install_path);
+ openvpn_swprintf(default_value, _countof(default_value), TEXT("%ls\\config"), install_path);
error = GetRegString(key, TEXT("config_dir"), s->config_dir, sizeof(s->config_dir),
default_value);
if (error != ERROR_SUCCESS)
goto out;
}
- openvpn_swprintf(default_value, _countof(default_value), TEXT("%s\\log"), install_path);
+ openvpn_swprintf(default_value, _countof(default_value), TEXT("%ls\\log"), install_path);
error = GetRegString(key, TEXT("log_dir"), s->log_dir, sizeof(s->log_dir), default_value);
if (error != ERROR_SUCCESS)
{
else
{
SetLastError(ERROR_INVALID_DATA);
- error = MsgToEventLog(M_SYSERR, TEXT("Unknown priority name: %s"), priority);
+ error = MsgToEventLog(M_SYSERR, TEXT("Unknown priority name: %ls"), priority);
goto out;
}
else
{
SetLastError(ERROR_INVALID_DATA);
- error = MsgToEventLog(M_ERR, TEXT("Log file append flag (given as '%s') must be '0' or '1'"), append);
+ error = MsgToEventLog(M_ERR, TEXT("Log file append flag (given as '%ls') must be '0' or '1'"), append);
goto out;
}
else
{
tmp[wcslen(tmp) - 2] = TEXT('\0'); /* remove CR/LF characters */
- openvpn_swprintf(buf, _countof(buf), TEXT("%s (0x%x)"), tmp, error);
+ openvpn_swprintf(buf, _countof(buf), TEXT("%ls (0x%x)"), tmp, error);
}
if (tmp)
if (hEventSource != NULL)
{
openvpn_swprintf(msg[0], _countof(msg[0]),
- TEXT("%s%s%s: %s"), APPNAME, service_instance,
+ TEXT("%ls%ls%ls: %ls"), APPNAME, service_instance,
(flags & MSG_FLAGS_ERROR) ? TEXT(" error") : TEXT(""), err_msg);
va_start(arglist, format);
* Same format as error messages (3 line string) with error = 0 in
* 0x%08x format, PID on line 2 and a description "Process ID" on line 3
*/
- openvpn_swprintf(buf, _countof(buf), L"0x%08x\n0x%08x\n%s", 0, pid, msg);
+ openvpn_swprintf(buf, _countof(buf), L"0x%08x\n0x%08x\n%ls", 0, pid, msg);
WritePipeAsync(pipe, buf, (DWORD)(wcslen(buf) * 2), count, events);
}
int argc;
BOOL ret = FALSE;
int i;
- const WCHAR *msg1 = L"You have specified a config file location (%s relative to %s)"
+ const WCHAR *msg1 = L"You have specified a config file location (%ls relative to %ls)"
L" that requires admin approval. This error may be avoided"
- L" by adding your account to the \"%s\" group";
+ L" by adding your account to the \"%ls\" group";
- const WCHAR *msg2 = L"You have specified an option (%s) that may be used"
+ const WCHAR *msg2 = L"You have specified an option (%ls) that may be used"
L" only with admin approval. This error may be avoided"
- L" by adding your account to the \"%s\" group";
+ L" by adding your account to the \"%ls\" group";
argv = CommandLineToArgvW(options, &argc);
}
if (err != ERROR_SUCCESS)
{
- MsgToEventLog(M_ERR, L"Failed to find interface index for <%s>", ifname);
+ MsgToEventLog(M_ERR, L"Failed to find interface index for <%ls>", ifname);
}
return err;
}
err_str = buf;
}
- MsgToEventLog(M_ERR, L"%S (status = %lu): %s", msg, err, err_str);
-
+ MsgToEventLog(M_ERR, L"%hs (status = %lu): %ls", msg, err, err_str);
}
/* Use an always-true match_fn to get the head of the list */
/* kill without impunity */
TerminateProcess(pi.hProcess, exit_code);
- MsgToEventLog(M_ERR, TEXT("ExecCommand: \"%s %s\" killed after timeout"),
+ MsgToEventLog(M_ERR, TEXT("ExecCommand: \"%ls %ls\" killed after timeout"),
argv0, cmdline);
}
else if (exit_code)
{
- MsgToEventLog(M_ERR, TEXT("ExecCommand: \"%s %s\" exited with status = %lu"),
+ MsgToEventLog(M_ERR, TEXT("ExecCommand: \"%ls %ls\" exited with status = %lu"),
argv0, cmdline, exit_code);
}
else
{
- MsgToEventLog(M_INFO, TEXT("ExecCommand: \"%s %s\" completed"), argv0, cmdline);
+ MsgToEventLog(M_INFO, TEXT("ExecCommand: \"%ls %ls\" completed"), argv0, cmdline);
}
CloseHandle(pi.hProcess);
else
{
exit_code = GetLastError();
- MsgToEventLog(M_SYSERR, TEXT("ExecCommand: could not run \"%s %s\" :"),
+ MsgToEventLog(M_SYSERR, TEXT("ExecCommand: could not run \"%ls %ls\" :"),
argv0, cmdline);
}
HANDLE wait_handles[2] = {rdns_semaphore, exit_event};
- openvpn_swprintf(ipcfg, MAX_PATH, L"%s\\%s", get_win_sys_path(), L"ipconfig.exe");
+ openvpn_swprintf(ipcfg, MAX_PATH, L"%ls\\%ls", get_win_sys_path(), L"ipconfig.exe");
if (WaitForMultipleObjects(2, wait_handles, FALSE, timeout) == WAIT_OBJECT_0)
{
}
/* Path of netsh */
- openvpn_swprintf(argv0, _countof(argv0), L"%s\\%s", get_win_sys_path(), L"netsh.exe");
+ openvpn_swprintf(argv0, _countof(argv0), L"%ls\\%ls", get_win_sys_path(), L"netsh.exe");
/* cmd template:
* netsh interface $proto $action dns $if_name $addr [validate=no]
*/
- const wchar_t *fmt = L"netsh interface %s %s dns \"%s\" %s";
+ const wchar_t *fmt = L"netsh interface %ls %ls dns \"%ls\" %ls";
/* max cmdline length in wchars -- include room for worst case and some */
size_t ncmdline = wcslen(fmt) + wcslen(if_name) + wcslen(addr) + 32 + 1;
wchar_t *cmdline = NULL;
int timeout = 10000; /* in msec */
- openvpn_swprintf(argv0, _countof(argv0), L"%s\\%s", get_win_sys_path(), L"wbem\\wmic.exe");
+ openvpn_swprintf(argv0, _countof(argv0), L"%ls\\%ls", get_win_sys_path(), L"wbem\\wmic.exe");
const wchar_t *fmt;
/* comma separated list must be enclosed in parenthesis */
if (data && wcschr(data, L','))
{
- fmt = L"wmic nicconfig where (InterfaceIndex=%ld) call %s (%s)";
+ fmt = L"wmic nicconfig where (InterfaceIndex=%ld) call %ls (%ls)";
}
else
{
- fmt = L"wmic nicconfig where (InterfaceIndex=%ld) call %s \"%s\"";
+ fmt = L"wmic nicconfig where (InterfaceIndex=%ld) call %ls \"%ls\"";
}
size_t ncmdline = wcslen(fmt) + 20 + wcslen(action) /* max 20 for ifindex */
wchar_t argv0[MAX_PATH];
/* Path of netsh */
- openvpn_swprintf(argv0, _countof(argv0), L"%s\\%s", get_win_sys_path(), L"netsh.exe");
+ openvpn_swprintf(argv0, _countof(argv0), L"%ls\\%ls", get_win_sys_path(), L"netsh.exe");
/* cmd template:
* netsh interface ipv4 set address name=$if_index source=dhcp
}
openvpn_swprintf(ovpn_pipe_name, _countof(ovpn_pipe_name),
- TEXT("\\\\.\\pipe\\" PACKAGE "%s\\service_%lu"), service_instance, GetCurrentThreadId());
+ TEXT("\\\\.\\pipe\\" PACKAGE "%ls\\service_%lu"), service_instance, GetCurrentThreadId());
ovpn_pipe = CreateNamedPipe(ovpn_pipe_name,
PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 1, 128, 128, 0, NULL);
ReturnLastError(pipe, L"malloc");
goto out;
}
- openvpn_swprintf(cmdline, cmdline_size, L"openvpn %s --msg-channel %lu",
+ openvpn_swprintf(cmdline, cmdline_size, L"openvpn %ls --msg-channel %lu",
sud.options, svc_pipe);
if (!CreateEnvironmentBlock(&user_env, imp_token, FALSE))
initialized = TRUE;
}
- openvpn_swprintf(pipe_name, _countof(pipe_name), TEXT("\\\\.\\pipe\\" PACKAGE "%s\\service"), service_instance);
+ openvpn_swprintf(pipe_name, _countof(pipe_name), TEXT("\\\\.\\pipe\\" PACKAGE "%ls\\service"), service_instance);
pipe = CreateNamedPipe(pipe_name, flags,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE,
PIPE_UNLIMITED_INSTANCES, 1024, 1024, 0, NULL);
if (GetModuleFileName(NULL, path + 1, _countof(path) - 2) == 0)
{
- wprintf(TEXT("Unable to install service - %s\n"), GetLastErrorText());
+ wprintf(TEXT("Unable to install service - %ls\n"), GetLastErrorText());
return 1;
}
svc_ctl_mgr = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE);
if (svc_ctl_mgr == NULL)
{
- wprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText());
+ wprintf(TEXT("OpenSCManager failed - %ls\n"), GetLastErrorText());
return 1;
}
NULL, NULL);
if (service)
{
- wprintf(TEXT("%s installed.\n"), openvpn_service[i].display_name);
+ wprintf(TEXT("%ls installed.\n"), openvpn_service[i].display_name);
CloseServiceHandle(service);
--ret;
}
else
{
- wprintf(TEXT("CreateService failed - %s\n"), GetLastErrorText());
+ wprintf(TEXT("CreateService failed - %ls\n"), GetLastErrorText());
}
}
svc_ctl_mgr = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (svc_ctl_mgr == NULL)
{
- wprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText());
+ wprintf(TEXT("OpenSCManager failed - %ls\n"), GetLastErrorText());
return 1;
}
}
else
{
- wprintf(TEXT("StartService failed - %s\n"), GetLastErrorText());
+ wprintf(TEXT("StartService failed - %ls\n"), GetLastErrorText());
}
CloseServiceHandle(service);
}
else
{
- wprintf(TEXT("OpenService failed - %s\n"), GetLastErrorText());
+ wprintf(TEXT("OpenService failed - %ls\n"), GetLastErrorText());
}
CloseServiceHandle(svc_ctl_mgr);
svc_ctl_mgr = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
if (svc_ctl_mgr == NULL)
{
- wprintf(TEXT("OpenSCManager failed - %s\n"), GetLastErrorText());
+ wprintf(TEXT("OpenSCManager failed - %ls\n"), GetLastErrorText());
return 1;
}
DELETE | SERVICE_STOP | SERVICE_QUERY_STATUS);
if (service == NULL)
{
- wprintf(TEXT("OpenService failed - %s\n"), GetLastErrorText());
+ wprintf(TEXT("OpenService failed - %ls\n"), GetLastErrorText());
goto out;
}
/* try to stop the service */
if (ControlService(service, SERVICE_CONTROL_STOP, &status))
{
- wprintf(TEXT("Stopping %s."), ovpn_svc->display_name);
+ wprintf(TEXT("Stopping %ls."), ovpn_svc->display_name);
Sleep(1000);
while (QueryServiceStatus(service, &status))
if (status.dwCurrentState == SERVICE_STOPPED)
{
- wprintf(TEXT("\n%s stopped.\n"), ovpn_svc->display_name);
+ wprintf(TEXT("\n%ls stopped.\n"), ovpn_svc->display_name);
}
else
{
- wprintf(TEXT("\n%s failed to stop.\n"), ovpn_svc->display_name);
+ wprintf(TEXT("\n%ls failed to stop.\n"), ovpn_svc->display_name);
}
}
/* now remove the service */
if (DeleteService(service))
{
- wprintf(TEXT("%s removed.\n"), ovpn_svc->display_name);
+ wprintf(TEXT("%ls removed.\n"), ovpn_svc->display_name);
--ret;
}
else
{
- wprintf(TEXT("DeleteService failed - %s\n"), GetLastErrorText());
+ wprintf(TEXT("DeleteService failed - %ls\n"), GetLastErrorText());
}
CloseServiceHandle(service);
}
else
{
- wprintf(TEXT("%s -install to install the interactive service\n"), APPNAME);
- wprintf(TEXT("%s -start [name] to start the service (name = \"interactive\" is optional)\n"), APPNAME);
- wprintf(TEXT("%s -remove to remove the service\n"), APPNAME);
+ wprintf(TEXT("%ls -install to install the interactive service\n"), APPNAME);
+ wprintf(TEXT("%ls -start [name] to start the service (name = \"interactive\" is optional)\n"), APPNAME);
+ wprintf(TEXT("%ls -remove to remove the service\n"), APPNAME);
wprintf(TEXT("\nService run-time parameters:\n"));
wprintf(TEXT("-instance interactive <id>\n")
/* convert fname to full path */
if (PathIsRelativeW(fname) )
{
- openvpn_swprintf(tmp, _countof(tmp), L"%s\\%s", workdir, fname);
+ openvpn_swprintf(tmp, _countof(tmp), L"%ls\\%ls", workdir, fname);
config_file = tmp;
}
else
ret = IsUserInGroup(sid, token_groups, admin_group[i]);
if (ret)
{
- MsgToEventLog(M_INFO, TEXT("Authorizing user '%s@%s' by virtue of membership in group '%s'"),
+ MsgToEventLog(M_INFO, TEXT("Authorizing user '%ls@%ls' by virtue of membership in group '%ls'"),
username, domain, admin_group[i]);
goto out;
}
if (err != NERR_Success && err != NERR_GroupNotFound)
{
SetLastError(err);
- MsgToEventLog(M_SYSERR, TEXT("In NetLocalGroupGetMembers for group '%s'"), group_name);
+ MsgToEventLog(M_SYSERR, TEXT("In NetLocalGroupGetMembers for group '%ls'"), group_name);
}
return ret;