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: New release 5.9.7.1
FIX: Command line number of parameters detection corrected
ENH: It's now possible to define the number of digits for new created PIN
(multiotp -config default-pin-digits=n)
ENH: It's now possible to generate the HTML provisioning file by command line
(multiotp -htmlinfo username /full/path/to/username.html or
multiotp -htmlinfo /full/path/to/folder/ to generate files for all users)
ENH: Embedded Windows nginx edition updated to version 1.25.3
ENH: Embedded Windows internal tools updated (wget 1.21.4 and fart 1.99d)
ENH: Embedded Windows freeradius is now launched using NSSM (instead of SRVANY)
New release 5.9.7.0
FIX: Better Windows nginx configuration support (path backslashes replaced by slashes)
ENH: Embedded Windows nginx edition updated to version 1.24.0
ENH: Embedded Windows PHP edition updated to version 8.2.13
ENH: Better hardware/model detection
ENH: Documentation enhanced with instructions for RDWeb on Windows
ENH: Upgrade of some internal tools
ENH: Better internal configuration organization
New release 5.9.6.7
ENH: Documentation updated for "Configuring multiOTP with FreeRADIUS 3.x under Linux"
ENH: Without2FA tokens cannot be used for multi_account connection
ENH: Added documentation for SSH login with multiOTP
New release 5.9.6.5
FIX: Better Raspberry Pi support
FIX: ShowLog() method (used by -showlog option) was buggy
New release 5.9.6.1
FIX: Automated concurrent access for the same user with "Without2FA" token could corrupt the user file
FIX: Any files backend operation is now secured with explicit lock mechanism
ENH: Template updated to print bigger QRcode for "MOTP-XML" tokens
New release 5.9.5.7
FIX: Weekly anonymized stats date was not always updated
FIX: Adding -tokenslist command in CLI mode (mas missing)
FIX: Remove a debug line displaying sometimes "COMMDN:$command\n";
FIX: Some minor PHP notice corrections
ENH: Adding on-premises smsgateway (https://github.com/multiOTP/SMSGateway) as a new SMS provider
ENH: Better warning messages when CheckUserLdapPassword failed
ENH: Embedded documentation enhanced
ENH: Template updated to display correct information for WITHOUT2FA tokens
Date: 3 months ago
Size: 4,259 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, <info@multiotp.net> * @version 5.9.7.1 * @date 2023-12-03 * @since 2016-12-08 * @copyright (c) 2010-2023 SysCo systemes de communication sa * @copyright GNU Lesser General Public License * *//* * * LICENCE * * Copyright (c) 2010-2023 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.9.7.1" #define VER_DATE "2023-12-03" 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); }