mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-15 08:39:08 -05:00
fixed passwd handling in retroshare-service
This commit is contained in:
parent
3f21b4bf65
commit
116c7f1aec
4 changed files with 53 additions and 27 deletions
|
|
@ -112,7 +112,7 @@ NotifyQt::NotifyQt() : cDialog(NULL)
|
|||
mEventHandlerId = 0;
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType == RsEventType::SYSTEM_ERROR && dynamic_cast<const RsSystemEvent*>(event.get())->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED)
|
||||
if(event->mType == RsEventType::SYSTEM && dynamic_cast<const RsSystemEvent*>(event.get())->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED)
|
||||
sync_handleIncomingEvent(event);
|
||||
else
|
||||
RsQThreadUtils::postToObject([=](){ async_handleIncomingEvent(event); }, this );
|
||||
|
|
@ -165,7 +165,6 @@ void NotifyQt::notifyOwnAvatarChanged()
|
|||
#endif
|
||||
emit ownAvatarChanged() ;
|
||||
}
|
||||
#endif
|
||||
|
||||
class SignatureEventData
|
||||
{
|
||||
|
|
@ -237,8 +236,9 @@ void NotifyQt::handleSignatureEvent()
|
|||
working = false ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool NotifyQt::graphical_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password,bool& cancelled)
|
||||
bool NotifyQt::GUI_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad)
|
||||
{
|
||||
RsAutoUpdatePage::lockAllEvents() ;
|
||||
|
||||
|
|
@ -272,19 +272,18 @@ bool NotifyQt::graphical_askForPassword(const std::string& title, const std::str
|
|||
, Q_ARG(QLineEdit::EchoMode, textEchoMode)
|
||||
, Q_ARG(bool, modal)
|
||||
);
|
||||
cancelled = false ;
|
||||
//cancelled = false ;
|
||||
|
||||
RsAutoUpdatePage::unlockAllEvents() ;
|
||||
|
||||
if (ret.execReturn == QDialog::Rejected) {
|
||||
RsLoginHelper::clearPgpPassphrase();
|
||||
password.clear() ;
|
||||
cancelled = true ;
|
||||
//cancelled = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if (ret.execReturn == QDialog::Accepted) {
|
||||
password = ret.textValue.toUtf8().constData();
|
||||
auto password = ret.textValue.toUtf8().constData();
|
||||
RsLoginHelper::cachePgpPassphrase(password);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -292,7 +291,7 @@ bool NotifyQt::graphical_askForPassword(const std::string& title, const std::str
|
|||
RsLoginHelper::clearPgpPassphrase();
|
||||
return false;
|
||||
}
|
||||
bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, const std::string& plugin_file_hash, bool first_time)
|
||||
bool NotifyQt::GUI_askForPluginConfirmation(const std::string& plugin_file_name, const RsFileHash& plugin_file_hash, bool first_time)
|
||||
{
|
||||
// By default, when no information is known about plugins, just dont load them. They will be enabled from the GUI by the user.
|
||||
|
||||
|
|
@ -307,7 +306,7 @@ bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, con
|
|||
QString text ;
|
||||
text += tr( "RetroShare has detected an unregistered plugin. This happens in two cases:<UL><LI>Your RetroShare executable has changed.</LI><LI>The plugin has changed</LI></UL>Click on Yes to authorize this plugin, or No to deny it. You can change your mind later in Options -> Plugins, then restart." ) ;
|
||||
text += "<UL>" ;
|
||||
text += "<LI>Hash:\t" + QString::fromStdString(plugin_file_hash) + "</LI>" ;
|
||||
text += "<LI>Hash:\t" + QString::fromStdString(plugin_file_hash.toStdString()) + "</LI>" ;
|
||||
text += "<LI>File:\t" + QString::fromStdString(plugin_file_name) + "</LI>";
|
||||
text += "</UL>" ;
|
||||
|
||||
|
|
@ -319,10 +318,13 @@ bool NotifyQt::askForPluginConfirmation(const std::string& plugin_file_name, con
|
|||
|
||||
RsAutoUpdatePage::unlockAllEvents() ;
|
||||
|
||||
if (ret == QMessageBox::Yes)
|
||||
return true ;
|
||||
else
|
||||
return false;
|
||||
if (ret == QMessageBox::Yes)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
rsPlugins->disablePlugin(plugin_file_hash);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
|
|
@ -694,11 +696,9 @@ void NotifyQt::sync_handleIncomingEvent(std::shared_ptr<const RsEvent> event)
|
|||
auto ev6 = dynamic_cast<const RsSystemEvent*>(event.get());
|
||||
|
||||
if(ev6->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED)
|
||||
{
|
||||
std::string password;
|
||||
bool cancelled;
|
||||
graphical_askForPassword(ev6->passwd_request_title, ev6->passwd_request_key_details, ev6->passwd_request_prev_is_bad, password,cancelled);
|
||||
}
|
||||
GUI_askForPassword(ev6->passwd_request_title, ev6->passwd_request_key_details, ev6->passwd_request_prev_is_bad);
|
||||
else if(ev6->mEventCode == RsSystemEventCode::NEW_PLUGIN_FOUND)
|
||||
GUI_askForPluginConfirmation(ev6->plugin_file_name, ev6->plugin_file_hash, ev6->plugin_first_time);
|
||||
}
|
||||
|
||||
void NotifyQt::async_handleIncomingEvent(std::shared_ptr<const RsEvent> event)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class SignatureEventData ;
|
|||
struct TurtleFileInfo;
|
||||
struct TurtleGxsInfo;
|
||||
|
||||
class NotifyQt: public QObject, public NotifyClient
|
||||
class NotifyQt: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
@ -86,8 +86,9 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
// virtual void notifyHistoryChanged(uint32_t msgId, int type);
|
||||
|
||||
// virtual void notifyDiscInfoChanged() ;
|
||||
virtual bool graphical_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled);
|
||||
virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time);
|
||||
|
||||
virtual bool GUI_askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad);
|
||||
virtual bool GUI_askForPluginConfirmation(const std::string& plugin_filename, const RsFileHash& plugin_file_hash,bool first_time);
|
||||
|
||||
/* Notify from GUI */
|
||||
void notifyChatFontChanged();
|
||||
|
|
@ -146,7 +147,7 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
|
||||
private slots:
|
||||
void runningTick();
|
||||
void handleSignatureEvent() ;
|
||||
// void handleSignatureEvent() ;
|
||||
// void handleChatLobbyTimeShift(int) ;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -346,8 +346,8 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
|||
//
|
||||
RsControl::earlyInitNotificationSystem() ;
|
||||
|
||||
NotifyQt *notify = NotifyQt::Create();
|
||||
rsNotify->registerNotifyClient(notify);
|
||||
//NotifyQt *notify = NotifyQt::Create();
|
||||
//rsNotify->registerNotifyClient(notify);
|
||||
|
||||
/* RetroShare Core Objects */
|
||||
RsInit::InitRsConfig();
|
||||
|
|
|
|||
|
|
@ -71,7 +71,29 @@ std::string colored(int color,const std::string& s)
|
|||
}
|
||||
}
|
||||
|
||||
static void eventHandler(std::shared_ptr<const RsEvent> e)
|
||||
{
|
||||
auto fe = dynamic_cast<const RsSystemEvent*>(e.get());
|
||||
|
||||
if(!fe)
|
||||
return;
|
||||
|
||||
#ifdef RS_SERVICE_TERMINAL_LOGIN
|
||||
if(fe->mEventCode == RsSystemEventCode::PASSWORD_REQUESTED)
|
||||
{
|
||||
std::string question1 = fe->passwd_request_title + colored(COLOR_GREEN,"Please enter your PGP password for key:\n ") + fe->passwd_request_key_details + " :";
|
||||
std::string password = RsUtil::rs_getpass(question1.c_str()) ;
|
||||
|
||||
if(!password.empty())
|
||||
RsLoginHelper::cachePgpPassphrase(password);
|
||||
}
|
||||
#endif
|
||||
|
||||
// We should also handle plugin loading
|
||||
}
|
||||
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
class RsServiceNotify: public NotifyClient
|
||||
{
|
||||
public:
|
||||
|
|
@ -86,7 +108,7 @@ public:
|
|||
password = RsUtil::rs_getpass(question1.c_str()) ;
|
||||
cancel = false ;
|
||||
|
||||
return !password.empty();
|
||||
return !password.empty();
|
||||
}
|
||||
};
|
||||
#endif // def RS_SERVICE_TERMINAL_LOGIN
|
||||
|
|
@ -149,6 +171,9 @@ int main(int argc, char* argv[])
|
|||
RsInit::InitRsConfig();
|
||||
RsControl::earlyInitNotificationSystem();
|
||||
|
||||
RsEventsHandlerId_t EventHandlerId = 0;
|
||||
rsEvents->registerEventsHandler(eventHandler,EventHandlerId, RsEventType::SYSTEM);
|
||||
|
||||
#ifdef __APPLE__
|
||||
// TODO: is this still needed with argstream?
|
||||
/* HACK to avoid stupid OSX Finder behaviour
|
||||
|
|
@ -330,8 +355,8 @@ int main(int argc, char* argv[])
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
RsServiceNotify* notify = new RsServiceNotify();
|
||||
rsNotify->registerNotifyClient(notify);
|
||||
//RsServiceNotify* notify = new RsServiceNotify();
|
||||
//rsNotify->registerNotifyClient(notify);
|
||||
|
||||
// supply empty passwd so that it is properly asked 3 times on console
|
||||
RsInit::LoadCertificateStatus result = rsLoginHelper->attemptLogin(ssl_id, "");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue