From patchwork Wed Jul 25 09:50:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristof Provost via Openvpn-devel X-Patchwork-Id: 432 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id Ky7tL9LUWFu5dgAAIUCqbw for ; Wed, 25 Jul 2018 15:51:46 -0400 Received: from proxy8.mail.ord1d.rsapps.net ([172.30.191.6]) by director9.mail.ord1d.rsapps.net (Dovecot) with LMTP id W1OnL9LUWFvPIAAAalYnBA ; Wed, 25 Jul 2018 15:51:46 -0400 Received: from smtp9.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy8.mail.ord1d.rsapps.net with LMTP id gDqxL9LUWFveVAAAGdz6CA ; Wed, 25 Jul 2018 15:51:46 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp9.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=pass header.d=lists.sourceforge.net; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=microsoft.com; dmarc=pass (p=none; dis=none) header.from=lists.sourceforge.net X-Suspicious-Flag: NO X-Classification-ID: 290ae0fa-9044-11e8-82d8-525400bd3b1f-1-1 Received: from [216.105.38.7] ([216.105.38.7:62099] helo=lists.sourceforge.net) by smtp9.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 26/A5-22271-1D4D85B5; Wed, 25 Jul 2018 15:51:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:Message-ID:Date:To:Sender:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=NFcWPePebs+vZrlHONSDR7m8GdqcEgDy82DhSAeGzk8=; b=eT/Vkz7IwswAzW8IAciC6EpGns 8aCjk11f9AGGsyxGarLxkbSybLfP6GmpS/n/NDOt6RxCWQS+gLzTsBwZ4sSOVI8GiIUj1qNr8WEeA 4oB6xH7wrp53Cvv8EjyL19S59P2niTTIhpNluTVLsX4iqXlZ1KPGhVYPZJHVNpJZsj98=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1fiPo3-0006XV-5X; Wed, 25 Jul 2018 19:50:43 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fiPo1-0006XK-8E for openvpn-devel@lists.sourceforge.net; Wed, 25 Jul 2018 19:50:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Transfer-Encoding:Content-Type :Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=TI6rqXR15eUrMmLwUIr9Xwxt23GcZVBd1NBw/vPPweM=; b=SQNXxDClMuu22Vud1z+sa+ZqNw Ody7WyYvrvT0QtqisbJnIgn2/C8+K269Nw7zZCERr0blnbwhYYqAqvhqddCHVRSe0R4a6bVje3hiR pZwM8idOfQ9Q6GyKkDHvn1Oo9RKxoV5Q1Od/X9v9s3Oz8Kt33450t3FNyktjzzwAbb/g=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Transfer-Encoding:Content-Type:Message-ID:Date: Subject:CC:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=TI6rqXR15eUrMmLwUIr9Xwxt23GcZVBd1NBw/vPPweM=; b=E 4vN6TXtHg37wv+Q6I9yhvsortdTk7aW9q0JZDupPoKzrVoL6YRAaQ5Ligl5dD9jTyp/mkpT+OUa0D dYSfHgMOtWZX+5ilq+hErv/TFUKud7om9vyI8xoxJm18p9Y2q3iCu6xt2bHJGq7H2GJ7UuMnxCwT3 5+CHfJ2nuOqal/nQ=; Received: from mail-bn3nam01on0135.outbound.protection.outlook.com ([104.47.33.135] helo=NAM01-BN3-obe.outbound.protection.outlook.com) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) (Exim 4.90_1) id 1fiPny-00BcBQ-Aa for openvpn-devel@lists.sourceforge.net; Wed, 25 Jul 2018 19:50:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TI6rqXR15eUrMmLwUIr9Xwxt23GcZVBd1NBw/vPPweM=; b=P85ES8FoFzN+eKmL6uKPdmZiC0Zk5PtRaRv2lusCXtYGX2hnzvcqcbxiJq5IUpHQvxvVUb5d+XrtWstXcWtT7M1x7ujigQDEnqQcKdyetUo6P5awuvJ9Pncfp0gbik5Ae30yEJxiGiX1ps84OS7x7vsPUfyUB7k0dijXQZ+815I= Received: from BL0PR2101MB1058.namprd21.prod.outlook.com (52.132.24.16) by BL0PR2101MB0897.namprd21.prod.outlook.com (52.132.23.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.2; Wed, 25 Jul 2018 19:50:31 +0000 Received: from BL0PR2101MB1058.namprd21.prod.outlook.com ([fe80::178:4c86:5dda:c4db]) by BL0PR2101MB1058.namprd21.prod.outlook.com ([fe80::178:4c86:5dda:c4db%3]) with mapi id 15.20.1017.000; Wed, 25 Jul 2018 19:50:31 +0000 To: "openvpn-devel@lists.sourceforge.net" Thread-Topic: [PATCH v2] [openvpn] Register/unregister trusted custom dialer DLL when installing/uninstalling service Thread-Index: AQHUJFC+8IMLFwL0k0iNEzAXP2zmOA== Date: Wed, 25 Jul 2018 19:50:30 +0000 Message-ID: <20180725195016.22456-1-kkane@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1.windows.2 x-clientproxiedby: CY4PR22CA0061.namprd22.prod.outlook.com (2603:10b6:903:ae::23) To BL0PR2101MB1058.namprd21.prod.outlook.com (2603:10b6:207:37::16) x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BL0PR2101MB0897; 6:0p1WAB2AoXJAKP3C/bE8sR6Z0de/Bs98d2xp5cP4ShT5QRsCK2SX3AGEBxh4CJ6ikPr/NkSocvKBbTnwxWjuZP6hWa2utN/dmB63Gzg68djlx0FgdSkcKF60uovI+9eE6VmW/bEr4JUibKAmf8BPdSh9DW0y6TtlvXZsXYr3finCvqBm7a83c2pguiaoltSmArXW2ruUl9dCgJ1vJJYm5Nod5O76gBy68mnO7sk2pOnW3TWpbndK+P6gX9Kj2/f00/kM1M8tgW1gt34+L9UT4RkMxHb2Yg4zY+f+ueXR3OiShJT16yQlIjtI0txsZxZX7s3C0cQv4mFtqojvzGNpCmYF2rxNvNPupFGVLio0jDNc/om6ljF/7iX5ObdcDkjhmfExMXXQwsoNftct2p4RdzFxM6eGOjvo8HL9ZMqaP+vsVltc7K1pWqvQVSkC8K2QZiT6Gtc2cIx8n7HTvxDVaQ==; 5:c8lMYpjPRKu6rv7W5ysqeNiHEE2QrCxXK9fwf4rVhwuMsWlDVOINfT8HwMe5aSszvpMYrLzVRUSEYA7XomE352mXviLNXU2vaEqjdnxUdHjIRlW2p6Q/eutncNpCihESlU9bQ/7KmAOmCl9X1rRHe3m+swuUY1r5PQoPJSQYs4o=; 7:IdEyAKQjjZfnD+0gfVmUk8GOZnnnlF2BIvTVOUq9zLODjS01YOR4/MUCxMwQa2/f2R+nKuN8AgP6F43v3Bro5SRVyBZXFWaE5i6C+6MiTY9VKfXEilcbW+IlxvIqcOm9aLEHKmTCMppU0iWl+pWrv8nVakT9wHVqzoqKl8RHz2K02VAv5T8njtoLmAm57HEumDhdWWTkgBnL7t+jwoBQZRqJLfk1vvn1nwxFYhLF/X/ID3TcU0JG19vx8QlUL2aF x-ms-office365-filtering-correlation-id: 4ecc8d4f-7af1-4f45-8504-08d5f267e05a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7193020); SRVR:BL0PR2101MB0897; x-ms-traffictypediagnostic: BL0PR2101MB0897: x-o365-sonar-daas-pilot: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(197898729827340); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231311)(944501410)(52105095)(2018427008)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:BL0PR2101MB0897; BCL:0; PCL:0; RULEID:; SRVR:BL0PR2101MB0897; x-forefront-prvs: 0744CFB5E8 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(39860400002)(376002)(346002)(366004)(396003)(189003)(199004)(316002)(25786009)(2351001)(68736007)(1076002)(5660300001)(22452003)(6512007)(106356001)(105586002)(6116002)(6916009)(8936002)(81166006)(2906002)(8676002)(6436002)(99286004)(81156014)(4326008)(2900100001)(6486002)(5640700003)(7736002)(107886003)(10090500001)(486006)(476003)(10290500003)(2616005)(14454004)(14444005)(36756003)(305945005)(2501003)(52116002)(6506007)(478600001)(5250100002)(386003)(50226002)(102836004)(46003)(186003)(575784001)(86362001)(86612001)(256004)(97736004)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:BL0PR2101MB0897; H:BL0PR2101MB1058.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: iEVXjrGY+07lhr7aver7Hn03hP0EbmGbFP4sd8fUEHHZS8gBnrFVHKeXjxh6Y2xos3tkMX4WrnnMjh2CS68ZN42HWPBh/SZWOC8Z6BNDCULjnhB+LF/MZU5wnoQGZuRcR0NiQKJsyx5JQ+eRT+JYpzP3i+4mRbaELEFxAJIqKqSZu0s0rf9l7wKkUFhn78ozV9MqqQz4gB0F452Fb4EsHhKjPzi8SiJ3Us5qax8tVRj7thfMOopCwUyXh4aK3J5ShG4Bfn7j1jPFWeLRr2KiU1Bbo7YGlOHpmIPpB9VPyzZ7biA0+VlnZZMBkMXtYjAIfapbjnPKVJP3Be9VopU7vANvS5Svz22uv0bxRbmBfu0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ecc8d4f-7af1-4f45-8504-08d5f267e05a X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jul 2018 19:50:30.9730 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR2101MB0897 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [104.47.33.135 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 T_DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender 0.4 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1fiPny-00BcBQ-Aa Subject: [Openvpn-devel] [PATCH v2] [openvpn] Register/unregister trusted custom dialer DLL when installing/uninstalling service X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Kevin Kane via Openvpn-devel From: Kristof Provost via Openvpn-devel Reply-To: Kevin Kane Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox Add copyright notice as required where Microsoft has contributed code Signed-off-by: Kevin Kane --- src/openvpnserv/service.c | 241 +++++++++++++++++++++++++++++++++++--- 1 file changed, 222 insertions(+), 19 deletions(-) diff --git a/src/openvpnserv/service.c b/src/openvpnserv/service.c index 7157bea2..edb21b0d 100644 --- a/src/openvpnserv/service.c +++ b/src/openvpnserv/service.c @@ -6,6 +6,7 @@ * * Copyright (C) 1993 - 2000. Microsoft Corporation. All rights reserved. * 2013 Heiko Hund + * Portions Copyright (C) 2018 Microsoft Corporation */ #include "service.h" @@ -53,6 +54,195 @@ ReportStatusToSCMgr(SERVICE_STATUS_HANDLE service, SERVICE_STATUS *status) return res; } +static const TCHAR DialerDllName[] = TEXT("libopenvpndialer-0.dll"); +static const TCHAR RegValueName[] = TEXT("CustomDLL"); + +static int +HandleDialerRegistration(int uninstall) +{ + TCHAR path[512], customDllString[1024]; + HKEY parametersKey; + LONG result; + DWORD customDllSize = sizeof(customDllString); + + /* Assumption is that the dialer DLL is installed to the same bin directory as everything else. */ + if (GetModuleFileName(NULL, path, sizeof(path)) == 0) + { + _tprintf(TEXT("Unable to get module path - %lu\n"), GetLastError()); + return 1; + } + + /* The version of NSIS we use to create the installer doesn't yet have support for + * writing multi-string registry entries, which we need to do in order to register our + * custom dialer DLL. Instead, we'll update this registry entry on install/uninstall. + */ + + TCHAR *lastBackslash = _tcsrchr(path, TEXT('\\')); + if (NULL == lastBackslash) + { + _tprintf(TEXT("Could not locate last backslash in path: %s\n"), path); + return 1; + } + + lastBackslash[1] = TEXT('\0'); + + /* Bounds checking. */ + if ((_tcslen(path) + _countof(DialerDllName)) > _countof(path)) + { + _tprintf(TEXT("Out of buffer adding dialer filename to path")); + return 1; + } + + _tcscat(path, DialerDllName); + + result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + TEXT("SYSTEM\\CurrentControlSet\\Services\\RasMan\\Parameters"), + 0, + KEY_ALL_ACCESS, + ¶metersKey); + if (ERROR_SUCCESS != result) + { + _tprintf(TEXT("Could not open RasMan parameters key: %ld\n"), result); + return 1; + } + + /* Must RegCloseKey(parametersKey) from this point */ + + result = RegGetValue(parametersKey, + NULL, + RegValueName, + RRF_RT_REG_MULTI_SZ, + NULL, + customDllString, + &customDllSize); + + /* If we're installing, the key being absent is okay. Any other error is fatal. */ + if (ERROR_FILE_NOT_FOUND == result) + { + if (0 != uninstall) + { + _tprintf(TEXT("CustomDLL value was not found; skipping unregistration step\n")); + RegCloseKey(parametersKey); + return 0; /* Not a fatal error but nothing to do */ + } + else + { + result = ERROR_SUCCESS; + customDllString[0] = TEXT('\0'); + customDllSize = 0; + } + } + else if (ERROR_SUCCESS != result) + { + _tprintf(TEXT("Could not open CustomDLL value: %ld\n"), result); + RegCloseKey(parametersKey); + return 1; + } + + /* Determine if the custom dialer DLL is present in the registry setting. This is a multi-string so we can't + * use _tcsstr. + */ + TCHAR* p; + for (p = customDllString; *p != TEXT('\0'); p += _tcslen(p) + 1) + { + if (0 == _tcsicmp(path, p)) + { + /* It is. p points to where it begins. */ + break; + } + } + /* If it's not present, p points at a NULL terminator. */ + + /* If we're installing and the DLL is present in the registry, do nothing. */ + /* If we're uninstalling and the DLL is not present in the registry, do nothing. */ + if ( ((0 == uninstall) && (*p != TEXT('\0'))) || + ((0 != uninstall) && (*p == TEXT('\0'))) ) + { + RegCloseKey(parametersKey); + return 0; + } + + /* If we're installing and the DLL is not present in the registry, append it at point p. */ + if ((0 == uninstall) && (*p == TEXT('\0'))) + { + /* Make sure the string buffer has enough space left. p points at the second in the double-terminating null + * (or the sole NULL if the registry entry was empty or absent). + */ + if (((p - customDllString) + _tcslen(path) + 2) > _countof(customDllString)) + { + _tprintf(TEXT("Not enough buffer to create new CustomDLL string\n")); + RegCloseKey(parametersKey); + return 1; + } + _tcscpy(p, path); + /* Add second terminating NULL we overwrote with the copy. */ + p += _tcslen(p) + 1; + *p++ = TEXT('\0'); + + /* Set in the registry. */ + result = RegSetValueEx(parametersKey, + RegValueName, + 0, + REG_MULTI_SZ, + (const BYTE*)customDllString, + (DWORD)(sizeof(TCHAR) * (p - customDllString))); + + RegCloseKey(parametersKey); + if (ERROR_SUCCESS != result) + { + _tprintf(TEXT("Failed to RegSetValueEx: %ld\n"), result); + return 1; + } + } + /* Else if we're uninstalling and the DLL is present, copy everything except strings matching path. */ + else if ((0 != uninstall) && (*p != TEXT('\0'))) + { + TCHAR newCustomDllString[1024]; + TCHAR *n, *c; + + /* newCustomDllString is the same size as customDllString, and we're only removing, so no + * way to overflow the buffer. + */ + for (c = customDllString, n = newCustomDllString; *c != TEXT('\0'); c += _tcslen(c) + 1) + { + if (0 != _tcsicmp(path, c)) + { + _tcscpy(n, c); + n += _tcslen(n) + 1; + } + } + + /* Add double-terminating NULL as is required for a multi-string. */ + *n++ = TEXT('\0'); + + /* If the new string is nonempty, set in the registry. Otherwise delete the value. */ + if (TEXT('\0') != *newCustomDllString) + { + result = RegSetValueEx(parametersKey, + RegValueName, + 0, + REG_MULTI_SZ, + (const BYTE*)newCustomDllString, + (DWORD)(sizeof(TCHAR) * (n - newCustomDllString))); + } + else + { + result = RegDeleteValue(parametersKey, RegValueName); + } + + RegCloseKey(parametersKey); + if (ERROR_SUCCESS != result) + { + _tprintf(TEXT("Failed to %s new registry value: %ld\n"), + (TEXT('\0') != *newCustomDllString)?TEXT("set"):TEXT("delete"), + result); + return 1; + } + } + + return 0; +} + static int CmdInstallServices() { @@ -77,27 +267,35 @@ CmdInstallServices() return 1; } - for (i = 0; i < _service_max; i++) + if (0 != HandleDialerRegistration(0)) { - service = CreateService(svc_ctl_mgr, - openvpn_service[i].name, - openvpn_service[i].display_name, - SERVICE_QUERY_STATUS, - SERVICE_WIN32_SHARE_PROCESS, - openvpn_service[i].start_type, - SERVICE_ERROR_NORMAL, - path, NULL, NULL, - openvpn_service[i].dependencies, - NULL, NULL); - if (service) - { - _tprintf(TEXT("%s installed.\n"), openvpn_service[i].display_name); - CloseServiceHandle(service); - --ret; - } - else + _tprintf(TEXT("HandleDialerRegistration failed\n")); + ret = 1; + } + else + { + for (i = 0; i < _service_max; i++) { - _tprintf(TEXT("CreateService failed - %s\n"), GetLastErrorText()); + service = CreateService(svc_ctl_mgr, + openvpn_service[i].name, + openvpn_service[i].display_name, + SERVICE_QUERY_STATUS, + SERVICE_WIN32_SHARE_PROCESS, + openvpn_service[i].start_type, + SERVICE_ERROR_NORMAL, + path, NULL, NULL, + openvpn_service[i].dependencies, + NULL, NULL); + if (service) + { + _tprintf(TEXT("%s installed.\n"), openvpn_service[i].display_name); + CloseServiceHandle(service); + --ret; + } + else + { + _tprintf(TEXT("CreateService failed - %s\n"), GetLastErrorText()); + } } } @@ -160,6 +358,11 @@ CmdRemoveServices() return 1; } + if (0 != HandleDialerRegistration(1)) + { + _tprintf(TEXT("HandleDialerRegistration uninstall failed; ignoring\n")); + } + for (i = 0; i < _service_max; i++) { openvpn_service_t *ovpn_svc = &openvpn_service[i];