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
ENH: LDAP filter can be customized using SetLdapFilter() method ({cn_identifier}, {username}, and {groups_filtering} placeholders are supported)
ENH: Full PHP 8.x support (tested with 8.2.1 and 8.1.14), with backward compatibility support (7.x, >=5.4.x)
ENH: Enhanced AD/LDAP paging support
ENH: Embedded Windows nginx edition updated to version 1.22.1
ENH: Embedded Windows PHP edition updated to version 8.2.0
ENH: PHP 8.2.x deprecated code cleaned (nullable trim, dynamic properties, PostgreSQL command without connection argument)
ENH: Enhanced sms library (MultiotpSms), new eCall API implementation, new ASPSMS API implementation
ENH: Better MySQL error handling
ENH: Better PostgreSQL error handling
New release
New release
ENH: It's now possible to define a special AD/LDAP group to attribute "Without2FA" token to specific users
ENH: Default username and password are not displayed anymore if default password has been changed
Enhanced multiOTP Credential Provider support
New release
FIX: Better special characters support in username and password
ENH: The locked accounts list now also list the temporary delayed accounts
ENH: Accounts with Without2FA tokens can now also be stored in cache
New release
ENH: Command -iswithout2fa added as a CLI option (to check if a token is needed)
ENH: Enhanced multiOTP Credential Provider
ENH: Additional CLI option -nt-key-only added
New release
FIX: Issue with /run/php when a Docker container is restarted
FIX: {MultiOtpVersion} is now correctly replaced in scratchtemplate.html
ENH: {MultiOtpDisplayName} tag (AD/LDAP DisplayName) can be used in templates
FIX: User account containing octal encoded ISO characters are now also converted to UTF
New release
FIX: Set specific flags to run Perl scripts from FreeRADIUS
FIX: User account containing special ISO characters are now also converted to UTF
ENH: New Hyper-V and OVA appliances available (version 011, based on Debian 11)
ENH: Scratchlist can be generated from the Web GUI
Date: 6 months ago
Size: 4,259 bytes


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\ * * Visit for additional support. * * Donation are always welcome! Please check https://www\ * and you will find the magic button ;-) * * The multiOTP C++ launcher is simply used to launch PHP * and run with the provided arguments. * * @author Andre Liechti, SysCo systemes de communication sa, <> * @version * @date 2023-01-19 * @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 * ( * 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 <>. * * * Change Log * * 2018-03-05 SysCo/al Adapt the php.exe path automatically * 2018-02-19 SysCo/al Quotes tested and debugged with Credential Provider * 2018-02-19 SysCo/al Comments cleaning * 2017-05-29 SysCo/al Quotes must by around the launch string * 2016-12-29 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 "" #define VER_DATE "2023-01-19" 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\\" + 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); }