PHP Classes

File: launcher/launcher.cpp

Recommend this page to a friend!
  Classes of André Liechti   multiOTP PHP class   launcher/launcher.cpp   Download  
File: launcher/launcher.cpp
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: multiOTP PHP class
Authenticate and manage OTP strong user tokens
Author: By
Last change: Release 5.10.0.2 - Fixed docker issue
Release 5.10.0.1
New release 5.9.9.1
FIX: Windows backup temp folder is now the default system temp folder
FIX: Adding -sync-delete-retention-days parameter doesn't return missing parameters error
FIX: Case sensitive issue has been fixed with MSCHAPv2 authentication (thanks Alexey)
FIX: Case sensitive issue has been fixed during FastCreateUser process
FIX: {MultiotpUserDisplayName} tag usage in templates (was not replaced in the QRcode)
ENH: Created users are trimmed to avoid bad space prefix/suffix during copy/paste
ENH: multiOTP Credential Provider enhanced support
ENH: New default-2fa-digits command line option to set the default amount of OTP digits
ENH: PHP 8.4.x deprecated code cleaned (xml_set_object removed)
ENH: New Message-Authenticator requirement support for FortiGate v7.2.10+, v7.4.5+ and v7.6.1+
ENH: New SetCurrentUserSid function for new Credential Provider -usersid option
ENH: Embedded Windows PHP edition updated to version 8.3.15
ENH: Embedded Windows nginx edition updated to version 1.27.3
New release 5.9.8.0
FIX: Database backend setup and initialization was not working well with some PHP version
ENH: New option to force writing logs only in file (even if the backend is a database)
ENH: Spryng SMS provider support
ENH: PHP 8.2.x deprecated code cleaned (null for string parameters)
FIX: without2fa token can be now correctly converted to TOTP with default 30 seconds time interval
FIX: Without2fa tokens with prefix pin where not working with CHAP/MSCHAP/MSCHAPv2
FIX: Windows: radiusd.conf and clients.conf files removed from the distribution
(they are created automatically when installing the services using radius_install.cmd)
ENH: Windows: -debug option removed from the radius module launcher
ENH: By design, Credential Provider check request don't wait any prefix. This behavior can now be overwrited.
Date: 1 month ago
Size: 4,261 bytes
 

Contents

Class file image Download
/** * @file launcher.cpp * @brief Launcher for the multiOTP open source embedded CLI package * * multiOTP C++ launcher - Strong two-factor authentication solution * https://www\.multiOTP.net * * Visit http://forum.multiotp.net/ for additional support. * * Donation are always welcome! Please check https://www\.multiOTP.net * and you will find the magic button ;-) * * The multiOTP C++ launcher is simply used to launch PHP * and run multiotp.windows.php with the provided arguments. * * @author Andre Liechti, SysCo systemes de communication sa, <[email protected]> * @version 5.10.0.2 * @date 2025-10-31 * @since 2016-12-08 * @copyright (c) 2010-2025 SysCo systemes de communication sa * @copyright GNU Lesser General Public License * *//* * * LICENCE * * Copyright (c) 2010-2025 SysCo systemes de communication sa * SysCo (tm) is a trademark of SysCo systemes de communication sa * (http://www.sysco.ch) * All rights reserved. * * This file is part of the multiOTP open source project. * * multiOTP open source project is free software; you can redistribute it * and/or modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * multiOTP open source project is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with multiOTP open source project. * If not, see <http://www.gnu.org/licenses/>. * * * Change Log * * 2018-03-05 5.1.0.8 SysCo/al Adapt the php.exe path automatically * 2018-02-19 5.1.0.6 SysCo/al Quotes tested and debugged with Credential Provider * 2018-02-19 5.1.0.3 SysCo/al Comments cleaning * 2017-05-29 5.0.4.5 SysCo/al Quotes must by around the launch string * 2016-12-29 5.0.3.4 SysCo/al Initial implementation and distribution * *********************************************************************/ #include "stdafx.h" #define WIN32_LEAN_AND_MEAN #include <direct.h> #include <fcntl.h> #include <io.h> #include <windows.h> #include <string> #include <iostream> #define SOFTWARE "LAUNCHPHPMULTIOTP" #define VER_NUMBER "5.10.0.2" #define VER_DATE "2025-10-31" void replaceAll(std::string& str, const std::string& from, const std::string& to) { if (from.empty()) return; size_t start_pos = 0; while ((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx' } } int _tmain(int argc, _TCHAR* argv[]) { std::string cli_arg = argv[0]; cli_arg = cli_arg + "\\..\\"; const char* cli_arg_char = cli_arg.c_str(); char basePath[4096] = ""; _fullpath(basePath, cli_arg_char, sizeof(basePath)); std::string quote = "\""; std::string pathToPhp = quote + basePath + "php\\php.exe" + quote; std::string pathToMultiotp = quote + basePath + "php\\multiotp.windows.php" + quote; // std::string defaultPath = basePath + "php"; // char defaultPath[4096] = ""; // strcpy_s(defaultPath, basePath); // strcat_s(defaultPath, "php"); std::string run_software = pathToPhp + " " + pathToMultiotp + " -base-dir=" + quote + basePath + "." + quote; std::string escapedArgv; for (int i = 1; i < argc; i = i + 1) { escapedArgv = argv[i]; replaceAll(escapedArgv, "\"", "\\\""); replaceAll(escapedArgv, "&", "^&"); run_software = run_software + " " + quote + escapedArgv + quote; } // Put the run software between quotes, because system use CMD /K run_software = quote + run_software + quote; const char* run_software_char = run_software.c_str(); // std::cout << "Full RUN: " << run_software_char << std::endl; _chdir(basePath); return system(run_software_char); }