src_prepare-overlay/games-util/lgogdownloader/files/0001-recycle-cookies-and-tokens.patch
2020-04-17 19:23:56 +02:00

59 lines
2.6 KiB
Diff

--- lgogdownloader/src/downloader.cpp 2020-04-17 15:41:32.142346898 +0200
+++ lgogdownloader-portage/src/downloader.cpp 2020-04-17 17:04:49.688606206 +0200
@@ -246,6 +246,7 @@
{
std::string email;
std::string password;
+ bool headless = false;
if (!Globals::globalConfig.sEmail.empty() && !Globals::globalConfig.sPassword.empty())
{
@@ -255,24 +256,32 @@
else
{
if (!isatty(STDIN_FILENO)) {
- std::cerr << "Unable to read email and password" << std::endl;
- return 0;
- }
- std::cerr << "Email: ";
- std::getline(std::cin,email);
+ /* Attempt to read this stuff from elsewhere */
+ bool cookie_gone = !(boost::filesystem::exists(Globals::globalConfig.curlConf.sCookiePath));
+ bool tokens_gone = !(boost::filesystem::exists(Globals::globalConfig.sConfigDirectory + "/galaxy_tokens.json"));
+ std::cout << Globals::globalConfig.curlConf.sCookiePath << std::endl;
+ std::cout << (Globals::globalConfig.sConfigDirectory + "/galaxy_tokens.json") << std::endl;
+ if(cookie_gone || tokens_gone) {
+ std::cerr << "Unable to read email and password" << std::endl;
+ return 0;
+ } else headless = true;
+ } else {
+ std::cerr << "Email: ";
+ std::getline(std::cin,email);
- std::cerr << "Password: ";
- struct termios termios_old, termios_new;
- tcgetattr(STDIN_FILENO, &termios_old); // Get current terminal attributes
- termios_new = termios_old;
- termios_new.c_lflag &= ~ECHO; // Set ECHO off
- tcsetattr(STDIN_FILENO, TCSANOW, &termios_new); // Set terminal attributes
- std::getline(std::cin, password);
- tcsetattr(STDIN_FILENO, TCSANOW, &termios_old); // Restore old terminal attributes
- std::cerr << std::endl;
+ std::cerr << "Password: ";
+ struct termios termios_old, termios_new;
+ tcgetattr(STDIN_FILENO, &termios_old); // Get current terminal attributes
+ termios_new = termios_old;
+ termios_new.c_lflag &= ~ECHO; // Set ECHO off
+ tcsetattr(STDIN_FILENO, TCSANOW, &termios_new); // Set terminal attributes
+ std::getline(std::cin, password);
+ tcsetattr(STDIN_FILENO, TCSANOW, &termios_old); // Restore old terminal attributes
+ std::cerr << std::endl;
+ }
}
- if (email.empty() || password.empty())
+ if ((email.empty() || password.empty()) && !headless)
{
std::cerr << "Email and/or password empty" << std::endl;
return 0;