0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 12:12:15 +02:00

ovpncli: add open_url support for unixoid OSes

Open the user's default browser for OPEN_URL and WEB_AUTH dynamic
auth requests.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
This commit is contained in:
Heiko Hund 2021-08-11 14:44:09 +02:00
parent 4b82cfaa3b
commit 634e58e23b

View File

@ -21,7 +21,7 @@
// OpenVPN 3 test client
#include <stdlib.h> // for atoi
#include <stdlib.h>
#include <string>
#include <iostream>
@ -342,6 +342,17 @@ private:
CFRelease(url);
});
thr.detach();
#elif defined(OPENVPN_PLATFORM_TYPE_UNIX)
Argv argv;
if (::getuid() == 0 && ::getenv("SUDO_USER"))
{
argv.emplace_back("/usr/sbin/runuser");
argv.emplace_back("-u");
argv.emplace_back(::getenv("SUDO_USER"));
}
argv.emplace_back("/usr/bin/xdg-open");
argv.emplace_back(url_str);
system_cmd(argv);
#else
std::cout << "No implementation to launch " << url_str << std::endl;
#endif