コード例 #1
0
ファイル: UserInputUtils.cpp プロジェクト: ccwls3290/sinit
UString GetPassword(CStdOutStream *outStream,bool verify)
{
#ifdef USE_FLTK 
  const char *r = fl_password("Enter password", 0);
  AString oemPassword = "";
  if (r) oemPassword = r;
#else /* USE_FLTK */
/*
#ifdef ENV_HAVE_GETPASS
  (*outStream) << "\nEnter password (will not be echoed) :";
  outStream->Flush();
  AString oemPassword = getpass("");
  if (verify)
  {
    (*outStream) << "Verify password (will not be echoed) :";
  outStream->Flush();
    AString oemPassword2 = getpass("");
    if (oemPassword != oemPassword2) throw "password verification failed";
  }
#else
*/
  (*outStream) << "\nEnter password:";
  outStream->Flush();
  AString oemPassword = g_StdIn.ScanStringUntilNewLine();
//#endif
#endif /* USE_FLTK */
  return MultiByteToUnicodeString(oemPassword, CP_OEMCP);
}
コード例 #2
0
const char *CFLTKDirDialog::AskPassword(CSuTerm *suterm)
{
    const char *ret = NULL;

    while (true)
    {
        ret = fl_password(GetTranslation("Your account doesn't have permissions to "
                                         "create the directory.\nTo create it with the root "
                                         "(administrator) account, please enter the administrative password below."));

        if (!ret || !ret[0])
            break;

        try
        {
            if (!suterm->TestPassword(ret))
                fl_alert(GetTranslation("Incorrect password given, please retype."));
            else
                break;
        }
        catch (Exceptions::CExIO &e)
        {
            fl_alert(e.what());
            break;
        }
    }

    return ret;
}
コード例 #3
0
const char *CFLTKDirDialog::AskPassword(LIBSU::CLibSU &suhandler)
{
    const char *ret = NULL;
    
    while (true)
    {
        ret = fl_password(GetTranslation("Your account doesn't have permissions to "
                "create the directory.\nTo create it with the root "
                "(administrator) account, please enter it's password below."));

        if (!ret || !ret[0])
            break;

        if (!suhandler.TestSU(ret))
        {
            if (suhandler.GetError() == LIBSU::CLibSU::SU_ERROR_INCORRECTPASS)
                fl_alert(GetTranslation("Incorrect password given for root user\nPlease retype"));
            else
            {
                fl_alert(GetTranslation("Could not use su to gain root access.\n"
                        "Make sure you can use su (adding the current user to the wheel group may help)."));
                break;
            }
        }
        else
            break;
    }
    
    return ret;
}
コード例 #4
0
ファイル: UserInputUtils.cpp プロジェクト: farruggia/7zip
UString GetPassword(CStdOutStream *outStream,bool verify)
{
#ifdef USE_FLTK 
  const char *r = fl_password("Enter password", 0);
  AString oemPassword = "";
  if (r) oemPassword = r;
  return MultiByteToUnicodeString(oemPassword, CP_OEMCP);
#else /* USE_FLTK */
  if (outStream)
  {
    *outStream << "\nEnter password"
      #ifdef MY_DISABLE_ECHO
      " (will not be echoed)"
      #endif
      ":";
    outStream->Flush();
  }
#ifdef ENV_HAVE_GETPASS
  AString oemPassword = getpass("");
  if ( (verify) && (outStream) )
  {
    (*outStream) << "Verify password (will not be echoed) :";
    outStream->Flush();
    AString oemPassword2 = getpass("");
    if (oemPassword != oemPassword2) throw "password verification failed";
  }
  return MultiByteToUnicodeString(oemPassword, CP_OEMCP);
#else
  return g_StdIn.ScanUStringUntilNewLine();
#endif
#endif /* USE_FLTK */
}