/*************************************************************************** * Copyright (C) 2004 by Christoph Thielecke * * crissi99@gmx.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program 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 General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ //BEGIN INCLUDES #include "kvpncconfig.h" #include "utils.h" #include "kvpncimportprofileselectiondialog.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //END INCLUDES KVpncConfig::KVpncConfig(QWidget *parent,KStatusBar *statusbar) { this->parent = parent; this->statusbar = statusbar; pathToVpnc = ""; pathToCiscoVpnc = ""; pathToRacoon = ""; pathToRacoonctl = ""; pathToSetkey = ""; pathToIpsec = ""; pathToPppd=""; pathToPptp=""; pathToL2tpd=""; pathToXl2tpd=""; pathToSsh="/usr/bin/ssh"; pathToKill=""; pathToKillall=""; pathToPing=""; pathToOpenvpn=""; pathToIp="/sbin/ip"; pathToIfconfig="/sbin/ifconfig"; pathToRoute="/sbin/route"; pathToNetstat="/bin/netstat"; pathToL2tpd="/usr/sbin/l2tpd"; pathToPkcs11Tool="/usr/bin/pkcs11-tool"; pathToVtund="/usr/sbin/vtund"; pathToCiscoCertMgr="/usr/local/bin/cisco_cert_mgr"; pathToTail="/usr/bin/tail"; pathToSsh="/usr/bin/ssh"; pathToKsshAskpass="/usr/bin/ksshaskpass"; pathToGnomeSshAskpass="/usr/lib/openssh/gnome-ssh-askpass"; AutoConnectProfile=""; Vpnc_pid_file = ""; Pppd_pid_file = ""; lastProfile = ""; logfileName = ""; InterpreterShell="/bin/bash"; TmpPassword=""; TmpGroupPassword=""; TmpUsername=""; TmpPrivKeyPassStr=""; TmpGatewayIP=""; TmpXauthInterPasscode=""; TmpPrivateKeyPass=""; TmpHttpProxyPassword=""; DnsDevice = ""; OldDefaultGw=""; OldDefaultDev=""; connectSleepDelay = 15; connectSleepRetry = 0; tryConnectTimeout = 10; runningCheckCounter = 0; runningCheckTimeout = 60; mainwindow_pos_x=0; mainwindow_pos_y=0; mainwindow_height=200; mainwindow_width=400; AuthRetryCount=0; PppdKernelLogLevel=0; maxConnectRetry=3; currentConnectRetry=0; OpenvpnManagementPort=2222; minimizeAfterConnect = true; //showDebugConsole = false; useDefaultPaths = false; writeLogFile = true; useSilentQuit = false; holdGeneratedScripts = true; enableDebugPppd=false; enableDebugPptpd=false; enableDebugL2tpd=false; enableDebugXl2tpd=false; enableDebugXl2tpdNetwork=false; enableDebugXl2tpdpacket=false; enableDebugXl2tpdstate=false; enableDebugXl2tpdtunnel=false; enableDebugOpenvpn=false; useColorizedLogOutput=true; showInterfaceIPinTooltip=true; dontQuitOnCloseEvent=true; PppdDebugLevel = false; doAutoConnectAtStartup=false; useKwallet=true; showStatusBar=true; showToolBar=true; firstUseOfKwallet=true; shutdownIsCalled=false; skipKwalletStoring = false; hideOnCloseInfo = false; enableFreeswanVerbose=false; doKillL2tpdIfStillRunning=true; doKillRacoonIfStillRunning=true; hideMainWindow=false; showInterfaceIPinTooltip = true; showConnectionTimeInTooltip = true; OpenvpnNeedSecurityParameter = false; haveUserData=false; prefDlgOpen=false; VpncDebugLevel = 0; RacoonDebugLevel = "info"; KvpncDebugLevel = 0; OpenvpnDebugLevel =0; LogViewerFontSize=0; // can be from -3 up to +3 DebugBackgroundcolor=black; ToolList = new QPtrList(); ToolList->setAutoDelete( TRUE ); AccountList = new QPtrList(); AccountList->setAutoDelete( TRUE ); // the list owns the objects InfoLogColor=Qt::black; ErrorLogColor=Qt::red; SuccessLogColor=Qt::darkGreen; DebugLogColor=Qt::yellow; KStandardDirs *dirs = KGlobal::dirs(); logfileName = QString(dirs->saveLocation( "data" )); QString logfilePath = QString(logfileName + "/kvpnc/kvpnc.log"); logfile.setName( logfilePath ); logFileStream.setDevice( &logfile ); currentProfile=0L; } KVpncConfig::~KVpncConfig() { delete AccountList; delete ToolList; } void KVpncConfig::setLogOutput(QTextEdit *LogOutput) { this->LogOutput = LogOutput; } void KVpncConfig::appendLogEntry( QString msg, LogType type ) { // write to logfile if ( writeLogFile ) { if ( !logfile.isOpen() ) { KStandardDirs * dirs = KGlobal::dirs(); QString logfileName = dirs->saveLocation( "data" ); logfileName += "/kvpnc/kvpnc.log"; // /root.kde/share/apps/kvpnc.log // KMessageBox::information( this, logfileName, "info" ); logfile.setName( logfileName ); if ( !logfile.open( IO_WriteOnly | IO_Append ) ) KMessageBox::error( 0, i18n( "Log file can not be opened!" ) ); else { // QTextStream s( &logfile ); logFileStream << i18n( "Log session started at: " ); logFileStream << QDateTime::currentDateTime().toString( Qt::TextDate ); logFileStream << "\n"; logfile.flush(); } } else { QString date = QDate().currentDate().toString(Qt::ISODate)+ " "; QString time = QTime().currentTime().toString(Qt::ISODate)+ " "; QString prefix=""; switch ( type ) { case info: prefix=i18n("info")+": "; break; case remote: prefix=i18n("remote")+": "; break; case error: prefix=i18n("error")+": "; break; case success: prefix=i18n("success")+": "; break; case debug: prefix=i18n("debug")+": "; break; } // appPointer->processEvents(); logFileStream << date << time << prefix << msg << "\n"; logfile.flush(); // appPointer->processEvents(); } } // write into debug console QString prefix=""; QString postfix=""; // font size prefix+=""; postfix+="<\\font>"; if (useColorizedLogOutput) prefix+=""; } prefix+=i18n("info")+": "; break; case remote: if (useColorizedLogOutput) { prefix+=RemoteLogColor.name(); prefix+="\">"; } prefix+=i18n("remote")+": "; break; case error: if (useColorizedLogOutput) { prefix+=ErrorLogColor.name(); prefix+="\">"; } prefix+=i18n("error")+": "; break; case success: if (useColorizedLogOutput) { prefix+=SuccessLogColor.name(); prefix+="\">"; } prefix+=i18n("success")+": "; break; case debug: if (useColorizedLogOutput) { prefix+=DebugLogColor.name(); prefix+="\">"; } prefix+=i18n("debug")+": "; break; } if (useColorizedLogOutput) postfix+=""; LogOutput->append( prefix+msg+postfix ); // if (appPointer->hasPendingEvents ()) // appPointer->processEvents(); } void KVpncConfig::slotStatusMsg( const QString &text, int id ) { if ( id != ID_FLASH_MSG ) { statusbar ->clear(); statusbar ->changeItem( text, id ); } else { statusbar->message( text, 2000 ); } } void KVpncConfig::saveOptions(bool saveOneProfile, QString Profile) { if (saveOneProfile && Profile.isEmpty()) return; KStandardDirs * dirs = KGlobal::dirs(); QString filePath = dirs->findResource ( "config", "kvpncrc" ); QFile::remove ( filePath ); config->setGroup( "Notification Messages" ); config->writeEntry( "hideOnCloseInfo" ,hideOnCloseInfo); if (!saveOneProfile) { config->setGroup( "General Options" ); checkStandardPathValues(); config->writeEntry( "Minimize after connect", minimizeAfterConnect ); config->writeEntry("Hide on startup", hideMainWindow ); config->writeEntry( "Use silent quit", useSilentQuit ); config->writeEntry( "Dont quit on CloseEvent", dontQuitOnCloseEvent ); config->writeEntry( "Enable pppd debug", enableDebugPppd ); config->writeEntry( "Enable pptpd debug", enableDebugPptpd ); config->writeEntry( "Enable l2tpd debug", enableDebugL2tpd ); config->writeEntry( "Enable xl2tpd debug", enableDebugXl2tpd ); config->writeEntry( "Enable openl2tp debug", enableDebugOpenl2tp ); config->writeEntry( "Enable FreeSWAN verbose", enableFreeswanVerbose ); config->writeEntry( "Pluto Debug", PlutoDebug.join(" ")); config->writeEntry( "Klips Debug", KlipsDebug.join(" ")); config->writeEntry( "Show debugconsole", showDebugConsole ); config->writeEntry( "Pid file for vpnc ", Vpnc_pid_file ); config->writeEntry( "Vpnc debuglevel", VpncDebugLevel ); config->writeEntry( "Racoon debuglevel", RacoonDebugLevel ); config->writeEntry( "Kvpnc debuglevel", KvpncDebugLevel ); config->writeEntry( "Pppd debuglevel", PppdDebugLevel ); config->writeEntry( "Openvpn debuglevel", OpenvpnDebugLevel ); config->writeEntry( "Pptp debuglevel", PptpLogLevel ); config->writeEntry( "Ssh debuglevel", SshDebugLevel ); config->writeEntry( "Pppd kernel log level", PppdKernelLogLevel ); config->writeEntry( "Path to vpnc-bin", pathToVpnc ); config->writeEntry( "Path to vpnclient", pathToCiscoVpnc ); config->writeEntry( "Path to racoon", pathToRacoon ); config->writeEntry( "Path to racoonctl", pathToRacoonctl ); config->writeEntry( "Path to setkey", pathToSetkey ); config->writeEntry( "Path to iptables", pathToIptables ); config->writeEntry( "Path to openssl", pathToOpenssl ); config->writeEntry( "Path to freeswan", pathToIpsec ); config->writeEntry( "Path to pppd", pathToPppd ); config->writeEntry( "Path to pptp", pathToPptp ); config->writeEntry( "Path to l2tpd", pathToL2tpd ); config->writeEntry( "Path to xl2tpd", pathToXl2tpd ); config->writeEntry( "Path to openl2tp", pathToOpenl2tp ); config->writeEntry( "Path to kill", pathToKill ); config->writeEntry( "Path to kill-all", pathToKillall ); config->writeEntry( "Path to ping", pathToPing ); config->writeEntry( "Path to openvpn", pathToOpenvpn ); config->writeEntry( "Path to iputility", pathToIp ); config->writeEntry( "Path to ifconfig", pathToIfconfig ); config->writeEntry( "Path to route", pathToRoute ); config->writeEntry( "Path to netstat", pathToNetstat ); config->writeEntry( "Path to pkcs11-tool", pathToPkcs11Tool ); config->writeEntry( "Path to vtund", pathToVtund ); config->writeEntry( "Path to cisco_cert_mgr",pathToCiscoCertMgr); config->writeEntry( "Path to tail",pathToTail); config->writeEntry( "Path to ssh",pathToSsh); config->writeEntry( "Path to ksshaskpass",pathToKsshAskpass); config->writeEntry( "Path to ssh-askpass-gnome",pathToGnomeSshAskpass); config->writeEntry( "Show Statusbar", showStatusBar ); config->writeEntry( "Try connect timeout", tryConnectTimeout ); config->writeEntry( "Last Profile", lastProfile ); config->writeEntry( "Write log file", writeLogFile ); config->writeEntry( "Hold generated scripts", holdGeneratedScripts ); config->writeEntry( "Programs in path", programsInPath ); config->writeEntry( "Info logwindow color", InfoLogColor ); config->writeEntry( "Remote logwindow color", RemoteLogColor ); config->writeEntry( "Error logwindow color", ErrorLogColor ); config->writeEntry( "Success logwindow color", SuccessLogColor ); config->writeEntry( "Debug logwindow color", DebugLogColor ); config->writeEntry("Debug background color", DebugBackgroundcolor ); config->writeEntry( "Use colorized log output", useColorizedLogOutput ); config->writeEntry( "Show interface IP in tooltip", showInterfaceIPinTooltip ); config->writeEntry( "Auto connect profile", AutoConnectProfile ); config->writeEntry( "Do auto connect at startup", doAutoConnectAtStartup ); config->writeEntry( "Log viewer font size", LogViewerFontSize ); config->writeEntry( "Mainwindow width", parent->width() ); config->writeEntry( "Mainwindow height", parent->height() ); config->writeEntry( "Mainwindow position x", parent->x() ); config->writeEntry( "Mainwindow position y", parent->y() ); config->writeEntry("Openvpn management port", OpenvpnManagementPort ); //config->writeEntry( "ToolBar Settings" ,parent->toolBar( "mainToolBar" )); config->writeEntry("Use KWallet",useKwallet); config->writeEntry("FeedbackMailSent",feedbackMailSent); config->writeEntry("Do kill l2tpd if still running",doKillL2tpdIfStillRunning); config->writeEntry("Do kill racoon if still running",doKillRacoonIfStillRunning); config->writeEntry("Do kill xl2tpd if still running",doKillXl2tpdIfStillRunning); config->writeEntry("Show connection time in Tooltip",showConnectionTimeInTooltip); config->writeEntry("Enable debug Openvpn",enableDebugOpenvpn); config->writeEntry("EnableDebugXl2tpdNetwork",enableDebugXl2tpdNetwork); config->writeEntry("EnableDebugXl2tpdpacket",enableDebugXl2tpdpacket); config->writeEntry("EnableDebugXl2tpdstate",enableDebugXl2tpdstate); config->writeEntry("EnableDebugXl2tpdtunnel",enableDebugXl2tpdtunnel); //appPointer->processEvents(); } if (useKwallet && KWallet::Wallet::isEnabled()) config->writeEntry( "First use of Kwallet", false ); /* = user data = */ VpnAccountData *it; if ( !AccountList->isEmpty() ) { /* passwords with kwallet */ if ( useKwallet && KWallet::Wallet::isEnabled()) { if (!skipKwalletStoring ) { if (KvpncDebugLevel > 2) appendLogEntry(i18n( "Wallet enabled and available, writing to wallet." ),debug); // Open local wallet wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet()); //appPointer->processEvents(); if (wallet != 0) { } } } else { if (KvpncDebugLevel > 2) appendLogEntry(i18n( "Wallet disabled or not available, writing to config file." ),debug); } QPtrList *TmpAccountList; if (!saveOneProfile) TmpAccountList = AccountList; else { TmpAccountList = new QPtrList(); TmpAccountList->setAutoDelete( TRUE ); // the list owns the objects VpnAccountData *ProfileData; for ( ProfileData = AccountList->first(); it; it = AccountList->next() ) { if ( ProfileData->getName() == Profile ) { TmpAccountList->append(ProfileData); break; } } } for ( it = TmpAccountList->first(); it; it = TmpAccountList->next() ) { // appPointer->processEvents(); // std::cout << "Save profile: " << it->getName().ascii() << std::endl; if ( !it->getName().isEmpty() ) { QString name = it->getName(); QString ProfileName = "Profile_"; ProfileName += name; config->setGroup( ProfileName ); config->writeEntry("Description",it->getDescription()); /* passwords with kwallet */ if ( useKwallet && KWallet::Wallet::isEnabled()) { if (!skipKwalletStoring ) { if (KvpncDebugLevel > 2) appendLogEntry(i18n( "Wallet enabled and available, writing to wallet." ),debug); if (wallet != 0) { QString walletname="kvpnc"; // Check if folder exists, otherwise create it bool walletOK=true; if (!wallet->hasFolder(walletname)) { walletOK = wallet->createFolder(walletname); // wallet->sync(); // appPointer->processEvents(); } if (walletOK) { wallet->setFolder(walletname); // appPointer->processEvents(); //std::cout << "[set] account: " << ProfileName << ", loginname: " << loginname << ", password: " << pwd << std::endl; bool UserPasswordOK=true; if ( it->getSaveUserPassword() ) UserPasswordOK = (wallet->writePassword (QString(name+"__user_pw"), it->getUserPassword()) == 0); else UserPasswordOK = (wallet->writePassword (QString(name+"__user_pw"), "") == 0); // wallet->sync(); // appPointer->processEvents(); bool PskOK=true; if ( it->getSavePsk() ) PskOK = (wallet->writePassword (QString(name+"__psk"), it->getPreSharedKey()) == 0); else PskOK = (wallet->writePassword (QString(name+"__psk"), "") == 0); // wallet->sync(); // appPointer->processEvents(); bool PskKeyPassOK = (wallet->writePassword (QString(name+"__priv_key_pwd"), it->getPrivateKeyPass()) == 0); // // wallet->sync(); // appPointer->processEvents(); if (KvpncDebugLevel > 2) { if (UserPasswordOK) if (KvpncDebugLevel > 2) appendLogEntry(i18n( "write of %1 was ok." ).arg(i18n("user password")), debug); else { // if ( KMessageBox::warningContinueCancel( 0, // i18n( "KVpnc is unable to save %1 password securely in your wallet.
" // "Do you want to save the password in the unsafe configuration file instead?" ).arg(i18n("user password")), // i18n( "Unable to store secure %1" ).arg(i18n("user password")), // KGuiItem( i18n( "Store &Unsafe" ), QString::fromLatin1( "unlock" ),QString::fromLatin1( "KWalletFallbackToKConfig" ) ) ) == KMessageBox::Continue ) // { // config->writeEntry( "User password", it->getUserPassword() ); // } appendLogEntry(i18n( "write of %1 has failed." ).arg(i18n("user password")), error); } if (PskOK) if (KvpncDebugLevel > 2) appendLogEntry(i18n( "write of %1 was successful." ).arg(i18n("preshared key")), debug); else { // if ( KMessageBox::warningContinueCancel( 0, // i18n( "KVpnc is unable to save %1 password securely in your wallet.
" // "Do you want to save the password in the unsafe configuration file instead?" ).arg(i18n("pre shared key")), // i18n( "Unable to store secure %1" ).arg(i18n("pre shared key")), // KGuiItem( i18n( "Store &Unsafe" ), QString::fromLatin1( "unlock" ),QString::fromLatin1( "KWalletFallbackToKConfig" ) ) ) == KMessageBox::Continue ) // { // config->writeEntry( "Pre shared key", it->getPreSharedKey() ); // } appendLogEntry(i18n( "write of %1 has failed." ).arg(i18n("preshared key")),error); } if (PskOK) if (KvpncDebugLevel > 2) appendLogEntry(i18n( "write of %1 was successful." ).arg(i18n("preshared key")), debug); else { // if ( KMessageBox::warningContinueCancel( 0, // i18n( "KVpnc is unable to save %1 password securely in your wallet.
" // "Do you want to save the password in the unsafe configuration file instead?" ).arg(i18n("preshared key password")), // i18n( "Unable to store secure %1" ).arg(i18n("reshared key password")), // KGuiItem( i18n( "Store &Unsafe" ), QString::fromLatin1( "unlock" ),QString::fromLatin1( "KWalletFallbackToKConfig" ) ) ) == KMessageBox::Continue ) // { // config->writeEntry( "Pre shared key", it->getPreSharedKey() ); // } appendLogEntry(i18n( "write of %1 has failed." ).arg(i18n("preshared key")),error); } if (PskKeyPassOK) if (KvpncDebugLevel > 2) appendLogEntry(i18n( "write of %1 was successful." ).arg(i18n("preshared key password")), debug); else { // if ( KMessageBox::warningContinueCancel( 0, // i18n( "KVpnc is unable to save %1 password securely in your wallet.
" // "Do you want to save the password in the unsafe configuration file instead?" ).arg(i18n("preshared key password")), // i18n( "Unable to store secure %1" ).arg(i18n("reshared key password")), // KGuiItem( i18n( "Store &Unsafe" ), QString::fromLatin1( "unlock" ),QString::fromLatin1( "KWalletFallbackToKConfig" ) ) ) == KMessageBox::Continue ) // { // config->writeEntry( "Pre shared key", it->getPreSharedKey() ); // } appendLogEntry(i18n( "write of %1 has failed." ).arg(i18n("preshared key password")),error); } //std::cout << "success: " << pwdOK << std::endl; } // appPointer->processEvents(); // wallet->sync(); } else { KMessageBox::error( 0, i18n( "Unable to create wallet folder for kvpnc!" ) ); appendLogEntry(i18n( "Unable to create wallet folder for kvpnc!" ), error); } } } else //sessionSaving neither writing to wallet nor to config-file { if (KvpncDebugLevel > 2) appendLogEntry(i18n( "Writing into Wallet is not possible at shutdown, skipping." ),debug); } } else { //Wallet not available //if (!useKwallet) { if (KvpncDebugLevel > 2) appendLogEntry(i18n( "Wallet disabled or not available, writing to config file." ),debug); // write passwords to config file :| if ( it->getSaveUserPassword() ) { config->writeEntry( "User password", it->getUserPassword() ); } if ( it->getSavePsk() ) { config->writeEntry( "Pre shared key", it->getPreSharedKey() ); } config->writeEntry( "PrivateKey password", it->getPrivateKeyPass() ); } } // appPointer->processEvents(); // KMessageBox::information(0,"connection type changed: "+QString().setNum(it->getConnectionType())+QString(" ")+it->getName(),QString("type set")); // normal config if ( it->getConnectionType() == VpnAccountData::cisco ) config->writeEntry( "Connection type", "cisco" ); else if ( it->getConnectionType() == VpnAccountData::ciscoorig ) config->writeEntry( "Connection type", "ciscoorig" ); else if ( it->getConnectionType() == VpnAccountData::racoon ) config->writeEntry( "Connection type", "racoon" ); else if ( it->getConnectionType() == VpnAccountData::l2tpd_racoon ) config->writeEntry( "Connection type", "l2tpd (racoon)" ); else if ( it->getConnectionType() == VpnAccountData::freeswan ) config->writeEntry( "Connection type", "freeswan" ); else if ( it->getConnectionType() == VpnAccountData::l2tpd_freeswan ) config->writeEntry( "Connection type", "l2tpd (openswan)" ); else if ( it->getConnectionType() == VpnAccountData::pptp ) config->writeEntry( "Connection type", "pptp" ); else if ( it->getConnectionType() == VpnAccountData::openvpn ) config->writeEntry( "Connection type", "openvpn" ); else if ( it->getConnectionType() == VpnAccountData::vtun ) config->writeEntry( "Connection type", "vtun" ); else if ( it->getConnectionType() == VpnAccountData::ssh ) config->writeEntry( "Connection type", "ssh" ); else config->writeEntry( "Connection type", "other" ); config->writeEntry( "VPN Gateway", it->getGateway() ); config->writeEntry( "VPN ID", it->getID() ); config->writeEntry( "Username", it->getUserName() ); config->writeEntry( "Save user password", it->getSaveUserPassword() ); config->writeEntry( "Save PSK", it->getSavePsk() ); config->writeEntry( "Save private key password", it->getSavePrivateKeyPassword() ); config->writeEntry( "Private key", it->getPrivateKey() ); config->writeEntry( "Use advanced settings", it->getUseAdvancedSettings() ); config->writeEntry( "Application version", it->getApplicationVersion() ); config->writeEntry( "Local port", it->getLocalPort() ); config->writeEntry( "Remote port", it->getRemotePort() ); config->writeEntry( "NT domain name", it->getNtDomainName() ); config->writeEntry( "Perfect forward secrety", it->getPerfectForwardSecrety() ); config->writeEntry( "IKE group", it->getIkeGroup() ); config->writeEntry( "Use application version", it->getUseApplicationVersion() ); config->writeEntry( "Use global IPSec secret", it->getUseGlobalIpsecSecret() ); config->writeEntry( "Use IKE group", it->getUseIkeGroup() ); config->writeEntry( "Use local port", it->getUseLocalPort() ); config->writeEntry( "Use remote port", it->getUseRemotePort() ); config->writeEntry( "Use NT domain name", it->getUseNtDomainName() ); config->writeEntry( "Use single DES", it->getUseSingleDes() ); config->writeEntry( "Use perfect Forward Secrety", it->getUsePerfectForwardSecrety() ); config->writeEntry( "Remote net address", it->getRemoteNetAddr() ); config->writeEntry( "Remote net mask", it->getRemoteNetMask() ); config->writeEntry( "x509 certificate", it->getX509Certificate() ); config->writeEntry( "Ca certificate", it->getCaCertificate() ); config->writeEntry( "Network device", it->getNetworkDevice() ); config->writeEntry( "Cert path", it->getCertPath() ); // // fix bad type // if ((it->getConnectionType() == VpnAccountData::pptp || it->getConnectionType() == VpnAccountData::openvpn || it->getConnectionType() == VpnAccountData::racoon || it->getConnectionType() == VpnAccountData::l2tpd_racoon || it->getConnectionType() == VpnAccountData::freeswan || it->getConnectionType() == VpnAccountData::l2tpd_freeswan || it->getConnectionType() == VpnAccountData::vtun) && ( it->getAuthType() != "cert" || it->getAuthType() != "psk")) // { // it->setAuthType( VpnAccountData::cert); // } if ( it->getAuthType() == VpnAccountData::cert ) config->writeEntry( "Auth type", "cert" ); else if ( it->getAuthType() == VpnAccountData::psk ) config->writeEntry( "Auth type", "psk" ); else if ( it->getAuthType() == VpnAccountData::hybrid ) config->writeEntry( "Auth type", "hybrid" ); else config->writeEntry( "Auth type", "unknownauth" ); config->writeEntry( "do ping ip", it->getDoPingIP() ); config->writeEntry( "Ping host IP", it->getPingHostIP() ); // appPointer->processEvents(); config->writeEntry( "Use special remote ID", it->getUseSpecialRemoteID() ); config->writeEntry( "Use special local ID", it->getUseSpecialLocalID() ); config->writeEntry( "Special server certificate", it->getSpecialServerCertificate() ); config->writeEntry( "Use special server certificate", it->getUseSpecialServerCertificate() ); config->writeEntry( "Special remote ID", it->getSpecialRemoteID() ); config->writeEntry( "Special local ID", it->getSpecialLocalID() ); config->writeEntry( "Local ID type", it->getLocalIDType() ); config->writeEntry( "Remote ID type", it->getRemoteIDType() ); config->writeEntry( "Use UDP-protocol", it->getUseUdp() ); config->writeEntry( "Use UDP-port", it->getUseUdpPort() ); config->writeEntry( "local UDP port", it->getUdpPort() ); config->writeEntry( "use DNS_UPDATE", it->getUseDnsUpdate() ); config->writeEntry( "use DNS-server", it->getUseDnsServer() ); config->writeEntry( "DNS server", it->getDnsServer() ); config->writeEntry( "refuse 40 bit encryption", it->getRefuse40BitEncryption() ); config->writeEntry( "refuse 128 bit encryption", it->getRefuse128BitEncryption() ); config->writeEntry( "require stateless encryption", it->getAllowStatefulMode() ); config->writeEntry( "require mppe", it->getRequireMppe() ); config->writeEntry( "Disable MPPE compression", it->getDisableMPPEComp() ); config->writeEntry( "Local virtual IP", it->getLocalVirtualIP() ); config->writeEntry( "Remote virtual IP", it->getRemoteVirtualIP() ); config->writeEntry( "Pre shared key file", it->getPreSharedKeyFile() ); config->writeEntry( "Execute command before connect", it->getExecuteCmdBeforeConnect() ); config->writeEntry( "Execute command after connect", it->getExecuteCmdAfterConnect() ); config->writeEntry( "Execute command before disconnect", it->getExecuteCmdBeforeDisconnect() ); config->writeEntry( "Execute command after disconnect", it->getExecuteCmdAfterDisconnect() ); config->writeEntry( "Command before connect", it->getCommandBeforeConnect() ); config->writeEntry( "Command after connect", it->getCommandAfterConnect() ); config->writeEntry( "Command before disconnect", it->getCommandBeforeDisconnect() ); config->writeEntry( "Command after disconnect", it->getCommandAfterDisconnect() ); config->writeEntry( "Use no BSD compression", it->getUseNoBsdComp() ); config->writeEntry( "Do not use no IP by default", it->getUseNoIpDefault()); config->writeEntry( "Use no deflate", it->getUseNoDeflate() ); config->writeEntry( "Replace default route", it->getReplaceDefaultRoute() ); config->writeEntry( "Use own MTU", it->getUseMtu() ); config->writeEntry( "Use own MRU", it->getUseMru() ); config->writeEntry( "MTU for pppd", it->getMtu() ); config->writeEntry( "MRU for pppd", it->getMru() ); config->writeEntry( "Use virtual IP", it->getUseVirtualIP() ); config->writeEntry( "Virtual IP", it->getVirtualIP() ); config->writeEntry( "PSK is in file", it->getPskIsInFile() ); config->writeEntry( "Use additional network routes", it->getUseAdditionalNetworkRoutes() ); config->writeEntry( "Hash algorithm", it->getHashAlgo() ); config->writeEntry( "Encryption algorithm", it->getEncryptionAlgorithm() ); config->writeEntry( "Authentication algorithm", it->getAuthenticationAlgorithm() ); config->writeEntry( "Tunnel device type", it->getTunnelDeviceType() ); config->writeEntry( "Use userdefined port", it->getUseUserdefinedPort() ); config->writeEntry( "Userdefined port", it->getUserdefinedPort() ); config->writeEntry( "NS cert type", it->getNsCertType() ); config->writeEntry( "Use NS cert type", it->getUseNsCertType() ); config->writeEntry( "Use connection status check", it->getUseConnectionStatusCheck() ); config->writeEntry( "Connection check success count", it->getConnectionStatusCheckSuccessCount() ); config->writeEntry( "Connection check status interval", it->getConnectionStatusInterval() ); config->writeEntry( "Do reconnect after connection lost", it->getDoReconnectAfterConnectionLost()); config->writeEntry( "Disable LZO compression", it->getDisableLzoCompression()); config->writeEntry( "AuthWithUsernameAndPassword", it->getAuthWithUsernameAndPassword() ); config->writeEntry( "AllowEmptyGroupPassword", it->getAllowEmptyGroupPassword() ); config->writeEntry( "Use userdefinied cipher", it->getUseUserdefiniedCipher() ); config->writeEntry( "Userdefinied cipher", it->getUserdefiniedCipher() ); config->writeEntry( "Use redirect gateway", it->getUseRedirectGateway() ); // appPointer->processEvents(); config->writeEntry( "Use TLS auth", it->getUseTlsAuth() ); config->writeEntry( "TLS auth file", it->getTlsAuthFile() ); config->writeEntry( "Use HTTP proxy", it->getUseHttpProxy() ); config->writeEntry( "HTTP proxy host", it->getHttpProxy() ); config->writeEntry( "HTTP proxy port", it->getHttpProxyPort() ); config->writeEntry( "HTTP proxy timeout", it->getHttpProxyTimeout() ); config->writeEntry( "Dont save username", it->getDontSaveUsername() ); config->writeEntry( "Use mode config", it->getUseModeConfig() ); config->writeEntry( "Exchange mode", it->getExchangeMode() ); config->writeEntry( "Use delay at reconnect", it->getUseReconnectDelay() ); config->writeEntry( "Reconnect delay", it->getReconnectDelay() ); config->writeEntry( "Use TLS host", it->getUseTlsRemoteHost() ); config->writeEntry( "TLS remote host", it->getTlsRemoteHost() ); config->writeEntry( "Disable opportunistic encryption", it->getDisableOpportunisticEncryption() ); config->writeEntry( "Right next hop", it->getRightNextHop() ); config->writeEntry( "Left next hop", it->getLeftNextHop() ); config->writeEntry( "Use userdefinied packet size for fragmentation", it->getUseFragment() ); config->writeEntry( "Use userdef packet size", it->getUseMssfix() ); config->writeEntry( "Fragment", it->getFragment() ); config->writeEntry( "PeerTimeout", it->getPeerTimeout() ); config->writeEntry("Disable CCP", it->getDisableCcp() ); config->writeEntry("Use smartcard", it->getUseSmartcard() ); config->writeEntry("Use Xauth interactive", it->getUseXauthInteractive() ); config->writeEntry("Use HTTP Proxy Authentication", it->getUseHttpProxyAuth() ); config->writeEntry("HTTP Proxy Authtype", it->getHttpProxyAuthType() ); config->writeEntry("Use HTTP Proxy Auth user", it->getHttpProxyUser() ); config->writeEntry("Use HTTP Proxy Auth pass", it->getHttpProxyPass() ); config->writeEntry("Use only CA cert and user auth", it->getUseOnlyCaCertAndUserAuth() ); config->writeEntry("Use mail address as identifier", it->getUseMailAddressAsIdentifier() ); config->writeEntry("Use right next hop", it->getUseRightNextHop() ); config->writeEntry("Use left next hop", it->getUseLeftNextHop() ); config->writeEntry("Pkcs11 providers", it->getPkcs11Providers() ); config->writeEntry("Pkcs11 slot type", it->getPkcs11SlotType() ); config->writeEntry("Pkcs11 slot", it->getPkcs11Slot() ); config->writeEntry("Pkcs11 id type", it->getPkcs11IdType() ); config->writeEntry("Pkcs11 id", it->getPkcs11Id() ); config->writeEntry("Pkcs11 sign mode", it->getPkcs11SignMode() ); config->writeEntry("Use Pkcs11 providers", it->getUsePkcs11Providers() ); config->writeEntry("Allow empty private key password", it->getAllowEmptyPrivateKeyPassword()); config->writeEntry("Allow ip address change of peer", it->getAllowIpAddressChangeOfPeer()); config->writeEntry("Auth method", it->getAuthMethod()); config->writeEntry("Command after connect delay time", it->getCommandAfterConnectDelayTime()); config->writeEntry("Use search domain in resolv conf",it->getUseSearchDomainInResolvConf()); config->writeEntry("Use domain in resolv conf",it->getUseDomainInResolvConf()); config->writeEntry("Search domain in resolv conf",it->getSearchDomainInResolvConf()); config->writeEntry("Domain in resolv conf",it->getDomainInResolvConf()); config->writeEntry("Authentication direction",it->getAuthenticationDirection()); config->writeEntry("CiscoNatMode", it->getCiscoNatMode()); config->writeEntry("IPSec ESP",it->getIpsecEsp()); config->writeEntry("IPSec IKE",it->getIpsecIke()); config->writeEntry("Vtun profile",it->getVtunProfile()); config->writeEntry("Disable data encryption", it->getDisableDataEncryption()); config->writeEntry("Use authentication algorithm", it->getUseAuthenticationAlgorithm()); config->writeEntry("Fix path mtu discovery problem" , it ->getFixPathMtuDiscoveryProblem()); config->writeEntry("Use remote network", it->getUseRemoteNetwork()); config->writeEntry("Ipsec vpn mode", it->getIpsecVpnMode()); config->writeEntry("DisableHeaderCompression",it->getDisableHeaderCompression()); config->writeEntry("DisableMagicNumberNegotiation",it->getDisableMagicNumberNegotiation()); config->writeEntry("DisableIpx",it->getDisableIpx()); config->writeEntry("Disable protocol field compression",it->getDisableProtocolFieldCompression()); config->writeEntry("Disable adress control compression",it->getDisableAdressControlCompression()); config->writeEntry("Use custom ike",it->getUseCustomIke()); config->writeEntry("Use custom esp",it->getUseCustomEsp()); config->writeEntry("Verify ca cert",it->getVerifyCaCert()); config->writeEntry("Use DPD idle timeout",it->getUseDpdIdleTimeout()); config->writeEntry("DPD idle timeout",it->getDpdIdleTimeout()); config->writeEntry("Hide group password in accountdata dialog",it->getHideGroupPasswordInAccountDataDialog()); config->writeEntry("MaxConnectTries",it->getMaxConnectTries()); config->writeEntry("L2tpDaemon",it->getL2tpDaemon()); config->writeEntry("UseLeftSourceIp",it->getUseLeftSourceIp()); config->writeEntry("UseRightSourceIp",it->getUseRightSourceIp()); config->writeEntry("LeftSourceIp",it->getLeftSourceIp()); config->writeEntry("RightSourceIp",it->getRightSourceIp()); config->writeEntry("Use virtual subnets",it->getUseVirtualSubnetworks()); config->writeEntry("Virtual subnets", it->getVirtualSubnetworks()); config->writeEntry("DisablePushFromServer", it->getDisablePushFromServer()); config->writeEntry("DisableBind", it->getDisableBind()); config->writeEntry("UseRenegSec", it->getUseRenegSec()); config->writeEntry("RenegSec", it->getRenegSec()); config->writeEntry("UseTunnelPing", it->getUseTunnelPing()); config->writeEntry("TunnelPing", it->getTunnelPing()); config->writeEntry("UseTunnelPingRestart", it->getUseTunnelPingRestart()); config->writeEntry("TunnelPingRestart", it->getTunnelPingRestart()); config->writeEntry("RequireEap", it->getRequireEap()); config->writeEntry("UseSshConfigRemoteScript", it->getUseSshConfigRemoteScript()); config->writeEntry("SshConfigRemoteScript", it->getSshConfigRemoteScript()); config->writeEntry("AskUserPasswordOnEachConnect", it->getAskUserPasswordOnEachConnect()); config->writeEntry("UseCiscoCertStore", it->getUseCiscoCertStore()); config->writeEntry("UseNat", it->getUseNat()); // appPointer->processEvents(); QString AdditionalNetworkRoutesString; QStringList AdditionalNetworkRoutes = it->getAdditionalNetworkRoutes(); // Networks delimited by a ',' for ( QStringList::Iterator it2 = AdditionalNetworkRoutes.begin(); it2 != AdditionalNetworkRoutes.end(); ++it2 ) { AdditionalNetworkRoutesString+=*it2; AdditionalNetworkRoutesString+=","; } AdditionalNetworkRoutesString=AdditionalNetworkRoutesString.left(AdditionalNetworkRoutesString.length()-1); config->writeEntry( "Additional network routes", AdditionalNetworkRoutesString ); // wallet->sync(); /* give info */ // slotStatusMsg ( i18n( "Profile \"%1\" saved." ).arg( ProfileName.remove("Profile_") ), ID_FLASH_MSG ); appendLogEntry ( i18n( "Profile \"%1\" saved." ).arg( ProfileName.remove("Profile_") ) , info); // appPointer->processEvents(); } appPointer->processEvents(); } } // if ( !skipKwalletStoring && wallet != 0) // if (useKwallet && KWallet::Wallet::isEnabled()) // if (wallet->isOpen()) // wallet->sync(); config->sync(); doBackupConfig(); slotStatusMsg ( i18n( "Profiles saved." ) , ID_FLASH_MSG ); appPointer->processEvents(); } void KVpncConfig::loadOptions() { config->setGroup( "Notification Messages" ); hideOnCloseInfo = config->readBoolEntry( "hideOnCloseInfo" ,false); config->setGroup( "General Options" ); minimizeAfterConnect = config->readBoolEntry( "Minimize after connect", true ); hideMainWindow = config->readBoolEntry("Hide on startup", false ); useSilentQuit = config->readBoolEntry( "Use silent quit", false ); dontQuitOnCloseEvent = config->readBoolEntry( "Dont quit on CloseEvent", true ); showDebugConsole = config->readBoolEntry( "Show debugconsole", true ); enableDebugPppd = config->readBoolEntry( "Enable pppd debug", false ); enableDebugPptpd = config->readBoolEntry( "Enable pptpd debug", false ); enableFreeswanVerbose = config->readBoolEntry( "Enable FreeSWAN verbose", false ); PlutoDebug = QStringList::split(" ", config->readEntry( "Pluto Debug", "")); KlipsDebug = QStringList::split(" ", config->readEntry( "Klips Debug", "")); Vpnc_pid_file = config->readEntry( "Pid file for vpnc ", "/var/run/vpnc/pid" ); RacoonDebugLevel = config->readEntry( "Racoon debuglevel", "info" ); // we need to correct old int value if (RacoonDebugLevel == "0") RacoonDebugLevel="info"; if (RacoonDebugLevel != "info" && RacoonDebugLevel != "debug" && RacoonDebugLevel != "debug2" ) RacoonDebugLevel = "info"; VpncDebugLevel = config->readNumEntry( "Vpnc debuglevel", 0 ); KvpncDebugLevel = config->readNumEntry( "Kvpnc debuglevel", 0 ); PppdDebugLevel = config->readBoolEntry( "Pppd debuglevel", false ); PppdKernelLogLevel = config->readNumEntry( "Pppd kernel log level", 0 ); OpenvpnDebugLevel = config->readNumEntry( "Openvpn debuglevel", 0 ); PptpLogLevel = config->readNumEntry( "Pptp debuglevel", 1 ); SshDebugLevel = config->readNumEntry( "ssh debuglevel", 1 ); enableDebugL2tpd = config->readBoolEntry( "enable l2tpd debug", false ); enableDebugXl2tpd = config->readBoolEntry( "Enable xl2tpd debug", false ); enableDebugOpenl2tp = config->readBoolEntry( "Enable openl2tp debug", false ); enableDebugXl2tpdNetwork = config->readBoolEntry("EnableDebugXl2tpdNetwork",false); enableDebugXl2tpdpacket = config->readBoolEntry("EnableDebugXl2tpdpacket",false); enableDebugXl2tpdstate = config->readBoolEntry("EnableDebugXl2tpdstate",false); enableDebugXl2tpdtunnel = config->readBoolEntry("EnableDebugXl2tpdtunnel",false); pathToVpnc = config->readEntry( "Path to vpnc-bin", "/usr/sbin/vpnc" ); pathToCiscoVpnc = config->readEntry( "Path to vpnclient", "/usr/local/bin/vpnclient" ); pathToSetkey = config->readEntry( "Path to setkey", "/usr/sbin/setkey" ); pathToRacoon = config->readEntry( "Path to racoon", "/usr/sbin/racoon" ); pathToRacoonctl = config->readEntry( "Path to racoonctl", "/usr/sbin/racoonctl" ); pathToIptables = config->readEntry( "Path to iptables", "/sbin/iptables" ); pathToOpenssl = config->readEntry( "Path to openssl", "/usr/bin/openssl" ); pathToIpsec = config->readEntry( "Path to freeswan", "/usr/sbin/ipsec" ); pathToIp = config->readEntry( "Path to iputility", "/sbin/ip" ); pathToIfconfig = config->readEntry( "Path to ifconfig", "/sbin/ifconfig" ); pathToRoute = config->readEntry( "Path to route", "/sbin/route" ); pathToNetstat = config->readEntry( "Path to netstat", "/bin/netstat" ); pathToPppd = config->readEntry ("Path to pppd","/usr/sbin/pppd"); pathToPptp = config->readEntry ("Path to pptp","/usr/sbin/pptp"); pathToL2tpd = config->readEntry ("Path to l2tpd","/usr/sbin/l2tpd"); pathToXl2tpd = config->readEntry ("Path to xl2tpd","/usr/sbin/xl2tpd"); pathToOpenl2tp = config->readEntry ("Path to openl2tp","/usr/sbin/openl2tpd"); pathToKill = config->readEntry ("Path to kill","/bin/kill"); pathToKillall = config->readEntry ("Path to kill-all","/usr/bin/killall"); pathToPing = config->readEntry ("Path to ping","/bin/ping"); pathToOpenvpn = config->readEntry ("Path to openvpn","/usr/sbin/openvpn"); pathToPkcs11Tool = config->readEntry( "Path to pkcs11-tool", "/usr/bin/pkcs11-tool" ); pathToVtund = config->readEntry( "Path to vtund", "/usr/sbin/vtund" ); pathToCiscoCertMgr = config->readEntry( "Path to cisco_cert_mgr","/usr/local/bin/cisco_cert_mgr"); pathToTail = config->readEntry( "Path to tail","/usr/bin/tail"); pathToSsh = config->readEntry( "Path to ssh","/usr/bin/ssh"); pathToKsshAskpass = config->readEntry( "Path to ksshaskpass","/usr/bin/ksshaskpass"); pathToGnomeSshAskpass = config->readEntry( "Path to ssh-askpass-gnome","/usr/lib/openssh/gnome-ssh-askpass"); checkStandardPathValues(); tryConnectTimeout = QString( config->readEntry( "Try connect timeout", "10" ) ).toInt(); lastProfile = config->readEntry( "Last Profile", "" ); writeLogFile = config->readBoolEntry( "Write log file", true ); holdGeneratedScripts = config->readBoolEntry( "Hold generated scripts", true ); showStatusBar = config->readBoolEntry( "Show Statusbar", true ); programsInPath = config->readBoolEntry( "Programs in path", true ); if (programsInPath) useDefaultPaths=true; InfoLogColor = config->readColorEntry ( "Info logwindow color", new QColor(Qt::black) ); RemoteLogColor = config->readColorEntry ( "Remote logwindow color", new QColor(Qt::blue) ); ErrorLogColor = config->readColorEntry( "Error logwindow color", new QColor(Qt::red )); SuccessLogColor = config->readColorEntry( "Success logwindow color", new QColor(Qt::darkGreen) ); DebugLogColor = config->readColorEntry( "Debug logwindow color", new QColor(255,175,0 )); DebugBackgroundcolor = config->readColorEntry("Debug background color", new QColor (Qt::white) ); useColorizedLogOutput = config->readBoolEntry("Use colorized log output", true); showInterfaceIPinTooltip = config->readBoolEntry( "Show interface IP in tooltip", true ); AutoConnectProfile= config->readEntry( "Auto connect profile", "" ); doAutoConnectAtStartup = config->readBoolEntry( "Do auto connect at startup", false ); LogViewerFontSize = config->readNumEntry( "Log viewer font size", 2 ); WindowSize = QSize( config->readNumEntry( "Mainwindow width", 50 ), this->config->readNumEntry( "Mainwindow height", 50 ) ); WindowPos = QPoint ( config->readNumEntry( "Mainwindow position x", 10 ), this->config->readNumEntry( "Mainwindow position y", 50 ) ); OpenvpnManagementPort = config->readNumEntry("Openvpn management port", 2222 ); appPointer->processEvents(); if ( writeLogFile ) if ( !logfile.isOpen() ) { KStandardDirs *dirs = KGlobal::dirs(); QDir AppFolder (QString(dirs->saveLocation( "data" )+"/kvpnc")); if (!AppFolder.exists()) { // KMessageBox::error( this, i18n( "creating dir: %1" ).arg(dirs->saveLocation( "data" )+"/kvpnc" )); QDir AppFolder2(dirs->saveLocation( "data" )); if(!AppFolder2.mkdir("kvpnc",true)) { KMessageBox::error( 0, i18n( "The appdir for kvpnc could not be created. Be sure that you have write permission of \"%1\"." ).arg(dirs->saveLocation( "data" )) ); appendLogEntry( i18n( "The appdir for kvpnc could not be created. Be sure that you have write permission of \"%1\"." ).arg(dirs->saveLocation( "data" )),error); } } logfileName = dirs->saveLocation( "data" ); logfileName += "/kvpnc/kvpnc.log"; //KMessageBox::information( this, logfileName, "info" ); logfile.setName( logfileName ); if ( !logfile.open( IO_WriteOnly | IO_Append ) ) { KMessageBox::error( 0, i18n( "Log file cant be opened!" ) ); appendLogEntry(i18n( "Unable to find \"%1\"!" ).arg("pppd"),error); } else { QTextStream s( &logfile ); s << i18n( "Log session started at: " ) << QDateTime::currentDateTime().toString( Qt::TextDate ) << endl; } } useKwallet = config->readBoolEntry("Use KWallet", true); firstUseOfKwallet = config->readBoolEntry( "First use of Kwallet", true ); feedbackMailSent = config->readBoolEntry("FeedbackMailSent",false); doKillL2tpdIfStillRunning = config->readBoolEntry("Do kill l2tpd if still running",true); doKillXl2tpdIfStillRunning = config->readBoolEntry("Do kill xl2tpd if still running",true); doKillRacoonIfStillRunning = config->readBoolEntry("Do kill racoon if still running",true); showConnectionTimeInTooltip = config->readBoolEntry("Show connection time in Tooltip",true); enableDebugOpenvpn = config->readBoolEntry("Enable debug Openvpn",false); if ( KvpncDebugLevel > 2 ) appendLogEntry( i18n( "Global configuration loaded." ) ,info); /* = user data = */ /* old style: one profile: will be removed in future */ /* config->setGroup( "Client Options" ); this->mw->gatewayLineEdit->setText( config->readEntry( "VPN Gateway", "" ) ); this->mw->IDLineEdit->setText( config->readEntry( "VPN ID", "" ) ); this->mw->PSKLineEdit->setText( config->readEntry( "Group password", "" ) ); this->mw->UsernameLineEdit->setText( config->readEntry( "Username", "" ) ); this->mw->PasswordEdit->setText( config->readEntry( "Password", "" ) ); this->mw->CheckUserPass->setChecked( config->readBoolEntry( "Save user password", false ) ); this->mw->CheckGroupPass->setChecked( config->readBoolEntry( "Save group password", false ) ); */ /* profiles are stored in a group which is named to the following scheme: Profile_XXXXX XXXXX is the account name (important: unique!) */ QStringList configGroups = config->groupList(); bool oldConfigurationFound = false; bool sessionFound = false; for ( QStringList::Iterator it = configGroups.begin(); it != configGroups.end(); ++it ) { QString name = *it; name.stripWhiteSpace(); if ( name.left( 7 ) == "Profile" && name.length() > 8 ) { // Profile found sessionFound = true; if ( KvpncDebugLevel > 2 ) { QString tmp = i18n( "Profile found: " ); tmp += name.right( ( name.length() ) - 8 ); appendLogEntry ( tmp, debug ); } config->setGroup( name ); QString UserPassword=""; QString PrivateKeyPass=""; QString PreSharedKey =""; /* passwords with kwallet */ if (useKwallet && KWallet::Wallet::isEnabled()) { if (KvpncDebugLevel > 2) appendLogEntry(i18n( "Wallet enabled and available, reading passwords from wallet." ),debug); // Open local wallet wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet()); if (wallet != 0) { QString walletname="kvpnc"; if (!wallet->hasFolder(walletname)) { wallet->createFolder(walletname); wallet->sync(); } if (wallet->setFolder(walletname)) { if (KvpncDebugLevel > 2) appendLogEntry(i18n( "Folder for kvpnc has been set." ),debug); QString profilename = name.right( ( name.length() ) - 8 ); if (wallet->readPassword(QString(profilename+"__user_pw"), UserPassword) != 0) appendLogEntry(i18n( "read of %1 has failed." ).arg(i18n("user password")),error); else if (KvpncDebugLevel > 2) appendLogEntry(i18n( "read of %1 was successful." ).arg(i18n("user password")),debug); if (wallet->readPassword(QString(profilename+"__psk"), PreSharedKey) != 0) appendLogEntry(i18n( "read of %1 has failed." ).arg(i18n("preshared key")),error); else if (KvpncDebugLevel > 2) appendLogEntry(i18n( "read of %1 was successful." ).arg(i18n("preshared key")),debug); if (wallet->readPassword(QString(profilename+"__priv_key_pwd"), PrivateKeyPass) != 0) appendLogEntry(i18n( "read of %1 has failed." ).arg(i18n("preshared key password")),error); else if (KvpncDebugLevel > 2) appendLogEntry(i18n( "read of %1 was successful." ).arg(i18n("preshared key password")),debug); } else { KMessageBox::error( 0, i18n( "Unable to set wallet folder for kvpnc!" ) ); appendLogEntry(i18n( "Unable to set wallet folder for kvpnc!" ), error); } appPointer->processEvents(); } else { KMessageBox::error( 0, i18n( "Unable to open wallet folder for kvpnc!" ) ); appendLogEntry(i18n( "Unable to open wallet folder for kvpnc!" ), error); } } else { if (KvpncDebugLevel > 2) { if (useKwallet && KWallet::Wallet::isEnabled() && firstUseOfKwallet) appendLogEntry(i18n( "Wallet enabled, available but first time, reading passwords from config file." ),debug); else appendLogEntry(i18n( "Wallet disabled or not available, reading passwords from config file." ),debug); } // read from config file UserPassword = config->readEntry( "User password", "" ); PrivateKeyPass = config->readEntry( "PrivateKey password", "" ); PreSharedKey = config->readEntry( "Pre shared key", "" ); } VpnAccountData::ConnectionType ConnType = VpnAccountData::ConnectionType( VpnAccountData::cisco ); QString type_string = config->readEntry( "Connection type", "cisco" ); if ( type_string == "cisco" ) ConnType = VpnAccountData::cisco; else if ( type_string == "ciscoorig" ) ConnType = VpnAccountData::ciscoorig; else if ( type_string == "racoon" ) ConnType = VpnAccountData::racoon; else if ( type_string == "l2tpd (racoon)" ) ConnType = VpnAccountData::l2tpd_racoon; else if ( type_string == "freeswan" ) ConnType = VpnAccountData::freeswan; else if ( type_string == "l2tpd (openswan)" ) ConnType = VpnAccountData::l2tpd_freeswan; else if ( type_string == "pptp" ) ConnType = VpnAccountData::pptp; else if ( type_string == "openvpn" ) ConnType = VpnAccountData::openvpn; else if ( type_string == "vtun" ) ConnType = VpnAccountData::vtun; else if ( type_string == "ssh" ) ConnType = VpnAccountData::ssh; else ConnType = VpnAccountData::other; QString Name = name.right( name.length() - 8 ); VpnAccountData *data = new VpnAccountData( ConnType, Name ); data->setGateway( config->readEntry( "VPN Gateway", "" )); data->setID( config->readEntry( "VPN ID", "" ) ); data->setDescription( config->readEntry("Description","")); data->setUserName( config->readEntry( "Username", "" )); data->setSaveUserPassword( config->readBoolEntry( "Save user password", false )); data->setSavePsk( config->readBoolEntry( "Save PSK", false )); data->setSavePrivateKeyPassword( config->readBoolEntry( "Save private key password", true ) ); data->setUseAdvancedSettings( config->readBoolEntry( "Use advanced settings", false )); data->setApplicationVersion( config->readEntry( "Application version", "Cisco Systems VPN Client 0.3-rm+zomb.1:Linux" )); data->setLocalPort( config->readNumEntry( "Local port", 500 )); data->setRemotePort( config->readNumEntry( "Remote port", 500 )); data->setNtDomainName( config->readEntry( "NT domain name", "" )); data->setPerfectForwardSecrety( config->readEntry( "Perfect forward secrety", "server" )); data->setIkeGroup( config->readEntry( "IKE group", "dh1" )); data->setUseApplicationVersion( config->readBoolEntry( "Use application version", false )); data->setUseGlobalIpsecSecret( config->readBoolEntry( "Use global IPSec secret", false )); data->setUseIkeGroup( config->readBoolEntry( "Use IKE group", false )); data->setUseLocalPort( config->readBoolEntry( "Use local port", false )); data->setUseRemotePort( config->readBoolEntry( "Use remote port", false )); data->setUseNtDomainName( config->readBoolEntry( "Use NT domain name", false )); data->setUseSingleDes( config->readBoolEntry( "Use single DES", false )); data->setUsePerfectForwardSecrety( config->readBoolEntry( "Use perfect Forward Secrety", false )); data->setX509Certificate( config->readEntry( "x509 certificate", "" )); data->setCaCertificate( config->readEntry( "Ca certificate", "" )); data->setNetworkDevice( config->readEntry( "Network device", "default" )); data->setCertPath( config->readEntry( "Cert path", "/etc/racoon/certs" )); data->setPrivateKey( config->readEntry( "Private key", "" )); VpnAccountData::AuthenticationType authtype; if ( config->readEntry( "Auth type", "cert" ) == "cert" ) authtype = VpnAccountData::cert; else if ( config->readEntry( "Auth type", "psk" ) == "psk" ) authtype = VpnAccountData::psk; else if ( config->readEntry( "Auth type", "cert" ) == "hybrid" ) authtype = VpnAccountData::hybrid; else authtype = VpnAccountData::unknownauth; data->setAuthType(authtype); appPointer->processEvents(); data->setDoPingIP( config->readBoolEntry( "do ping ip", false )); data->setPingHostIP( config->readEntry( "Ping host IP", "" )); data->setUseSpecialRemoteID( config->readBoolEntry( "Use special remote ID", false )); data->setUseSpecialLocalID( config->readBoolEntry( "Use special local ID", false )); data->setSpecialRemoteID( config->readEntry( "Special remote ID", "" )); data->setSpecialLocalID( config->readEntry( "Special local ID", "" )); data->setLocalIDType(config->readEntry( "Local ID type", "asn1dn") ); data->setRemoteIDType(config->readEntry( "Remote ID type", "none") ); data->setUseSpecialServerCertificate( config->readBoolEntry( "Use special server certificate", false )); data->setSpecialServerCertificate( config->readEntry( "Special server certificate", "" )); data->setUseUdp( config->readBoolEntry( "Use UDP-protocol", false )); data->setUseUdpPort( config->readBoolEntry( "Use UDP-port", false )); data->setUdpPort( config->readNumEntry( "local UDP port", 4500 )); data->setUseDnsUpdate( config->readBoolEntry( "use DNS_UPDATE", true)); data->setUseDnsServer( config->readBoolEntry( "use DNS-server", false)); data->setDnsServer( config->readEntry( "DNS server", "" )); data->setRefuse40BitEncryption( config->readBoolEntry( "refuse 40 bit encryption", true )); data->setRefuse128BitEncryption( config->readBoolEntry( "refuse 128 bit encryption", false )); data->setAllowStatefulMode( config->readBoolEntry( "require stateless encryption",false )); data->setRequireMppe( config->readBoolEntry( "require mppe", true )); data->setUseNoBsdComp( config->readBoolEntry( "Use no BSD compression", true )); data->setUseNoIpDefault(config->readBoolEntry( "Do not use no IP by default", false)); data->setUseNoDeflate( config->readBoolEntry( "Use no deflate", true )); data->setDisableMPPEComp( config->readBoolEntry( "Disable MPPE compression", false )); data->setLocalVirtualIP( config->readEntry( "Local virtual IP", "" )); data->setRemoteVirtualIP( config->readEntry( "Remote virtual IP", "" )); data->setPreSharedKeyFile( config->readEntry( "Pre shared key file", "" )); data->setExecuteCmdBeforeConnect( config->readBoolEntry( "Execute command before connect",false)); data->setExecuteCmdAfterConnect( config->readBoolEntry( "Execute command after connect",false)); data->setExecuteCmdBeforeDisconnect( config->readBoolEntry( "Execute command before disconnect", false)); data->setExecuteCmdAfterDisconnect( config->readBoolEntry( "Execute command after disconnect", false)); data->setCommandBeforeConnect( config->readEntry( "Command before connect", "" )); data->setCommandAfterConnect( config->readEntry( "Command after connect", "" )); data->setCommandBeforeDisconnect( config->readEntry( "Command before disconnect", "" )); data->setCommandAfterDisconnect( config->readEntry( "Command after disconnect", "" )); data->setReplaceDefaultRoute( config->readBoolEntry( "Replace default route", false )); data->setUseMtu( config->readBoolEntry( "Use own MTU", false )); data->setUseMru( config->readBoolEntry( "Use own MRU", false )); data->setMtu( config->readNumEntry( "MTU for pppd", 1492 )); data->setMru( config->readNumEntry( "MRU for pppd", 1492 )); data->setUseVirtualIP( config->readBoolEntry( "Use virtual IP", false )); data->setVirtualIP( config->readEntry( "Virtual IP", "" )); data->setPskIsInFile( config->readBoolEntry( "PSK is in file", false )); data->setUseAdditionalNetworkRoutes( config->readBoolEntry( "Use additional network routes", false )); appPointer->processEvents(); QString AdditionalNetworkRoutesString = config->readEntry( "Additional network routes", "" ); // Networks delimited by a ',' QStringList AdditionalNetworkRoutes(QStringList::split( ",", AdditionalNetworkRoutesString )); data->setAdditionalNetworkRoutes(AdditionalNetworkRoutes); data->setHashAlgo( config->readEntry( "Hash algorithm", "md5" )); data->setEncryptionAlgorithm( config->readEntry( "Encryption algorithm", "3des" )); data->setAuthenticationAlgorithm( config->readEntry( "Authentication algorithm", "hmac_sha1" )); data->setTunnelDeviceType( config->readEntry( "Tunnel device type", "tun" )); data->setUseUserdefinedPort( config->readBoolEntry( "Use userdefined port", false )); data->setUserdefinedPort( config->readNumEntry( "Userdefined port", 1194 )); data->setNsCertType( config->readEntry( "NS cert type", "client" )); data->setUseNsCertType( config->readBoolEntry( "Use NS cert type", false )); data->setUseConnectionStatusCheck ( config->readBoolEntry( "Use connection status check", true )); data->setConnectionStatusCheckSuccessCount ( config->readNumEntry( "Connection check success count", 4 )); data->setConnectionStatusInterval ( config->readNumEntry( "Connection check status interval", 1 )); data->setDoReconnectAfterConnectionLost(config->readBoolEntry("Do reconnect after connection lost", false)); data->setDisableLzoCompression(config->readBoolEntry("Disable LZO compression", true)); data->setUserPassword( UserPassword ); data->setRemoteNetAddr( config->readEntry("Remote net address","") ); data->setRemoteNetMask( QString().setNum(config->readNumEntry("Remote net mask",24 ))); data->setPreSharedKey( PreSharedKey ); data->setPrivateKeyPass( PrivateKeyPass ); data->setAuthWithUsernameAndPassword( config->readBoolEntry( "AuthWithUsernameAndPassword",false ) ); data->setAllowEmptyGroupPassword( config->readBoolEntry( "AllowEmptyGroupPassword", false ) ); data->setUseUserdefiniedCipher( config->readBoolEntry( "Use userdefinied cipher", false ) ); data->setUserdefiniedCipher( config->readEntry( "Userdefinied cipher", "" ) ); appPointer->processEvents(); data->setUseRedirectGateway( config->readBoolEntry( "Use redirect gateway", false ) ); data->setUseTlsAuth( config->readBoolEntry( "Use TLS auth", false ) ); data->setTlsAuthFile( config->readEntry( "TLS auth file", "" ) ); data->setUseHttpProxy( config->readBoolEntry( "Use HTTP proxy", false ) ); data->setHttpProxy( config->readEntry( "HTTP proxy host", "" ) ); data->setHttpProxyPort( config->readNumEntry( "HTTP proxy port", 8080 ) ); data->setHttpProxyTimeout( config->readNumEntry( "HTTP proxy timeout", 5 ) ); data->setDontSaveUsername( config->readBoolEntry( "Dont save username", false ) ); data->setUseModeConfig( config->readBoolEntry( "Use mode config", false ) ); data->setExchangeMode( config->readEntry( "Exchange mode", "main" ) ); data->setUseReconnectDelay( config->readBoolEntry( "Use delay at reconnect", false ) ); data->setReconnectDelay( config->readNumEntry( "Reconnect delay", 5 ) ); data->setUseTlsRemoteHost( config->readBoolEntry( "Use TLS host", false) ); data->setTlsRemoteHost( config->readEntry( "TLS remote host", "") ); data->setDisableOpportunisticEncryption( config->readBoolEntry( "Disable opportunistic encryption", false ) ); data->setRightNextHop( config->readEntry( "Right next hop", "" ) ); data->setLeftNextHop( config->readEntry( "Left next hop", "" ) ); data->setUseMssfix(config->readBoolEntry( "Use userdef packet size", false) ); data->setUseFragment(config->readBoolEntry( "Use userdefinied packet size for fragmentation" , false) ); data->setMssfix(config->readNumEntry( "Mssfix", 1300) ); data->setFragment( config->readNumEntry( "Fragment", 1300) ); data->setPeerTimeout( config->readNumEntry( "PeerTimeout",0) ); data->setDisableCcp( config->readBoolEntry("Disable CCP",false) ); data->setUseSmartcard( config->readBoolEntry("Use smartcard", false) ); data->setUseXauthInteractive(config->readBoolEntry("Use Xauth interactive", false) ); data->setUseHttpProxyAuth( config->readBoolEntry("Use HTTP Proxy Authentication", false ) ); data->setHttpProxyAuthType( config->readEntry("HTTP Proxy Authtype", "basic") ); data->setHttpProxyUser( config->readEntry("Use HTTP Proxy Auth user", "") ); data->setHttpProxyPass( config->readEntry("Use HTTP Proxy Auth pass", "") ); data->setUseOnlyCaCertAndUserAuth(config->readBoolEntry("Use only CA cert and user auth", false) ); data->setUseMailAddressAsIdentifier(config->readBoolEntry("Use mail address as identifier", false) ); data->setUseRightNextHop(config->readBoolEntry("Use right next hop", false) ); data->setUseLeftNextHop(config->readBoolEntry("Use left next hop", false) ); data->setPkcs11Providers(config->readEntry("Pkcs11 providers", "/usr/local/lib/libetpkcs11.so" ) ); data->setPkcs11SlotType(config->readEntry("Pkcs11 slot type", "id") ); data->setPkcs11Slot(config->readEntry("Pkcs11 slot", "0") ); data->setPkcs11IdType(config->readEntry("Pkcs11 id type", "id") ); data->setPkcs11Id(config->readEntry("Pkcs11 id","" ) ); data->setPkcs11SignMode(config->readEntry("Pkcs11 sign mode", "auto") ); data->setUsePkcs11Providers(config->readBoolEntry("Use Pkcs11 providers", false) ); data->setAllowEmptyPrivateKeyPassword( config->readBoolEntry("Allow empty private key password", false )); data->setAllowIpAddressChangeOfPeer(config->readBoolEntry("Allow ip address change of peer", false)); data->setAuthMethod(config->readEntry("Auth method", "mschap-v2")); data->setCommandAfterConnectDelayTime(config->readNumEntry("Command after connect delay time", 5)); data->setUseSearchDomainInResolvConf(config->readBoolEntry("Use search domain in resolv conf",false)); data->setUseDomainInResolvConf(config->readBoolEntry("Use domain in resolv conf",false)); data->setSearchDomainInResolvConf(config->readEntry("Search domain in resolv conf","")); data->setDomainInResolvConf(config->readEntry("Domain in resolv conf","")); data->setAuthenticationDirection(config->readEntry("Authentication direction","none")); data->setCiscoNatMode(config->readEntry("CiscoNatMode", "natt")); data->setIpsecEsp(config->readEntry("IPSec ESP","3des-md5,3des-sha1,aes128-sha1,aes256-sha1")); data->setIpsecIke(config->readEntry("IPSec IKE","aes256-sha1,aes128-sha1,3des-sha1-modp2048,3des-md5,3des-sha1")); data->setVtunProfile(config->readEntry("Vtun profile","")); data->setDisableDataEncryption(config->readBoolEntry("Disable data encryption", false)); data->setUseAuthenticationAlgorithm(config->readBoolEntry("Use authentication algorithm", false)); data->setFixPathMtuDiscoveryProblem(config->readBoolEntry("Fix path mtu discovery problem" , false)); data->setUseRemoteNetwork(config->readBoolEntry("Use remote network",false)); data->setIpsecVpnMode(config->readEntry("Ipsec vpn mode", "tunnel")); data->setDisableHeaderCompression(config->readBoolEntry("DisableHeaderCompression",false)); data->setDisableMagicNumberNegotiation(config->readBoolEntry("DisableMagicNumberNegotiation",false)); data->setDisableIpx(config->readBoolEntry("DisableIpx",false)); data->setDisableProtocolFieldCompression(config->readBoolEntry("Disable protocol field compression",false)); data->setDisableAdressControlCompression(config->readBoolEntry("Disable adress control compression",false)); data->setUseCustomIke(config->readBoolEntry("Use custom ike",false)); data->setUseCustomEsp(config->readBoolEntry("Use custom esp",false)); data->setVerifyCaCert(config->readBoolEntry("Verify ca cert",true)); data->setUseDpdIdleTimeout(config->readBoolEntry("Use DPD idle timeout",false)); data->setDpdIdleTimeout(config->readNumEntry("DPD idle timeout",300)); data->setHideGroupPasswordInAccountDataDialog(config->readBoolEntry("Hide group password in accountdata dialog",false)); data->setMaxConnectTries(config->readNumEntry("MaxConnectTries",300)); data->setL2tpDaemon((VpnAccountData::L2tpDaemonType)config->readNumEntry("L2tpDaemon",0)); data->setUseLeftSourceIp(config->readBoolEntry("UseLeftSourceIp",false)); data->setUseRightSourceIp(config->readBoolEntry("UseRightSourceIp",false)); data->setLeftSourceIp(config->readEntry("LeftSourceIp","")); data->setRightSourceIp(config->readEntry("RightSourceIp","")); data->setUseVirtualSubnetworks(config->readBoolEntry("Use virtual subnets",false)); data->setVirtualSubnetworks(config->readEntry("Virtual subnets", "")); data->setDisablePushFromServer(config->readBoolEntry("DisablePushFromServer",false)); data->setDisableBind(config->readBoolEntry("DisableBind",false)); data->setUseRenegSec( config->readBoolEntry("UseRenegSec", false)); data->setRenegSec(config->readNumEntry("RenegSec", 3600)); data->setUseTunnelPing(config->readBoolEntry("UseTunnelPing", false)); data->setTunnelPing(config->readNumEntry("TunnelPing",10)); data->setUseTunnelPingRestart(config->readBoolEntry("UseTunnelPingRestart", false)); data->setTunnelPingRestart(config->readNumEntry("TunnelPingRestart", 120)); data->setRequireEap(config->readBoolEntry("RequireEap", false)); data->setUseSshConfigRemoteScript(config->readBoolEntry("UseSshConfigRemoteScript", false)); data->setSshConfigRemoteScript(config->readEntry("SshConfigRemoteScript", "")); data->setAskUserPasswordOnEachConnect(config->readBoolEntry("AskUserPasswordOnEachConnect", false)); data->setUseCiscoCertStore( config->readBoolEntry("UseCiscoCertStore", false)); data->setUseNat(config->readBoolEntry("UseNat", true)); appPointer->processEvents(); AccountList->append( data ); } if ( name == "Client Options" ) { // old style configuration found config->setGroup( "Client Options" ); QString Name = "Default"; VpnAccountData::ConnectionType ConnType = VpnAccountData::cisco; QString Gateway = config->readEntry( "VPN Gateway", "" ); QString ID = config->readEntry( "VPN ID", "" ); QString Psk = config->readEntry( "Group password", "" ); QString Username = config->readEntry( "Username", "" ); QString UserPassword = config->readEntry( "Password", "" ); bool saveUserPassword = config->readBoolEntry( "Save user password", false ); bool savePsk = config->readBoolEntry( "Save group password", false ); VpnAccountData *AccData = new VpnAccountData( ConnType, Name); AccData->setGateway ( Gateway ); AccData->setID( ID ); AccData->setPreSharedKey( Psk); AccData->setUserName( Username ); AccData->setUserPassword( UserPassword ); AccData->setSaveUserPassword( saveUserPassword ); AccData->setSavePsk( savePsk ); AccData->setLocalPort( 500 ); AccData->setPerfectForwardSecrety ( "server" ); AccData->setIkeGroup( "dh1" ); AccountList->append( AccData ); lastProfile = "Default"; // now mark for deleting old configuration oldConfigurationFound = true; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n( "Old configuration found, converted." ),info ); if ( KvpncDebugLevel > 2 ) appendLogEntry( i18n( "Configuration for profile \"%1\" loaded." ).arg( Name ),info ); appPointer->processEvents(); } } if ( oldConfigurationFound ) { // delete configuration file KStandardDirs * dirs = KGlobal::dirs(); QString filePath = dirs->findResource ( "config", "kvpncrc" ); QFile::remove ( filePath ); if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n( "Old configuration deleted." ), debug ); } } void KVpncConfig::checkStandardPathValues() { if (pathToVpnc.isEmpty()) pathToVpnc = "/usr/sbin/vpnc"; if (pathToCiscoVpnc.isEmpty()) pathToCiscoVpnc = "/usr/local/bin/vpnclient"; if (pathToSetkey.isEmpty()) pathToSetkey = "/usr/sbin/setkey"; if (pathToRacoon.isEmpty()) pathToRacoon = "/usr/sbin/racoon"; if (pathToRacoonctl.isEmpty()) pathToRacoonctl = "/usr/sbin/racoonctl"; if (pathToIptables.isEmpty()) pathToIptables = "/sbin/iptables"; if (pathToOpenssl.isEmpty()) pathToOpenssl = "/usr/bin/openssl"; if (pathToIpsec.isEmpty()) pathToIpsec = "/usr/sbin/ipsec"; if (pathToIp.isEmpty()) pathToIp = "/sbin/ip"; if (pathToIfconfig.isEmpty()) pathToIfconfig = "/sbin/ifconfig"; if (pathToRoute.isEmpty()) pathToRoute = "/sbin/route"; if (pathToNetstat.isEmpty()) pathToNetstat = "/bin/netstat"; if (pathToPppd.isEmpty()) pathToPppd = "/usr/sbin/pppd"; if (pathToPptp.isEmpty()) pathToPptp = "/usr/sbin/pptp"; if (pathToL2tpd.isEmpty()) pathToL2tpd = "/usr/sbin/l2tpd"; if (pathToXl2tpd.isEmpty()) pathToXl2tpd = "/usr/sbin/xl2tpd"; if (pathToOpenl2tp.isEmpty()) pathToOpenl2tp = "/usr/sbin/openl2tpd"; if (pathToKill.isEmpty()) pathToKill = "/bin/kill"; if (pathToKillall.isEmpty()) pathToKillall = "/usr/bin/killall"; if (pathToPing.isEmpty()) pathToPing = "/bin/ping"; if (pathToOpenvpn.isEmpty()) pathToOpenvpn = "/usr/sbin/openvpn"; if (pathToPkcs11Tool.isEmpty()) pathToPkcs11Tool = "/usr/bin/pkcs11-tool"; if (pathToVtund.isEmpty()) pathToVtund = "/usr/sbin/vtund"; if (pathToCiscoCertMgr.isEmpty()) pathToCiscoCertMgr = "/usr/local/bin/cisco_cert_mgr"; if (pathToTail.isEmpty()) pathToTail = "/usr/bin/tail"; if (pathToSsh.isEmpty()) pathToSsh = "/usr/bin/ssh"; if (pathToKsshAskpass.isEmpty()) pathToKsshAskpass = "/usr/bin/ksshaskpass"; if (pathToGnomeSshAskpass.isEmpty()) pathToGnomeSshAskpass = "/usr/lib/openssh/gnome-ssh-askpass"; } bool KVpncConfig::exportKvpncConfig(QString filename) { bool ok=true; int exportCount=0; bool exportGlobal=false; QFile exportfile (filename); if (exportfile.exists()) { int res = KMessageBox::questionYesNo ( 0, i18n ( "\"%1\" still exists. Do you really want to overwrite it?" ).arg ( filename ), i18n ( "Overwrite?" ), i18n("&Overwrite") , KStdGuiItem::cancel() ); if (res == 4) ok=false; } if (ok==true) { if( exportfile.open(IO_WriteOnly)) { QPtrList *exportAccountList = new QPtrList(); exportAccountList->setAutoDelete( TRUE ); // the list owns the objects KvpncImportProfileSelectionBase selectdlg; VpnAccountData *it=NULL; selectdlg.OpenProfileManagerCheckBox->hide(); selectdlg.textLabel->setText(i18n("Select profiles for export:")); selectdlg.ImportPushButton->setText(i18n("&Export selected profiles...")); selectdlg.ImportGlobalSettingsCheckBox->setText(i18n("export &global settings")); if ( !AccountList->isEmpty() ) { selectdlg.ImportProfileListView->takeItem(selectdlg.ImportProfileListView->currentItem()); selectdlg.ImportProfileListView->addColumn(i18n("Name")); selectdlg.ImportProfileListView->addColumn(i18n("Type")); selectdlg.ImportProfileListView->addColumn(i18n("Gateway")); QCheckListItem *item; for ( it = AccountList->first(); it; it = AccountList->next() ) { QString name = it->getName(); QString type; if ( it->getConnectionType() == VpnAccountData::cisco ) type = "cisco" ; else if ( it->getConnectionType() == VpnAccountData::ciscoorig ) type = "ciscoorig" ; else if ( it->getConnectionType() == VpnAccountData::racoon ) type = "racoon" ; else if ( it->getConnectionType() == VpnAccountData::l2tpd_racoon ) type = "l2tpd (racoon)" ; else if ( it->getConnectionType() == VpnAccountData::freeswan ) type = "freeswan" ; else if ( it->getConnectionType() == VpnAccountData::l2tpd_freeswan ) type = "l2tpd (openswan)" ; else if ( it->getConnectionType() == VpnAccountData::pptp ) type = "pptp" ; else if ( it->getConnectionType() == VpnAccountData::openvpn ) type = "openvpn" ; else if ( it->getConnectionType() == VpnAccountData::vtun ) type = "vtun" ; else if ( it->getConnectionType() == VpnAccountData::ssh ) type = "ssh" ; else type = i18n("other"); // litem->setSelectable(true); item = new QCheckListItem(selectdlg.ImportProfileListView,it->getName(),QCheckListItem::CheckBox); item->setText(1,type); item->setText(2,it->getGateway()); selectdlg.ImportProfileListView->insertItem(item); // std::cout << "insert profile into listview: " << name << std::endl; } } bool ret = selectdlg.exec(); if (ret == true) { QListViewItemIterator it2( selectdlg.ImportProfileListView ); for ( ; it2.current(); ++it2 ) { if ( ( (QCheckListItem*)it2.current() )->isOn() ) { VpnAccountData *data=NULL; it = 0; for ( it = AccountList->first(); it; it = AccountList->next() ) if ( it->getName() == ( (QCheckListItem*)it2.current() )->text() && ( (QCheckListItem*)it2.current() )->isOn() ) data = it; exportAccountList->append(data); } } exportGlobal = selectdlg.ImportGlobalSettingsCheckBox->isChecked(); if (exportAccountList->count() == 0 && exportGlobal==false) { KMessageBox::sorry ( 0, i18n ( "No profiles for export, export canceled." ) ); exportfile.close(); exportfile.remove(); return false; } } else { KMessageBox::sorry ( 0, i18n ( "Export canceled." ) ); exportfile.close(); exportfile.remove(); return false; } QString date (__DATE__); QString day= date.section(' ',0,0); QString month= QString().setNum(QDate::fromString(date.section(' ',0,0),Qt::ISODate).month()); QString year= date.section(' ',2,2); QString currentdate ( date+" "+ QTime().currentTime().toString( "hh:mm" ) ); QTextStream ExportStream ( &exportfile ); ExportStream << "" << "\n"; ExportStream << "" << "\n"; ExportStream << "" << "\n"; ExportStream << "\t" << "\n"; ExportStream << "\t\t" << "0.9.2" << "" << "\n"; ExportStream << "\t\t" << "1" << "" << "\n"; ExportStream << "\t" << "\n"; if (exportGlobal == true) { ExportStream << "\t" << "\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; // ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t\n"; ExportStream << "\t\t" << "\n"; } ExportStream << "\t" << "\n"; // VpnAccountData *it; if ( !exportAccountList->isEmpty() ) { for ( it = exportAccountList->first(); it; it = exportAccountList->next() ) { // std::cout << "export profile: " << it->getName().ascii() << std::endl; ExportStream << "\t\tgetName() << "\">" << "\n"; // normal config if ( it->getConnectionType() == VpnAccountData::cisco ) ExportStream << "\t\t\t" << "\n"; else if ( it->getConnectionType() == VpnAccountData::ciscoorig ) ExportStream << "\t\t\t" << "\n"; else if ( it->getConnectionType() == VpnAccountData::racoon ) ExportStream << "\t\t\t" << "\n"; else if ( it->getConnectionType() == VpnAccountData::l2tpd_racoon ) ExportStream << "\t\t\t" << "\n"; else if ( it->getConnectionType() == VpnAccountData::freeswan ) ExportStream << "\t\t\t" << "\n"; else if ( it->getConnectionType() == VpnAccountData::l2tpd_freeswan ) ExportStream << "\t\t\t" << "\n"; else if ( it->getConnectionType() == VpnAccountData::pptp ) ExportStream << "\t\t\t" << "\n"; else if ( it->getConnectionType() == VpnAccountData::openvpn ) ExportStream << "\t\t\t" << "\n"; else ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; if ( it->getAuthType() == VpnAccountData::cert ) ExportStream << "\t\t\t" << "\n"; if ( it->getAuthType() == VpnAccountData::psk ) ExportStream << "\t\t\t" << "\n"; if ( it->getAuthType() == VpnAccountData::hybrid ) ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t\t" << "\n"; ExportStream << "\t\t" << "\n"; exportCount++; } } ExportStream << "\t" << "\n"; ExportStream << "" << "\n"; exportfile.close(); } else { KMessageBox::error ( 0, i18n ( "Creating of \"%1\" has been failed!" ).arg ( filename ) ); return false; } } else { KMessageBox::information ( 0, i18n ( "Export canceled." ) ); return false; } QString msg=""; if (exportCount > 0 && exportGlobal==true) msg = i18n("Export was successful. %1 profiles and global settings are exported.").arg(QString::number(exportCount)); if (exportCount > 0 && exportGlobal==false) msg = i18n("Export was successful. %1 profiles are exported.").arg(QString::number(exportCount)); if (exportCount < 1 && exportGlobal==true) msg = i18n("Export was successful. Global settings are exported."); KMessageBox::information ( 0, msg,i18n("Export success") ); return true; } bool KVpncConfig::importKvpncConfig(QString filename, QString& RetName, bool& openProfileManager) { QFile importfile (filename); if (!importfile.exists()) { KMessageBox::error ( 0, i18n ( "Reading of \"%1\" has been failed!" ).arg ( filename ) ); return false; } QString kvpncexportversion=""; QString pathToVpnc; QString pathToCiscoVpnc; QString pathToRacoon; QString pathToRacoonctl; QString pathToSetkey; QString pathToIptables; QString pathToOpenssl; QString pathToIpsec; QString pathToPppd; QString pathToPptp; QString pathToL2tpd; QString pathToXl2tpd; QString pathToOpenl2tp; QString pathToKill; QString pathToKillall; QString pathToPing; QString pathToOpenvpn; QString pathToIp; QString pathToIfconfig; QString pathToRoute; QString pathToNetstat; QString pathToPkcs11Tool; QString pathToVtund; QString pathToCiscoCertMgr; QString pathToTail; QString pathToSsh; QString pathToKsshAskpass; QString pathToGnomeSshAskpass; QString AutoConnectProfile; QString RacoonDebugLevel; QString Vpnc_pid_file; QString Pppd_pid_file; QString lastProfile; QString logfileName; QString TmpPassword; //< from enter password dialog QString TmpGroupPassword; //< from enter password dialog QString TmpUsername; //< from enter password dialog QString TmpPrivKeyPassStr; QString TmpGatewayIP; QString TmpXauthInterPasscode; //< from Xauth interactive passcode dialog QString TmpPrivateKeyPass; QString TmpHttpProxyPassword; bool minimizeAfterConnect=true; bool showDebugConsole=true; bool writeLogFile=true; bool useDefaultPaths=true; bool useSilentQuit=false; bool holdGeneratedScripts=true; bool programsInPath=true; bool enableDebugPppd=false; bool enableDebugPptpd=false; bool enableDebugL2tpd=false; bool enableDebugXl2tpd=false; bool enableDebugOpenl2tp=false; bool enableFreeswanVerbose=false; bool enableDebugOpenvpn=false; bool useColorizedLogOutput=true; bool showInterfaceIPinTooltip=true; bool dontQuitOnCloseEvent=true; bool doAutoConnectAtStartup=false; bool useKwallet=true; bool showStatusBar=true; bool showToolBar=true; bool hideMainWindow=false; bool PppdDebugLevel=false; bool firstUseOfKwallet=false; bool shutdownIsCalled=false; bool skipKwalletStoring=false; bool hideOnCloseInfo=false; bool feedbackMailSent=false; bool doKillL2tpdIfStillRunning=false; bool doKillXl2tpdIfStillRunning=false; bool doKillRacoonIfStillRunning=false; bool showConnectionTimeInTooltip=false; int VpncDebugLevel=0; int KvpncDebugLevel=1; int OpenvpnDebugLevel=0; int PptpLogLevel=0; int SshDebugLevel=0; int PppdKernelLogLevel=0; int LogViewerFontSize=10; int mainwindow_pos_x=10; int mainwindow_pos_y=10; int mainwindow_height=600; int mainwindow_width=800; int connectSleepDelay=10; int connectSleepRetry=3; int tryConnectTimeout=30; int connectionStartTime=0; int runningCheckCounter=0; int runningCheckTimeout=0; int OpenvpnManagementPort=2222; QPtrList *ImportedAccountList; QColor InfoLogColor; QColor RemoteLogColor; QColor ErrorLogColor; QColor SuccessLogColor; QColor DebugLogColor; QColor DebugBackgroundcolor; QPoint pos; QPoint WindowPos; QSize WindowSize; bool importGlobal=false; int importCount=0; QDomDocument doc( "kvpncsettingsdoc" ); if( importfile.open(IO_ReadOnly)) { QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); if ( !doc.setContent( &importfile ) ) { importfile.close(); KMessageBox::error ( 0, i18n ( "Reading of \"%1\" has been failed!" ).arg ( filename ) ); appendLogEntry (i18n ( "Reading of \"%1\" has been failed!" ).arg ( filename ), error); QApplication::restoreOverrideCursor(); return false; } importfile.close(); // print out the element names of all elements that are direct children // of the outermost element. QDomElement docElem = doc.documentElement(); QDomNode n = docElem.firstChild(); if (KvpncDebugLevel > 5) std::cout << "dom doc:" << std::endl; while( !n.isNull() ) { if (n.toElement().tagName() == "version") { if (KvpncDebugLevel > 5) std::cout << "version tag found." << std::endl; QDomNodeList vsubnodes = n.toElement().childNodes(); for (int i=0;i<=(int)vsubnodes.count();i++) { QDomNode n1 = vsubnodes.item(i); if (n1.toElement().tagName() == "app") { if (KvpncDebugLevel > 5) std::cout << " doc was created from kvpnc ver " << n1.toElement().text() << std::endl; } if (n1.toElement().tagName() == "exportversion") { kvpncexportversion = n1.toElement().text(); if (KvpncDebugLevel > 5) std::cout << " doc was created from kvpnc with exportver " << n1.toElement().text() << std::endl; } } } if (n.toElement().tagName() == "global") { if (KvpncDebugLevel > 5) std::cout << "gobal tag found." << std::endl; QDomNodeList vsubnodes = n.toElement().childNodes(); for (int i=0;i<=(int)vsubnodes.count();i++) { QDomNode n1 = vsubnodes.item(i); if (n1.toElement().tagName() != "") { if (KvpncDebugLevel > 5) std::cout << " => option: " << ", value: " << n1.toElement().text() << std::endl; } if ( n1.toElement().tagName() == "Minimize after connect" ) { minimizeAfterConnect = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Hide on startup" ) { hideMainWindow = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Use silent quit" ) { useSilentQuit = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Dont quit on CloseEvent" ) { dontQuitOnCloseEvent = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Enable pppd debug" ) { enableDebugPppd = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Enable pptpd debug" ) { enableDebugPptpd = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Enable l2tpd debug" ) { enableDebugL2tpd = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Enable xl2tpd debug" ) { enableDebugXl2tpd = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Enable openl2tp debug" ) { enableDebugOpenl2tp = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Enable FreeSWAN verbose" ) { enableFreeswanVerbose = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Pluto Debug" ) { PlutoDebug = QStringList::split(' ', n1.toElement().text()); } else if ( n1.toElement().tagName() == "Klips Debug" ) { KlipsDebug = QStringList::split(' ', n1.toElement().text()); } else if ( n1.toElement().tagName() == "Show debugconsole" ) { showDebugConsole = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Pid file for vpnc " ) { Vpnc_pid_file = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Vpnc debuglevel" ) { VpncDebugLevel = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Racoon debuglevel" ) { RacoonDebugLevel = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Kvpnc debuglevel" ) { KvpncDebugLevel = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Pppd debuglevel" ) { PppdDebugLevel = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Pppd kernel log level" ) { PppdKernelLogLevel = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Openvpn debuglevel" ) { OpenvpnDebugLevel = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Pptp debuglevel" ) { PptpLogLevel = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Ssh debuglevel" ) { SshDebugLevel = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Path to vpnc-bin" ) { pathToVpnc = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to vpnclient" ) { pathToCiscoVpnc = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to racoon" ) { pathToRacoon = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to racoonctl" ) { pathToRacoonctl = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to setkey" ) { pathToSetkey = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to iptables" ) { pathToIptables = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to openssl" ) { pathToOpenssl = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to freeswan" ) { pathToIpsec = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to pppd" ) { pathToPppd = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to pptp" ) { pathToPptp = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to l2tpd" ) { pathToL2tpd = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to xl2tpd" ) { pathToXl2tpd = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to openl2tp" ) { pathToOpenl2tp = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to kill" ) { pathToKill = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to kill-all" ) { pathToKillall = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to ping" ) { pathToPing = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to openvpn" ) { pathToOpenvpn = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to iputility" ) { pathToIp = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to ifconfig" ) { pathToIfconfig = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to route" ) { pathToRoute = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to netstat" ) { pathToNetstat = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to pkcs11-tool" ) { pathToPkcs11Tool = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to vtund" ) { pathToVtund = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to cisco_cert_mgr" ) { pathToCiscoCertMgr = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to tail" ) { pathToTail = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to ssh" ) { pathToSsh = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to ksshaskpass" ) { pathToKsshAskpass = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Path to ssh-askpass-gnome" ) { pathToGnomeSshAskpass = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Show Statusbar" ) { showStatusBar = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Try connect timeout" ) { tryConnectTimeout = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Last Profile" ) { lastProfile = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Write log file" ) { writeLogFile = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Hold generated scripts" ) { holdGeneratedScripts = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Programs in path" ) { programsInPath = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Info logwindow color" ) { InfoLogColor.name() = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Remote logwindow color" ) { RemoteLogColor.name() = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Error logwindow color" ) { ErrorLogColor.name() = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Success logwindow color" ) { SuccessLogColor.name() = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Debug logwindow color" ) { DebugLogColor.name() = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Debug background color" ) { DebugBackgroundcolor.name() = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Use colorized log output" ) { useColorizedLogOutput = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Show interface IP in tooltip" ) { showInterfaceIPinTooltip = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Auto connect profile" ) { AutoConnectProfile = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Do auto connect at startup" ) { doAutoConnectAtStartup = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Log viewer font size" ) { LogViewerFontSize = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Mainwindow width" ) { mainwindow_width = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Mainwindow height" ) { mainwindow_height = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Mainwindow position x" ) { mainwindow_pos_x = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Mainwindow position y" ) { mainwindow_pos_y = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Openvpn management port" ) { OpenvpnManagementPort = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "hideOnCloseInfo" ) { hideOnCloseInfo = n1.toElement().text().toInt(); } // else if (n1.toElement().tagName() == "ToolBar Settings") { parent->toolBar( "mainToolBar" ) = n1.toElement().text(); } else if ( n1.toElement().tagName() == "Use KWallet" ) { useKwallet = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "FeedbackMailSent" ) { feedbackMailSent = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Do kill l2tpd if still running" ) { doKillL2tpdIfStillRunning = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Do kill xl2tpd if still running" ) { doKillXl2tpdIfStillRunning = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Do kill racoon if still running" ) { doKillRacoonIfStillRunning = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Show connection time in Tooltip" ) { showConnectionTimeInTooltip = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "Enable debug Openvpn" ) { enableDebugOpenvpn = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "EnableDebugXl2tpdNetwork") { enableDebugXl2tpdNetwork = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "EnableDebugXl2tpdpacket" ) { enableDebugXl2tpdpacket = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "EnableDebugXl2tpdstate" ) { enableDebugXl2tpdstate = n1.toElement().text().toInt(); } else if ( n1.toElement().tagName() == "EnableDebugXl2tpdtunnel") { enableDebugXl2tpdtunnel = n1.toElement().text().toInt(); } } } if (n.toElement().tagName() == "profiles") { if (KvpncDebugLevel > 5) std::cout << "profiles tag found." << std::endl; ImportedAccountList = new QPtrList(); ImportedAccountList->setAutoDelete( TRUE ); // the list owns the objects QDomNodeList profiles_subnodes = n.toElement().childNodes(); for (int i=0;i<=(int)profiles_subnodes.count();i++) { QDomNode n1 = profiles_subnodes.item(i); if (n1.toElement().attribute("name") != "") { if (KvpncDebugLevel > 5) std::cout << "profile: " << n1.toElement().attribute("name") << std::endl; QString name = n1.toElement().attribute("name"); VpnAccountData *data = new VpnAccountData( VpnAccountData::cisco, name); // cisco is a dummy here, it will be set later data->setDescription(i18n("import from ")+filename); QDomNodeList profile_subnodes = n1.toElement().childNodes(); for (int j=0;j<=(int)profile_subnodes.count();j++) { QDomNode n2 = profile_subnodes.item(j); if (n2.toElement().attribute("name") != "") { QString elementname= n2.toElement().attribute("name"); QString elementvalue = n2.toElement().text(); if (KvpncDebugLevel > 5) std::cout << " => option: " << elementname << ", value: " << elementvalue << std::endl; // normal config if (elementname == "Connection type") { QString type = elementvalue; VpnAccountData::ConnectionType ConnType = VpnAccountData::ConnectionType( VpnAccountData::cisco ); if ( type == "cisco" ) ConnType = VpnAccountData::cisco; else if ( type == "ciscoorig" ) ConnType = VpnAccountData::ciscoorig; else if ( type == "racoon" ) ConnType = VpnAccountData::racoon; else if ( type == "l2tpd (racoon)" ) ConnType = VpnAccountData::l2tpd_racoon; else if ( type == "freeswan" ) ConnType = VpnAccountData::freeswan; else if ( type == "l2tpd (openswan)" ) ConnType = VpnAccountData::l2tpd_freeswan; else if ( type == "pptp" ) ConnType = VpnAccountData::pptp; else if ( type == "openvpn" ) ConnType = VpnAccountData::openvpn; else if ( type == "vtun" ) ConnType = VpnAccountData::vtun; else if ( type == "ssh" ) ConnType = VpnAccountData::ssh; else ConnType = VpnAccountData::other; data->setConnectionType(ConnType); // std::cout << " ==> type: " << type << std::endl; } else if (elementname == "VPN Gateway") { data->setGateway(elementvalue); } else if (elementname == "VPN ID") { data->setID(elementvalue); } else if (elementname == "Username") { data->setUserName(elementvalue); } else if (elementname == "Save user password") { data->setSaveUserPassword(elementvalue.toInt()); } else if (elementname == "Save PSK") { data->setSavePsk(elementvalue.toInt()); } else if (elementname == "Save private key password") { data->setSavePrivateKeyPassword(elementvalue.toInt()); } else if (elementname == "Private key") { data->setPrivateKey(elementvalue); } else if (elementname == "Use advanced settings") { data->setUseAdvancedSettings(elementvalue.toInt()); } else if (elementname == "Application version") { data->setApplicationVersion(elementvalue); } else if (elementname == "Local port") { data->setLocalPort(elementvalue.toInt()); } else if (elementname == "Remote port") { data->setRemotePort(elementvalue.toInt()); } else if (elementname == "NT domain name") { data->setNtDomainName(elementvalue); } else if (elementname == "Perfect forward secrety") { data->setPerfectForwardSecrety(elementvalue); } else if (elementname == "IKE group") { data->setIkeGroup(elementvalue); } else if (elementname == "Use application version") { data->setUseApplicationVersion(elementvalue.toInt()); } else if (elementname == "Use global IPSec secret") { data->setUseGlobalIpsecSecret(elementvalue.toInt()); } else if (elementname == "Use IKE group") { data->setUseIkeGroup(elementvalue.toInt()); } else if (elementname == "Use local port") { data->setUseLocalPort(elementvalue.toInt()); } else if (elementname == "Use remote port") { data->setUseRemotePort(elementvalue.toInt()); } else if (elementname == "Use NT domain name") { data->setUseNtDomainName(elementvalue.toInt()); } else if (elementname == "Use single DES") { data->setUseSingleDes(elementvalue.toInt()); } else if (elementname == "Use perfect Forward Secrety") { data->setUsePerfectForwardSecrety(elementvalue.toInt()); } else if (elementname == "Remote net address") { data->setRemoteNetAddr(elementvalue); } else if (elementname == "Remote net mask") { data->setRemoteNetMask(elementvalue); } else if (elementname == "x509 certificate") { data->setX509Certificate(elementvalue); } else if (elementname == "Ca certificate") { data->setCaCertificate(elementvalue); } else if (elementname == "Network device") { data->setNetworkDevice(elementvalue); } else if (elementname == "Cert path") { data->setCertPath(elementvalue); } else if (elementname == "Auth type") { QString Authtype = elementvalue; if (Authtype == "cert") data->setAuthType(VpnAccountData::cert); else if (Authtype == "psk") data->setAuthType(VpnAccountData::psk); else if (Authtype == "hybrid") data->setAuthType(VpnAccountData::hybrid); else data->setAuthType( VpnAccountData::unknownauth); if ((data->getConnectionType() == VpnAccountData::pptp || data->getConnectionType() == VpnAccountData::openvpn ) && (Authtype != "cert" && Authtype == "psk")) data->setAuthType(VpnAccountData::cert); } else if (elementname == "do ping ip") { data->setDoPingIP(elementvalue.toInt()); } else if (elementname == "Ping host IP") { data->setPingHostIP(elementvalue); } else if (elementname == "Special server certificate") { data->setSpecialServerCertificate(elementvalue); } else if (elementname == "Use special server certificate") { data->setUseSpecialServerCertificate(elementvalue.toInt()); } else if (elementname == "Special remote ID") { data->setSpecialRemoteID(elementvalue); } else if (elementname == "Special local ID") { data->setSpecialLocalID(elementvalue); } else if (elementname == "Local ID type") { data->setLocalIDType(elementvalue); } else if (elementname == "Remote ID type") { data->setRemoteIDType(elementvalue); } else if (elementname == "Use UDP-protocol") { data->setUseUdp(elementvalue.toInt()); } else if (elementname == "Use UDP-port") { data->setUseUdpPort(elementvalue.toInt()); } else if (elementname == "local UDP port") { data->setUdpPort(elementvalue.toInt()); } else if (elementname == "use DNS_UPDATE") { data->setUseDnsUpdate(elementvalue.toInt()); } else if (elementname == "use DNS-server") { data->setUseDnsServer(elementvalue.toInt()); } else if (elementname == "DNS server") { data->setDnsServer(elementvalue); } else if (elementname == "refuse 40 bit encryption") { data->setRefuse40BitEncryption(elementvalue.toInt()); } else if (elementname == "refuse 128 bit encryption") { data->setRefuse128BitEncryption(elementvalue.toInt()); } else if (elementname == "require stateless encryption") { data->setAllowStatefulMode(elementvalue.toInt()); } else if (elementname == "require mppe") { data->setRequireMppe(elementvalue.toInt()); } else if (elementname == "Disable MPPE compression") { data->setDisableMPPEComp(elementvalue.toInt()); } else if (elementname == "Local virtual IP") { data->setLocalVirtualIP(elementvalue); } else if (elementname == "Remote virtual IP") { data->setRemoteVirtualIP(elementvalue); } else if (elementname == "Pre shared key file") { data->setPreSharedKeyFile(elementvalue); } else if (elementname == "Execute command before connect") { data->setExecuteCmdBeforeConnect(elementvalue.toInt()); } else if (elementname == "Execute command after connect") { data->setExecuteCmdAfterConnect(elementvalue.toInt()); } else if (elementname == "Execute command before disconnect") { data->setExecuteCmdBeforeDisconnect(elementvalue.toInt()); } else if (elementname == "Execute command after disconnect") { data->setExecuteCmdAfterDisconnect(elementvalue.toInt()); } else if (elementname == "Command before connect") { data->setCommandBeforeConnect(elementvalue); } else if (elementname == "Command after connect") { data->setCommandAfterConnect(elementvalue); } else if (elementname == "Command before disconnect") { data->setCommandBeforeDisconnect(elementvalue); } else if (elementname == "Command after disconnect") { data->setCommandAfterDisconnect(elementvalue); } else if (elementname == "Use no BSD compression") { data->setUseNoBsdComp(elementvalue.toInt()); } else if (elementname == "Do not use no IP by default") { data->setUseNoIpDefault(elementvalue.toInt()); } else if (elementname == "Use no deflate") { data->setUseNoDeflate(elementvalue.toInt()); } else if (elementname == "Replace default route") { data->setReplaceDefaultRoute(elementvalue.toInt()); } else if (elementname == "Use own MTU") { data->setUseMtu(elementvalue.toInt()); } else if (elementname == "Use own MRU") { data->setUseMru(elementvalue.toInt()); } else if (elementname == "MTU for pppd") { data->setMtu(elementvalue.toInt()); } else if (elementname == "MRU for pppd") { data->setMru(elementvalue.toInt()); } else if (elementname == "Use virtual IP") { data->setUseVirtualIP(elementvalue.toInt()); } else if (elementname == "Virtual IP") { data->setVirtualIP(elementvalue); } else if (elementname == "PSK is in file") { data->setPskIsInFile(elementvalue.toInt()); } else if (elementname == "Use additional network routes") { data->setUseAdditionalNetworkRoutes(elementvalue.toInt()); } else if (elementname == "Hash algorithm") { data->setHashAlgo(elementvalue); } else if (elementname == "Encryption algorithm") { data->setEncryptionAlgorithm(elementvalue); } else if (elementname == "Authentication algorithm") { data->setAuthenticationAlgorithm(elementvalue); } else if (elementname == "Tunnel device type") { data->setTunnelDeviceType(elementvalue); } else if (elementname == "Use userdefined port") { data->setUseUserdefinedPort(elementvalue.toInt()); } else if (elementname == "Userdefined port") { data->setUserdefinedPort(elementvalue.toInt()); } else if (elementname == "NS cert type") { data->setNsCertType(elementvalue); } else if (elementname == "Use NS cert type") { data->setUseNsCertType(elementvalue.toInt()); } else if (elementname == "Use connection status check") { data->setUseConnectionStatusCheck(elementvalue.toInt()); } else if (elementname == "Connection check success count") { data->setConnectionStatusCheckSuccessCount(elementvalue.toInt()); } else if (elementname == "Connection check status interval") { data->setConnectionStatusInterval(elementvalue.toInt()); } else if (elementname == "Do reconnect after connection lost") { data->setDoReconnectAfterConnectionLost(elementvalue.toInt()); } else if (elementname == "Disable LZO compression") { data->setDisableLzoCompression(elementvalue.toInt()); } else if (elementname == "AuthWithUsernameAndPassword") { data->setAuthWithUsernameAndPassword(elementvalue.toInt()); } else if (elementname == "AllowEmptyGroupPassword") { data->setAllowEmptyGroupPassword(elementvalue.toInt()); } else if (elementname == "Use userdefinied cipher") { data->setUseUserdefiniedCipher(elementvalue.toInt()); } else if (elementname == "Userdefinied cipher") { data->setUserdefiniedCipher(elementvalue); } else if (elementname == "Use redirect gateway") { data->setUseRedirectGateway(elementvalue.toInt()); } // appPointer->processEvents(<< "") { "\n"; else if (elementname == "Use TLS auth") { data->setUseTlsAuth(elementvalue.toInt()); } else if (elementname == "TLS auth file") { data->setTlsAuthFile(elementvalue); } else if (elementname == "Use HTTP proxy") { data->setUseHttpProxy(elementvalue.toInt()); } else if (elementname == "HTTP proxy host") { data->setHttpProxy(elementvalue); } else if (elementname == "HTTP proxy port") { data->setHttpProxyPort(elementvalue.toInt()); } else if (elementname == "HTTP proxy timeout") { data->setHttpProxyTimeout(elementvalue.toInt()); } else if (elementname == "Dont save username") { data->setDontSaveUsername(elementvalue.toInt()); } else if (elementname == "Use mode config") { data->setUseModeConfig(elementvalue.toInt()); } else if (elementname == "Exchange mode") { data->setExchangeMode(elementvalue); } else if (elementname == "Use delay at reconnect") { data->setUseReconnectDelay(elementvalue.toInt()); } else if (elementname == "Reconnect delay") { data->setReconnectDelay(elementvalue.toInt()); } else if (elementname == "Use TLS host") { data->setUseTlsRemoteHost(elementvalue.toInt()); } else if (elementname == "TLS remote host") { data->setTlsRemoteHost(elementvalue); } else if (elementname == "Disable opportunistic encryption") { data->setDisableOpportunisticEncryption(elementvalue.toInt()); } else if (elementname == "Right next hop") { data->setRightNextHop(elementvalue); } else if (elementname == "Left next hop") { data->setLeftNextHop(elementvalue); } else if (elementname == "Use userdefinied packet size for fragmentation") { data->setUseFragment(elementvalue.toInt()); } else if (elementname == "Use userdef packet size") { data->setUseMssfix(elementvalue.toInt()); } else if (elementname == "Fragment") { data->setFragment(elementvalue.toInt()); } else if (elementname == "PeerTimeout") { data->setPeerTimeout(elementvalue.toInt()); } else if (elementname == "Disable CCP") { data->setDisableCcp(elementvalue.toInt()); } else if (elementname == "Use smartcard") { data->setUseSmartcard(elementvalue.toInt()); } else if (elementname == "Use Xauth interactive") { data->setUseXauthInteractive(elementvalue.toInt()); } else if (elementname == "Use HTTP Proxy Authentication") { data->setUseHttpProxyAuth(elementvalue.toInt()); } else if (elementname == "HTTP Proxy Authtype") { data->setHttpProxyAuthType(elementvalue); } else if (elementname == "HTTP Proxy Auth user") { data->setHttpProxyUser(elementvalue); } else if (elementname == "HTTP Proxy Auth pass") { data->setHttpProxyPass(elementvalue); } else if (elementname == "Use only CA cert and user auth") { data->setUseOnlyCaCertAndUserAuth(elementvalue.toInt()); } else if (elementname == "Use mail address as identifier") { data->setUseMailAddressAsIdentifier(elementvalue.toInt()); } else if (elementname == "Use right next hop") { data->setUseRightNextHop(elementvalue.toInt()); } else if (elementname == "Use left next hop") { data->setUseLeftNextHop(elementvalue.toInt()); } else if (elementname == "Pkcs11 providers") { data->setPkcs11Providers(elementvalue); } else if (elementname == "Pkcs11 slot type") { data->setPkcs11SlotType(elementvalue); } else if (elementname == "Pkcs11 slot") { data->setPkcs11Slot(elementvalue); } else if (elementname == "Pkcs11 id type") { data->setPkcs11IdType(elementvalue); } else if (elementname == "Pkcs11 id") { data->setPkcs11Id(elementvalue); } else if (elementname == "Pkcs11 sign mode") { data->setPkcs11SignMode(elementvalue); } else if (elementname == "Use Pkcs11 providers") { data->setUsePkcs11Providers(elementvalue.toInt()); } else if (elementname == "Allow empty private key password") { data->setAllowEmptyPrivateKeyPassword(elementvalue.toInt()); } else if (elementname == "Allow ip address change of peer") { data->setAllowIpAddressChangeOfPeer(elementvalue.toInt()); } else if (elementname == "Auth method") { data->setAuthMethod(elementvalue); } else if (elementname == "Command after connect delay time") { data->setCommandAfterConnectDelayTime(elementvalue.toInt()); } else if (elementname == "Use search domain in resolv conf") { data->setUseSearchDomainInResolvConf(elementvalue.toInt()); } else if (elementname == "Use domain in resolv conf") { data->setUseDomainInResolvConf(elementvalue.toInt()); } else if (elementname == "Search domain in resolv conf") { data->setSearchDomainInResolvConf(elementvalue); } else if (elementname == "Domain in resolv conf") { data->setDomainInResolvConf(elementvalue); } else if (elementname == "Authentication direction") { data->setAuthenticationDirection(elementvalue); } else if (elementname == "CiscoNatMode") { data->setCiscoNatMode(elementvalue); } else if (elementname == "IPSec ESP") { data->setIpsecEsp(elementvalue); } else if (elementname == "IPSec IKE") { data->setIpsecIke(elementvalue); } else if (elementname == "Vtun profile") { data->setVtunProfile(elementvalue); } else if (elementname == "Disable data encryption") { data->setDisableDataEncryption(elementvalue.toInt()); } else if (elementname == "Use authentication algorithm") { data->setUseAuthenticationAlgorithm(elementvalue.toInt()); } else if (elementname == "Fix path mtu discovery problem") { data->setFixPathMtuDiscoveryProblem(elementvalue.toInt()); } else if (elementname == "Use remote network") { data->setUseRemoteNetwork(elementvalue.toInt()); } else if (elementname == "Ipsec vpn mode") { data->setIpsecVpnMode(elementvalue); } else if (elementname == "DisableHeaderCompression") { data->setDisableHeaderCompression(elementvalue.toInt()); } else if (elementname == "DisableMagicNumberNegotiation") { data->setDisableMagicNumberNegotiation(elementvalue.toInt()); } else if (elementname == "DisableIpx") { data->setDisableIpx(elementvalue.toInt()); } else if (elementname == "Disable protocol field compression") { data->setDisableProtocolFieldCompression(elementvalue.toInt()); } else if (elementname == "Disable adress control compression") { data->setDisableAdressControlCompression(elementvalue.toInt()); } else if (elementname == "Use custom ike") { data->setUseCustomIke(elementvalue.toInt()); } else if (elementname == "Use custom esp") { data->setUseCustomEsp(elementvalue.toInt()); } else if (elementname == "Verify ca cert") { data->setVerifyCaCert(elementvalue.toInt()); } else if (elementname == "Use DPD idle timeout") { data->setUseDpdIdleTimeout(elementvalue.toInt()); } else if (elementname == "DPD idle timeout") { data->setDpdIdleTimeout(elementvalue.toInt()); } else if (elementname == "Hide group password in accountdata dialog") { data->setHideGroupPasswordInAccountDataDialog(elementvalue.toInt()); } else if (elementname == "MaxConnectTries") { data->setMaxConnectTries(elementvalue.toInt()); } else if (elementname == "L2tpDaemon") { data->setL2tpDaemon((VpnAccountData::L2tpDaemonType)elementvalue.toInt()); } else if (elementname == "UseLeftSourceIp") { data->setUseLeftSourceIp(elementvalue.toInt()); } else if (elementname == "UseRightSourceIp") { data->setUseRightSourceIp(elementvalue.toInt()); } else if (elementname == "LeftSourceIp") { data->setLeftSourceIp(elementvalue); } else if (elementname == "RightSourceIp") { data->setRightSourceIp(elementvalue); } else if (elementname == "Use virtual subnets") { data->setUseVirtualSubnetworks(elementvalue.toInt()); } else if (elementname == "Virtual subnets") { data->setVirtualSubnetworks(elementvalue); } else if (elementname == "DisablePushFromServer") { data->setDisablePushFromServer(elementvalue.toInt()); } else if (elementname == "DisableBind") { data->setDisableBind(elementvalue.toInt()); } else if (elementname == "UseRenegSec") { data->setUseRenegSec(elementvalue.toInt()); } else if (elementname == "RenegSec") { data->setRenegSec(elementvalue.toInt()); } else if (elementname == "UseTunnelPing") { data->setUseTunnelPing(elementvalue.toInt()); } else if (elementname == "TunnelPing") { data->setTunnelPing(elementvalue.toInt()); } else if (elementname == "UseTunnelPingRestart") { data->setUseTunnelPingRestart(elementvalue.toInt()); } else if (elementname == "TunnelPingRestart") { data->setTunnelPingRestart(elementvalue.toInt()); } else if (elementname == "RequireEap") { data->setRequireEap(elementvalue.toInt()); } else if (elementname == "UseSshConfigRemoteScript") { data->setUseSshConfigRemoteScript(elementvalue.toInt()); } else if (elementname == "SshConfigRemoteScript") { data->setSshConfigRemoteScript(elementvalue); } else if (elementname == "AskUserPasswordOnEachConnect") { data->setAskUserPasswordOnEachConnect(elementvalue.toInt()); } else if (elementname == "UseCiscoCertStore") { data->setUseCiscoCertStore(elementvalue.toInt()); } else if (elementname == "UseNat") { data->setUseNat(elementvalue.toInt()); } } } if (KvpncDebugLevel > 5) std::cout << "profile end " << std::endl; ImportedAccountList->append(data); } appPointer->processEvents(); } QApplication::restoreOverrideCursor(); KvpncImportProfileSelectionDialog selectdlg; VpnAccountData *it=NULL; if ( !ImportedAccountList->isEmpty() ) { selectdlg.ImportProfileListView->takeItem(selectdlg.ImportProfileListView->currentItem()); selectdlg.ImportProfileListView->addColumn(i18n("Name")); selectdlg.ImportProfileListView->addColumn(i18n("Type")); selectdlg.ImportProfileListView->addColumn(i18n("Gateway")); selectdlg.ImportNamePrefixLineEdit->setText( "kvpnc_import_"); QCheckListItem *item; for ( it = ImportedAccountList->first(); it; it = ImportedAccountList->next() ) { QString name = it->getName(); QString type; if ( it->getConnectionType() == VpnAccountData::cisco ) type = "cisco" ; else if ( it->getConnectionType() == VpnAccountData::ciscoorig ) type = "ciscoorig" ; else if ( it->getConnectionType() == VpnAccountData::racoon ) type = "racoon" ; else if ( it->getConnectionType() == VpnAccountData::l2tpd_racoon ) type = "l2tpd (racoon)" ; else if ( it->getConnectionType() == VpnAccountData::freeswan ) type = "freeswan" ; else if ( it->getConnectionType() == VpnAccountData::l2tpd_freeswan ) type = "l2tpd (openswan)" ; else if ( it->getConnectionType() == VpnAccountData::pptp ) type = "pptp" ; else if ( it->getConnectionType() == VpnAccountData::openvpn ) type = "openvpn" ; else type = i18n("other"); // litem->setSelectable(true); item = new QCheckListItem(selectdlg.ImportProfileListView,it->getName(),QCheckListItem::CheckBox); item->setText(1,type); item->setText(2,it->getGateway()); selectdlg.ImportProfileListView->insertItem(item); // std::cout << "insert profile into listview: " << name << std::endl; } } bool ret = selectdlg.exec(); if (ret == true) { importGlobal=selectdlg.ImportGlobalSettingsCheckBox->isChecked(); QListViewItemIterator it2( selectdlg.ImportProfileListView ); for ( ; it2.current(); ++it2 ) { if ( ( (QCheckListItem*)it2.current() )->isOn() ) { VpnAccountData *data=NULL; it = 0; for ( it = ImportedAccountList->first(); it; it = ImportedAccountList->next() ) { if ( it->getName() == ( (QCheckListItem*)it2.current() )->text() && ( (QCheckListItem*)it2.current() )->isOn() ) { data = it; importCount++; // FIXME last profilename here RetName=it->getName(); data->setName(selectdlg.ImportNamePrefixLineEdit->text()+data->getName()); bool ok = false; VpnAccountData * it; bool nameOk = false; while ( nameOk == false ) { for ( it = AccountList->first(); it; it = AccountList->next() ) { if ( it->getName() == data->getName() ) { //account->setName( QString( account->getName() + "_2" ) ); // KMessageBox::information ( this, i18n( "Profile name exists!\n It will be renamed to \"%1\"." ).arg( account->getName() ), i18n( "Name exist, renamed" ) ); KMessageBox::error ( 0, i18n ( "Profile name exists!" ), i18n ( "Name Exists" ) ); nameOk = false; QString newName = KInputDialog::getText ( i18n ( "New Name" ), i18n ( "New name for profile:" ), QString ( data->getName() + "_2" ), &ok ); if (newName.isEmpty()) { KMessageBox::information ( 0, i18n ( "Import was canceled." ) ); appendLogEntry ( i18n ( "Import was canceled." ), info ); return false; } if (newName != it->getName() ) { data->setName ( newName ); nameOk = true; } } else { nameOk = true; } } } if ( nameOk == true ) { AccountList->append(data); } } } } } if (selectdlg.OpenProfileManagerCheckBox->isChecked()) openProfileManager=true; } else { KMessageBox::sorry ( 0, i18n ( "Import canceled." ) ); return false; } } QDomElement e = n.toElement(); // try to convert the node to an element. if( !e.isNull() ) { std::cout << e.tagName() << std::endl; // the node really is an element. } n = n.nextSibling(); } if (KvpncDebugLevel > 5) std::cout << "dom doc end" << std::endl; if (importGlobal == true) { this-> pathToVpnc= pathToVpnc; this-> pathToCiscoVpnc= pathToCiscoVpnc; this-> pathToRacoon= pathToRacoon; this-> pathToSetkey= pathToSetkey; this-> pathToIptables= pathToIptables; this-> pathToIptables= pathToIptables; this-> pathToIpsec= pathToIpsec; this-> pathToPppd= pathToPppd; this-> pathToPptp= pathToPptp; this-> pathToL2tpd= pathToL2tpd; this-> pathToXl2tpd= pathToXl2tpd; this-> pathToSsh= pathToSsh; this-> pathToKill= pathToKill; this-> pathToKillall= pathToKillall; this-> pathToPing= pathToPing; this-> pathToOpenvpn= pathToOpenvpn; this-> pathToIp= pathToIp; this-> pathToIfconfig= pathToIfconfig; this-> pathToRoute= pathToRoute; this-> pathToNetstat= pathToNetstat; this-> pathToPkcs11Tool= pathToPkcs11Tool; this-> AutoConnectProfile= AutoConnectProfile; this-> RacoonDebugLevel= RacoonDebugLevel; this-> Vpnc_pid_file= Vpnc_pid_file; this-> Pppd_pid_file= Pppd_pid_file; this-> lastProfile= lastProfile; this-> logfileName= logfileName; this->minimizeAfterConnect= minimizeAfterConnect; this->showDebugConsole= showDebugConsole; this-> writeLogFile= writeLogFile; this-> useDefaultPaths= useDefaultPaths; this-> useSilentQuit= useSilentQuit; this-> holdGeneratedScripts= holdGeneratedScripts; this-> programsInPath= programsInPath; this-> enableDebugPppd= enableDebugPppd; this-> enableDebugPptpd= enableDebugPptpd; this-> enableDebugL2tpd= enableDebugL2tpd; this-> enableDebugXl2tpd= enableDebugXl2tpd; this-> enableFreeswanVerbose= enableFreeswanVerbose; this-> enableDebugOpenvpn= enableDebugOpenvpn; this-> useColorizedLogOutput= useColorizedLogOutput; this-> showInterfaceIPinTooltip= showInterfaceIPinTooltip; this-> dontQuitOnCloseEvent= dontQuitOnCloseEvent; this-> doAutoConnectAtStartup= doAutoConnectAtStartup; this-> useKwallet= useKwallet; this-> showStatusBar= showStatusBar; this-> showToolBar= showToolBar; this-> hideMainWindow= hideMainWindow; this-> PppdDebugLevel= PppdDebugLevel; this-> firstUseOfKwallet= firstUseOfKwallet; this-> shutdownIsCalled= shutdownIsCalled; this-> skipKwalletStoring= skipKwalletStoring; this-> hideOnCloseInfo= hideOnCloseInfo; this-> feedbackMailSent= feedbackMailSent; this-> doKillL2tpdIfStillRunning= doKillL2tpdIfStillRunning; this-> doKillXl2tpdIfStillRunning= doKillXl2tpdIfStillRunning; this-> doKillRacoonIfStillRunning= doKillRacoonIfStillRunning; this-> showConnectionTimeInTooltip= showConnectionTimeInTooltip; this-> VpncDebugLevel= VpncDebugLevel; this-> KvpncDebugLevel= KvpncDebugLevel; this-> OpenvpnDebugLevel= OpenvpnDebugLevel; this-> PptpLogLevel= PptpLogLevel; this-> SshDebugLevel= SshDebugLevel; this-> LogViewerFontSize= LogViewerFontSize; this-> mainwindow_pos_x= mainwindow_pos_x; this-> mainwindow_pos_y= mainwindow_pos_y; this-> mainwindow_height= mainwindow_height; this-> mainwindow_width= mainwindow_width; this-> connectSleepDelay= connectSleepDelay; this-> connectSleepRetry= connectSleepRetry; this-> tryConnectTimeout= tryConnectTimeout; this-> connectionStartTime= connectionStartTime; this-> runningCheckCounter= runningCheckCounter; this-> runningCheckTimeout= runningCheckTimeout; this-> OpenvpnManagementPort= OpenvpnManagementPort; this->InfoLogColor= InfoLogColor; this->RemoteLogColor= RemoteLogColor; this->ErrorLogColor= ErrorLogColor; this->SuccessLogColor= SuccessLogColor; this->DebugLogColor= DebugLogColor; this->DebugBackgroundcolor= DebugBackgroundcolor; this->pos= pos; this->WindowPos= WindowPos; this->WindowSize= WindowSize; } saveOptions(); QString msg=""; if (importCount > 0 && importGlobal==true) msg = i18n("Import was successful. %1 profiles and global settings are imported.").arg(QString::number(importCount)); if (importCount > 0 && importGlobal==false) msg = i18n("Import was successful. %1 profiles are imported.").arg(QString::number(importCount)); if (importCount < 1 && importGlobal==false) msg = i18n("Import was successful. Global settings are imported."); KMessageBox::information ( 0, msg,i18n("Import success") ); } else { KMessageBox::error ( 0, i18n ( "Reading of \"%1\" has been failed!" ).arg ( filename ) ); appendLogEntry (i18n ( "Reading of \"%1\" has been failed!" ).arg ( filename ), error); QApplication::restoreOverrideCursor(); return false; } return true; } bool KVpncConfig::importIpsecConfig(QString filename, QString& RetName, bool& openProfileManager) { QFile importfile (filename); if (!importfile.exists()) { KMessageBox::error ( 0, i18n ( "Reading of \"%1\" has been failed!" ).arg ( filename ) ); return false; } QPtrList *ImportedAccountList = new QPtrList(); ImportedAccountList->setAutoDelete( TRUE ); // the list owns the objects QPtrList *IpsecImportSectionList = new QPtrList(); bool isIpsecGlobalSection=false; bool firstSectionFound=false; bool defaultSectionFound=false; bool useNat=false; bool disableOpportunisticEncryption=true; QStringList InterfaceList; int IpsecVersion=1; // bool pskIsInFile=true; QString PskFile="/etc/ipsec.secrets"; QString CertPath="/etc/ipsec.d/certs"; QString IpsecConfigSection=""; bool validLineFound=false; if ( importfile.open(IO_ReadOnly)) { QString line = NULL; QString IpsecConfigSectionName=""; QString IpsecConfigData=""; bool sectionEndFound=false; // std::cout << "pass1: collecting sections" << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: pass1: collecting sections"),debug); QTextStream stream(&importfile); while ( !stream.atEnd() ) { line = stream.readLine().replace("\"",""); // std::cout << "line: \"" << line << "\"" << std::endl; if ( IpsecConfigSectionName!="" && ( line=="\n" || removeWhiteSpaceAtBegin(line) =="\n" || line == NULL || line.startsWith("include") || line.startsWith("conn") )) { // end of section found // std::cout << "end of section " << IpsecConfigSectionName << " found." << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n("import ipsec config: end of section %1 found.").arg(IpsecConfigSectionName), debug); sectionEndFound=true; IpsecImportSection *section = new IpsecImportSection(); section->SectionName = IpsecConfigSectionName; section->SectionData = IpsecConfigData; IpsecImportSectionList->append(section); IpsecConfigData=""; IpsecConfigSectionName=""; // std::cout << "Section:"<< std::endl; // std::cout << section->SectionName << std::endl; // std::cout << section->SectionData.join("\n"); // std::cout << "-------------------"<< std::endl; if (KvpncDebugLevel > 2) { appendLogEntry( "import ipsec config: Section:", debug); appendLogEntry( section->SectionName , debug); appendLogEntry( section->SectionData.join("\n"), debug); appendLogEntry( "-------------------", debug); } } if (line.startsWith("conn")) { // section found IpsecConfigSectionName=line.simplifyWhiteSpace().section('#',0,0).section(" ",1,1); // std::cout << "normal section found: " << IpsecConfigSectionName << std::endl; isIpsecGlobalSection=false; if (IpsecConfigSectionName == "%default") { defaultSectionFound=true; sectionEndFound=false; firstSectionFound=true; if (KvpncDebugLevel > 2) appendLogEntry( i18n ("import ipsec config: default section found."), debug); } else { if (KvpncDebugLevel > 2) appendLogEntry( i18n ("import ipsec config: normal section found: ") + IpsecConfigSectionName , debug); sectionEndFound=false; firstSectionFound=true; } } if (line.startsWith("version")) { IpsecVersion=int(QString(line.simplifyWhiteSpace().section('#',0,0).section(" ",1,1).stripWhiteSpace()).toFloat()); validLineFound=true; // std::cout << "ipsec version found: " << IpsecVersion << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: ipsec version found: ")+ QString().setNum(IpsecVersion) ,debug); } if (line.startsWith("config setup")) { // config section found isIpsecGlobalSection=true; validLineFound=true; // std::cout << "global section found." << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: global section found."),debug); } if (isIpsecGlobalSection==true) { QString line2 = removeWhiteSpaceAtBegin( line); // std::cout << "global section line: " << line2 << std::endl; if (line2.startsWith("plutodebug")) { validLineFound=true; // FIXME not implemented yet } if (line2.startsWith("nat_traversal=")) { validLineFound=true; useNat=false; if (line2.section('=',1,1) == "yes") { useNat=true; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: use NAT."),debug); } else { useNat=false; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: use no NAT."),debug); } } if (line2.startsWith("interfaces=")) { validLineFound=true; if (line2.section('=',1,1) == "%defaultroute") { InterfaceList.append("default"); if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: use interface where default route points"),debug); } else { InterfaceList = QStringList::split(' ',line2.replace("interfaces=","").replace(QRegExp("ipsec[0-9]="),"")); // std::cout << "interface list: " << InterfaceList << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: use interface from list:")+ " "+InterfaceList.join(", "),debug); } } } if (line.startsWith("include /etc/ipsec.d/examples/no_oe.conf")) { validLineFound=true; isIpsecGlobalSection=false; // std::cout << "opportunistic enncrytion disabled found." << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: opportunistic encrytion disabled found"),debug); disableOpportunisticEncryption=true; } if (!sectionEndFound && firstSectionFound==true) { // collecting data QString cleanLine = removeWhiteSpaceAtBegin(line)+"\n"; // std:: cout << "clean line: \"" << cleanLine << "\"" << std::endl; if (!cleanLine.startsWith("#") && !cleanLine.startsWith("include") && cleanLine != "" && !line.startsWith("conn") && cleanLine != "\n") { // std:: cout << "appending line: \"" << line << "\"" << std::endl; IpsecConfigData.append(line+"\n"); } else { // std:: cout << "skipping line: \"" << line << "\"" << std::endl; } } } importfile.close(); if (IpsecConfigSectionName!="") { // end of section found // std::cout << "end of section " << IpsecConfigSectionName << " found." << std::endl; if (KvpncDebugLevel > 2) appendLogEntry("end of section " + IpsecConfigSectionName +" found.",debug); sectionEndFound=true; IpsecImportSection *section = new IpsecImportSection(); section->SectionName = IpsecConfigSectionName; section->SectionData = IpsecConfigData; IpsecImportSectionList->append(section); IpsecConfigData=""; IpsecConfigSectionName=""; } // std::cout << "pass2: modifiy sections" << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: pass2: modifiy sections"),debug); // std::cout << "sections: IpsecImportSectionList: " << IpsecImportSectionList->count() << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: sections: ") + QString().setNum(IpsecImportSectionList->count()),debug); if (!IpsecImportSectionList->isEmpty()) { for ( int i=0; i< (int)IpsecImportSectionList->count();i++ ) { IpsecImportSection *section = IpsecImportSectionList->at(i); QString Name= section->SectionName; QStringList data = QStringList::split('\n',section->SectionData.join("\n")); // std::cout << " => processing section: \"" << Name << "\"" << std::endl; if (Name != "%default") { if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: => processing section: ")+"\"" + Name + "\"",debug); for ( QStringList::Iterator it2 = data.begin(); it2 != data.end(); ++it2 ) { QString dataline = *it2; // std::cout << "dataline found: \"" << dataline.remove("\n") << "\"" << std::endl; if (removeWhiteSpaceAtBegin( dataline).startsWith("also=")) { // std::cout << "also= found, looking for other section..." << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: also= found, looking for other section..."),debug); QString newdata = QString(section->SectionData.join("\n")); newdata.replace(QRegExp("^.*also=.*$"),""); section->SectionData= newdata; QString OtherSection=dataline.simplifyWhiteSpace().section('#',0,0).section("=",1,1); // we have to find the other section and replace this line by the config data of the other section (after the =) bool section_found=false; for (IpsecImportSection * it3 = IpsecImportSectionList->first(); it3; it3 = IpsecImportSectionList->next() ) { if (it3->SectionName == OtherSection) { // std::cout << "section " << OtherSection << " found, appending:" << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: section %1 found, appending:").arg(OtherSection),debug); // std::cout << "other data:" << std::endl << it3->SectionData.join("\n") << "--------" << std::endl; // std::cout << "section data:" << std::endl << section->SectionData.join("\n") << "--------" << std::endl; section_found=true; // data.remove(dataline); dataline=""; // QStringList otherdata = QStringList::split("\n",QString(it3->SectionData.join("\n"))); QString OtherData = QString(it3->SectionData.join("\n")); QStringList newdata; for ( QStringList::Iterator it6 = data.begin(); it6 != data.end(); ++it6 ) { // std::cout << " also line: " << *it6 << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: also line: ") + QString(*it6),debug); if (QString(*it6).find("also=") < 0) { // std::cout << " also= found." << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: also= found."),debug); newdata.append(QString(*it6)); } else { // std::cout << " also= not found." << std::cout; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: also= not found.") ,debug); } } // newdata.append(data.join("\n")); newdata.append(OtherData); section->SectionData= newdata; } } if (!section_found) { // std::cout << "section " << OtherSection << " not found, skipping" << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: section %1 not found, skipping").arg(OtherSection) ,debug); } } } if (defaultSectionFound==true) { if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: => default section is set... "),debug); for ( int i=0; i< (int)IpsecImportSectionList->count();i++ ) { IpsecImportSection *section2 = IpsecImportSectionList->at(i); QString Name= section2->SectionName; if (Name == "%default") { if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: => appending %default section: ")+"\"" + section2->SectionData.join("\n") ,debug); QStringList defaultdata = QStringList::split('\n',section2->SectionData.join("\n")); for ( QStringList::Iterator defaultit = defaultdata.begin(); defaultit != defaultdata.end(); ++defaultit ) { if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: => appending %default line: ")+"\"" + *defaultit,debug); section->SectionData.append(*defaultit); } break; } } } } } } // std::cout << "modified config" << std::endl << "---------------------" << std::endl; // IpsecImportSection *it5=NULL; // for ( it5 = IpsecImportSectionList->first(); it5; it5 = IpsecImportSectionList->next() ) // { // QString SectionName= it5->SectionName; // QStringList data = it5->SectionData; // // std::cout << SectionName << std::endl; // std::cout << data.join("\n") << std::endl; // } // remove default section for ( int i=0; i< (int)IpsecImportSectionList->count();i++ ) { IpsecImportSection *section = IpsecImportSectionList->at(i); QString Name= section->SectionName; if (Name == "%default") { IpsecImportSectionList->remove(IpsecImportSectionList->at(i)); break; } } if (KvpncDebugLevel > 2) { appendLogEntry(i18n ("modified config") ,debug); appendLogEntry( "---------------------" ,debug); IpsecImportSection *it5=NULL; for ( it5 = IpsecImportSectionList->first(); it5; it5 = IpsecImportSectionList->next() ) { QString SectionName= it5->SectionName; QStringList data = it5->SectionData; appendLogEntry(SectionName ,debug); appendLogEntry(data.join("\n") ,debug); } } // std::cout << "pass3: parse sections" << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: pass3: parse sections") ,debug); if (!IpsecImportSectionList->isEmpty()) { for ( int i=0; i< (int)IpsecImportSectionList->count();i++ ) { IpsecImportSection *section = IpsecImportSectionList->at(i); QStringList sectiondata = QStringList::split('\n',section->SectionData.join("\n")); // std::cout << " => processing section: \"" << section->SectionName << "\"" << std::endl; // std::cout << " => data: \"" << section->SectionData.join("\n") << "\"" << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: => processing section: ")+"\"" + section->SectionName + "\"" ,debug); VpnAccountData *profiledata = new VpnAccountData(VpnAccountData::freeswan,QString(section->SectionName)) ; for ( QStringList::Iterator it2 = sectiondata.begin(); it2!= sectiondata.end() ; it2++ ) { QString dataline = *it2; QString line2 = removeWhiteSpaceAtBegin ( dataline ); // line of text excluding '\n' and replace all white chars with one blank // std::cout << "dataline: \"" << line2 << "\""; if ( line2.startsWith ( "rightsubnet=" ) ) { validLineFound=true; QString RightSubnet=line2.section ( "rightsubnet=",1,-1 ); // std::cout << "right subnet (remote) found: " << RightSubnet << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: right subnet (remote) found: " ) + RightSubnet ,debug ); profiledata->setRemoteNetAddr ( RightSubnet.section ( '/',0,0 ) ); profiledata->setRemoteNetMask ( RightSubnet.section ( '/',1,1 ) ); profiledata->setUseRemoteNetwork ( true ); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "leftsubnet=" ) ) { validLineFound=true; QString LeftSubnet=line2.section ( "leftsubnet=",1,-1 ); // std::cout << "left subnet (local) found: " << LeftSubnet << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: left subnet (local) found: " ) + LeftSubnet ,debug ); // local subnet cant be set yet. // profiledata->setLocalNetAddr(RightSubnet.section('/',0,0)); // profiledata->setLocalNetMask(RightSubnet.section('/',1,1)); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; } if ( line2.startsWith ( "rightnexthop=" ) ) { validLineFound=true; QString RightNextHop=line2.section ( "rightnexthop=",1,-1 ); // std::cout << "right next hop (remote) found: " << RightNextHop << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: right next hop (remote) found: " ) +RightNextHop ,debug ); profiledata->setRightNextHop ( RightNextHop ); profiledata->setUseRightNextHop(true); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "leftnexthop=" ) ) { validLineFound=true; QString LeftNextHop=line2.section ( "leftnexthop=",1,-1 ); std::cout << "left next hop (local) found: " << LeftNextHop << std::endl; if (KvpncDebugLevel > 2) appendLogEntry("import ipsec config: left next hop (local) found: " +LeftNextHop ,debug); profiledata->setLeftNextHop(LeftNextHop); profiledata->setUseLeftNextHop(true); std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; if (KvpncDebugLevel > 2) appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "left=" ) ) { validLineFound=true; QString left=line2.section ( "left=",1,-1 ); // local ip cant be set yet. // std::cout << "left found: " << left << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: left found: " + left ,debug); // profiledata->setLocal (left); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "right=" ) ) { validLineFound=true; QString right=line2.section ( "right=",1,-1 ); // std::cout << "right (remote gateway) found: " << right << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: right (remote gateway) found: " ) + right ,debug ); profiledata->setGateway ( right ); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "leftcert=" ) ) { validLineFound=true; QString LeftCert=line2.section ( "leftcert=",1,-1 ); // std::cout << "left cert (local) found: " << LeftCert << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: left cert (local) found: " ) + LeftCert ,debug ); profiledata->setX509Certificate ( LeftCert ); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "rightcert=" ) ) { validLineFound=true; QString RightCert=line2.section("rightcert=",1,-1); // std::cout << "right cert (remote) found: " << RightCert << std::endl; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import ipsec config: right cert (remote) found: ") + RightCert ,debug); profiledata->setUseSpecialServerCertificate(true); profiledata->setSpecialServerCertificate(RightCert); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "rightca=" ) ) { validLineFound=true; QString RightCA=line2.section ( "rightca=",1,-1 ); // std::cout << "right CA (remote) found: " << RightCA << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: right CA (remote) found: " ) +RightCA ,debug ); profiledata->setCaCertificate ( RightCA ); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "rightid=" ) ) { validLineFound=true; QString RightID=line2.section ( "rightid=",1,-1 ); // std::cout << "right ID (remote) found: " << RightID << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: right ID (remote) found: " ) + RightID ,debug ); profiledata->setUseSpecialRemoteID ( true ); profiledata->setSpecialRemoteID ( RightID ); profiledata->setRemoteIDType("keyid"); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "leftid=" ) ) { validLineFound=true; QString LeftID=line2.section ( "leftid=",1,-1 ); // std::cout << "local ID (local) found: " << LeftID << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: local ID (local) found: " ) + LeftID ,debug ); profiledata->setUseSpecialLocalID ( true ); profiledata->setSpecialLocalID ( LeftID ); profiledata->setLocalIDType("keyid"); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "rightrsasigkey=" ) ) { validLineFound=true; QString RightRsaSigKey=line2.section ( "rightrsasigkey=",1,-1 ); // std::cout << "right uses (remote) " << RightRsaSigKey << std::endl; if (RightRsaSigKey=="%cert") { if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: right (remote) uses cert" ),debug ); profiledata->setAuthType ( VpnAccountData::cert ); } else { if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: right (remote) uses " ) + RightRsaSigKey ,debug ); profiledata->setAuthType ( VpnAccountData::psk ); // ok, we use special server cert here because at psk its unused profiledata->setSpecialServerCertificate( RightRsaSigKey ); profiledata->setUseSpecialServerCertificate(true); } // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "leftrsasigkey=" ) ) { validLineFound=true; QString LeftRsaSigKey=line2.section ( "leftrsasigkey=",1,-1 ); // std::cout << "right uses (remote) " << LeftRsaSigKey << std::endl; if (LeftRsaSigKey=="%cert") { if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: left (local) uses cert" ),debug ); profiledata->setAuthType ( VpnAccountData::cert ); } else { if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: left (local) uses " ) + LeftRsaSigKey ,debug ); profiledata->setAuthType ( VpnAccountData::psk ); profiledata->setPreSharedKeyFile( LeftRsaSigKey ); profiledata->setPskIsInFile( true ); } // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "authby=" ) ) { validLineFound=true; QString Authby=line2.simplifyWhiteSpace().section ( "authby=",1,1 ); // std::cout << "left and right use certs " << std::endl; if ( Authby.find ( "rsasig", 0 , FALSE ) > -1 ) { if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: left and right use certs." ) ,debug ); profiledata->setAuthType ( VpnAccountData::cert ); profiledata->setCertPath ( "/etc/ipsec.d/certs" ); //profiledata->setPskIsInFile ( true ); //profiledata->setPrivateKey ( "/etc/ipsec.secrets" ); } else if ( Authby.find ( "secret", 0 , FALSE ) > -1 ) { if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: left and right use psk." ) ,debug ); profiledata->setAuthType ( VpnAccountData::psk ); //profiledata->setPskIsInFile ( true ); //profiledata->setPreSharedKeyFile ( "/etc/ipsec.secrets" ); } else { if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: left and right use unknown auth, guess psk" ) ,debug ); profiledata->setAuthType ( VpnAccountData::psk ); } // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "auto=start" ) ) { // validLineFound=true; // QString Authby=line2.simplifyWhiteSpace().section('#',0,0).section("=",1,1); // std::cout << "profile should be started" << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: profile should be started" ,debug); // profiledata->setAuthType(VpnAccountData::cert); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "leftsourceip=" ) ) { validLineFound=true; QString leftsourceip=line2.section ( "leftsourceip=",1,-1 ); std::cout << "left (local) have to use IP address " << leftsourceip << std::endl; if (KvpncDebugLevel > 2) appendLogEntry("import ipsec config: left (local) have to use IP address " + leftsourceip ,debug); profiledata->setLocalVirtualIP(leftsourceip); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; if (KvpncDebugLevel > 2) appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "virtual_private=" ) ) { validLineFound=true; QString virtualprivate=line2.section ( "virtual_private=",1,-1 ); std::cout << "virtual private networks " << virtualprivate << std::endl; if (KvpncDebugLevel > 2) appendLogEntry("import ipsec config: virtual private networks " +virtualprivate ,debug); profiledata->setLocalVirtualIP(virtualprivate); profiledata->setUseVirtualIP(true); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; if (KvpncDebugLevel > 2) appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "rightsourceip=" ) ) { validLineFound=true; QString rightsourceip=line2.section ( "rightsourceip=",1,-1 ); std::cout << "right (remote) have to use IP address " << rightsourceip << std::endl; if (KvpncDebugLevel > 2) appendLogEntry("import ipsec config: right (remote) have to use IP address " + rightsourceip ,debug); profiledata->setRightSourceIp(rightsourceip); profiledata->setUseRightSourceIp(true); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; if (KvpncDebugLevel > 2) appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "esp=" ) ) { validLineFound=true; QString IpsecEsp=line2.section ( "esp=",1,-1 ); // std::cout << "esp settings found: " << IpsecEsp << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: esp settings found: " ) + IpsecEsp ,debug ); profiledata->setIpsecEsp ( IpsecEsp ); profiledata->setUseCustomEsp(true); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "ike=" ) ) { validLineFound=true; QString IpsecIke=line2.section ( "ike=",1,-1 ); // std::cout << "ike settings found: " << IpsecIke << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: ike settings found: " ) + IpsecIke ,debug ); profiledata->setIpsecIke ( IpsecIke ); profiledata->setUseCustomIke(true); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "type=" ) ) { validLineFound=true; QString IpsecVpnMode=line2.section ( "type=",1,1 ); // std::cout << "IpsecType found: " << IpsecType << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: IPsec vpn mode found: " ) + IpsecVpnMode ,debug ); if ( IpsecVpnMode == "tunnel" ) profiledata->setIpsecVpnMode ( "tunnel" ); else profiledata->setIpsecVpnMode ( "transport" ); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "leftxauthclient=" ) ) { validLineFound=true; QString useXauth=line2.section ( "leftxauthclient=",1,1 ); if (useXauth=="yes") { //std::cout << "Use XAUTH: " << i18n("yes") << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "Use XAUTH (leftxauthclient found):" )+" " + i18n("yes") ,debug ); profiledata->setAuthWithUsernameAndPassword( true ); } else { //std::cout << "Use XAUTH: " << i18n("no") << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "Use XAUTH (leftxauthclient found):" )+" " + i18n("no") ,debug ); profiledata->setAuthWithUsernameAndPassword( false ); } // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "rightxauthserver=" ) ) { validLineFound=true; QString useXauth=line2.section ( "rightxauthserver=",1,-1 ); if (useXauth == "yes") { //std::cout << "Use XAUTH: " << i18n("yes") << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "Use XAUTH (rightxauthserver found):" )+" " + i18n("yes") ,debug ); profiledata->setAuthWithUsernameAndPassword( true ); } else { //std::cout << "Use XAUTH: " << i18n("no") << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "Use XAUTH (rightxauthserver found):" )+" " + i18n("no") ,debug ); profiledata->setAuthWithUsernameAndPassword( false ); } // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "keyingtries=" ) ) { validLineFound=true; int MaxConnectTries=QString(line2.section ( "keyingtries=",1,1 )).toInt(); // std::cout << "keyingtries found: " << MaxConnectTries << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: keyingtries found: " ) + QString().setNum(MaxConnectTries) ,debug ); profiledata->setMaxConnectTries ( MaxConnectTries ); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "pfs=" ) ) { validLineFound=true; QString UsePerfectForwardSecrety=line2.section ( "pfs=",1,1 ).remove ( '"' ); if (UsePerfectForwardSecrety =="yes") { //std::cout << "Use PFS: " << i18n("yes") << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "Use PFS:" )+" " + i18n("yes") ,debug ); profiledata->setUsePerfectForwardSecrety( true ); } else { //std::cout << "Use PFS: " << i18n("no") << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "Use PFS:" )+" " + i18n("no") ,debug ); profiledata->setUsePerfectForwardSecrety( false ); } // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "pfsgroup=" ) ) { validLineFound=true; QString PerfectForwardSecrety=line2.section ( "pfsgroup=",1,1 ); // std::cout << "keyingtries found: " << MaxConnectTries << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: PFS group found: " ) + PerfectForwardSecrety ,debug ); profiledata->setPerfectForwardSecrety ( PerfectForwardSecrety ); // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } if ( line2.startsWith ( "aggrmode=" ) ) { validLineFound=true; QString UseAgressiveMode=line2.section ( "aggrmode=",1,1 ).remove ( '"' ); if (UseAgressiveMode == "yes") { //std::cout << "Exchange mode: " << i18n("aggressive") << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "Exchange mode:" )+" " + "aggressive" ,debug ); profiledata->setExchangeMode( "aggressive" ); } else { //std::cout << "Exchange mode: " << i18n("main") << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "Exchange mode:" )+" " + "main" ,debug ); profiledata->setExchangeMode( "main" ); } // std::cout << " => set it for profile " << IpsecConfigSection << " ." << std::endl; // if (KvpncDebugLevel > 2) // appendLogEntry("import ipsec config: => set it for profile " + IpsecConfigSection + " ." ,debug); } else { // std::cout << "comment found." << std::endl; } } if ( useNat ) { profiledata->setUseNat ( true ); // std::cout << "nat_traversal=yes found, enabling nat." << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: nat_traversal=yes found, enabling nat." ) ,debug ); } else { profiledata->setUseNat ( false ); // std::cout << "nat_traversal=no found, disabling nat." << std::endl; if ( KvpncDebugLevel > 2 ) appendLogEntry ( i18n ( "import ipsec config: nat_traversal=no found, disabling nat." ) ,debug ); } if ( disableOpportunisticEncryption== true ) { profiledata->setDisableOpportunisticEncryption ( true ); } else { profiledata->setDisableOpportunisticEncryption ( false ); } // FIXME we only use the first in list QString Interface = InterfaceList.first(); profiledata->setNetworkDevice(Interface); profiledata->setName("kvpnc_import_"+profiledata->getName()); profiledata->setDescription(QString(i18n("import from ")+filename)); ImportedAccountList->append(profiledata); } } KvpncImportProfileSelectionBase selectdlg; selectdlg.ImportGlobalSettingsCheckBox->hide(); VpnAccountData *it=NULL; int importCount=0; if ( !ImportedAccountList->isEmpty() ) { selectdlg.ImportProfileListView->takeItem(selectdlg.ImportProfileListView->currentItem()); selectdlg.ImportProfileListView->addColumn(i18n("Name")); selectdlg.ImportProfileListView->addColumn(i18n("Type")); selectdlg.ImportProfileListView->addColumn(i18n("Gateway")); selectdlg.ImportProfileListView->addColumn(i18n("Authentication")); selectdlg.ImportProfileListView->addColumn(i18n("Remote network")); QCheckListItem *item; for ( it = ImportedAccountList->first(); it; it = ImportedAccountList->next() ) { QString name = it->getName(); QString type=""; if ( it->getConnectionType() == VpnAccountData::cisco ) type = "cisco" ; else if ( it->getConnectionType() == VpnAccountData::ciscoorig ) type = "ciscoorig" ; else if ( it->getConnectionType() == VpnAccountData::racoon ) type = "racoon" ; else if ( it->getConnectionType() == VpnAccountData::l2tpd_racoon ) type = "l2tpd (racoon)" ; else if ( it->getConnectionType() == VpnAccountData::freeswan ) type = "ipsec" ; else if ( it->getConnectionType() == VpnAccountData::l2tpd_freeswan ) type = "l2tpd (ipsec)" ; else if ( it->getConnectionType() == VpnAccountData::pptp ) type = "pptp" ; else if ( it->getConnectionType() == VpnAccountData::openvpn ) type = "openvpn" ; else type = i18n("other"); // litem->setSelectable(true); item = new QCheckListItem(selectdlg.ImportProfileListView,it->getName(),QCheckListItem::CheckBox); item->setText(1,type); item->setText(2,it->getGateway()); if (it->getAuthType() == VpnAccountData::cert) item->setText(3,i18n("certificate")); else if (it->getAuthType() == VpnAccountData::psk) item->setText(3,i18n("preshared key")); else if (it->getAuthType() == VpnAccountData::hybrid) item->setText(3,i18n("hybrid")); else item->setText(3,i18n("unknown")); selectdlg.ImportProfileListView->insertItem(item); QString RemoteNetDiv="/"; if (it->getRemoteNetAddr() == "") { it->setRemoteNetMask(""); RemoteNetDiv=""; } item->setText(4,QString(it->getRemoteNetAddr()+RemoteNetDiv+it->getRemoteNetMask())); // std::cout << "insert profile into listview: " << name << std::endl; } } bool ret = selectdlg.exec(); if (ret == true) { QListViewItemIterator it2( selectdlg.ImportProfileListView ); for ( ; it2.current(); ++it2 ) { if ( ( (QCheckListItem*)it2.current() )->isOn() ) { VpnAccountData *data=NULL; it = 0; for ( it = ImportedAccountList->first(); it; it = ImportedAccountList->next() ) { if ( it->getName() == ( (QCheckListItem*)it2.current() )->text() && ( (QCheckListItem*)it2.current() )->isOn() ) { data = it; importCount++; RetName=it->getName(); break; } } AccountList->append(data); saveOptions(true, data->getName()); } } if (selectdlg.OpenProfileManagerCheckBox->isChecked() && !ImportedAccountList->isEmpty()) openProfileManager=true; } else { KMessageBox::sorry ( 0, i18n ( "Import canceled." ) ); return false; } QString msg=""; if (importCount > 0 ) msg = i18n("Import was successful. %1 profiles are imported.").arg(QString::number(importCount)); else msg = i18n("Import was canceled because no profiles are selected.").arg(QString::number(importCount)); KMessageBox::information ( 0, msg,i18n("Import success") ); } else { KMessageBox::error ( 0, i18n ( "Reading of \"%1\" has been failed!" ).arg ( filename ) ); return false; } return true; } bool KVpncConfig::importFritzboxConfig(QString filename, QString& RetName, bool& openProfileManager) { /* // example of vpn config fritzbox user version = { revision = "$Revision: 1.30 $"; creatversion = "1.1"; } pwcheck = { } datapipecfg = { security = dpsec_quiet; icmp = { ignore_echo_requests = no; destunreach_rate = { burstfactor = 6; timeout = 1; } timeexceeded_rate = { burstfactor = 6; timeout = 1; } echoreply_rate = { burstfactor = 6; timeout = 1; } } masqtimeouts = { tcp = 15m; tcp_fin = 2m; tcp_rst = 3s; udp = 5m; icmp = 30s; got_icmp_error = 15s; any = 5m; tcp_connect = 6m; tcp_listen = 2m; } ipfwlow = { input = { } output = { } } ipfwhigh = { input = { } output = { } } NAT_T_keepalive_interval = 20; } targets = { policies = { name = "My Fritzbox"; connect_on_channelup = no; always_renew = no; reject_not_encrypted = no; dont_filter_netbios = yes; localip = 0.0.0.0; virtualip = 192.168.178.201; remoteip = 0.0.0.0; remotehostname = "dnyn.myfb.com"; localid = { user_fqdn = "user@domain.com"; } mode = mode_aggressive; phase1ss = "all/all/all"; keytype = keytype_pre_shared; key = "geheim"; cert_do_server_auth = no; use_nat_t = yes; use_xauth = no; use_cfgmode = no; phase2localid = { ipaddr = 192.168.178.201; } phase2remoteid = { ipnet = { ipaddr = 192.168.178.0; mask = 255.255.255.0; } } phase2ss = "esp-all-all/ah-none/comp-all/pfs"; accesslist = "permit ip any 192.168.178.0 255.255.255.0"; wakeupremote = no; } } policybindings = { } */ QFile importfile (filename); if (!importfile.exists()) { KMessageBox::error ( 0, i18n ( "Reading of \"%1\" has been failed!" ).arg ( filename ) ); return false; } if ( importfile.open(IO_ReadOnly)) { QString line = NULL; VpnAccountData *profiledata = new VpnAccountData(VpnAccountData::freeswan,"fritzbox") ; QTextStream stream(&importfile); bool datapipecfgFound = false; bool policiesFound = false; bool targetsFound = false; bool localidFound = false; bool phase2localidFound = false; bool phase2remoteidFound = false; bool ipnetFound = false; bool nameFound = false; profiledata->setDescription(QString(i18n("import from ")+filename)); profiledata->setConnectionType( VpnAccountData::racoon); profiledata->setUsePerfectForwardSecrety(true); profiledata->setPerfectForwardSecrety("modp1024"); profiledata->setUseIkeGroup(true); profiledata->setIkeGroup("modp1024"); profiledata->setIpsecIke("aes"); profiledata->setHashAlgo( "sha1"); profiledata->setUseAuthenticationAlgorithm(true); profiledata->setEncryptionAlgorithm( "aes"); profiledata->setAuthenticationAlgorithm( "hmac_sha1" ); profiledata->setLocalIDType("user_fqdn"); profiledata->setReplaceDefaultRoute(false); profiledata->setNetworkDevice("default"); profiledata->setUseDnsUpdate(false); while ( !stream.atEnd() ) { line = removeWhiteSpaceAtBegin(stream.readLine()).simplifyWhiteSpace(); if (KvpncDebugLevel > 6) appendLogEntry(i18n ("import fritzbox config: line: %1").arg(line), debug); if (line.startsWith("datapipecfg")) { datapipecfgFound = true; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found").arg("datapipecfg"), debug); } if (line.startsWith("policies")) { policiesFound = true; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found").arg("policies"), debug); } if (line.startsWith("targets")) { targetsFound = true; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found").arg("targets"), debug); } if (line.startsWith("localid")) { localidFound = true; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found").arg("localid"), debug); } if (line.startsWith("phase2localid")) { phase2localidFound = true; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found").arg("phase2localid"), debug); } if (line.startsWith("phase2remoteid")) { phase2remoteidFound = true; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found").arg("phase2remoteid"), debug); } if (line.startsWith("ipnet")) { ipnetFound = true; if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: ipnetFound found"), debug); } if ( datapipecfgFound ) { // here we can read masq timeouts, and so on. } if (targetsFound && policiesFound ) { if (line.startsWith("name = ")) { QString ProfileName=line.section("= ",1,1).replace("\"","").replace(";","").replace(" ","_"); if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("name").arg(ProfileName) ,debug); profiledata->setName(ProfileName); nameFound = true; } if (line.startsWith(" always_renew = ")) { bool reconnectAfterConnectionLost=false; if (line.section("= ",1,1).replace(";","") == "yes") reconnectAfterConnectionLost = true; if (KvpncDebugLevel > 2) if (reconnectAfterConnectionLost) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("always_renew").arg(i18n("yes")) ,debug); else appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("always_renew").arg(i18n("no")) ,debug); profiledata->setDoReconnectAfterConnectionLost(reconnectAfterConnectionLost); } if (line.startsWith("dont_filter_netbios = ")) { bool dont_filter_netbios=false; if (line.section("= ",1,1).replace(";","") == "yes") dont_filter_netbios = true; if (KvpncDebugLevel > 2) if (dont_filter_netbios) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("dont_filter_netbios").arg(i18n("yes")) ,debug); else appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("dont_filter_netbios").arg(i18n("no")) ,debug); // nothing to yet } if (line.startsWith("localip = ")) { QString LocalIp=line.section("= ",1,1).replace("\"","").replace(";",""); if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("localip").arg(LocalIp) ,debug); // nothing to do yet } if (line.startsWith("virtualip = ")) { QString LocalVirtualIp=line.section("= ",1,1).replace("\"","").replace(";",""); if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("virtualip").arg(LocalVirtualIp) ,debug); profiledata->setUseLeftSourceIp(true); profiledata->setLeftSourceIp(LocalVirtualIp); } if (line.startsWith("remoteip = ")) { QString RemoteIp=line.section("= ",1,1).replace("\"","").replace(";",""); if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("remoteip").arg(RemoteIp) ,debug); // nothing to do yet } if (line.startsWith("remotehostname = ")) { QString Gateway=line.section("= ",1,1).replace("\"","").replace(";",""); if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("remotehostname").arg(Gateway) ,debug); profiledata->setGateway(Gateway); } if (localidFound) { if (line.startsWith("user_fqdn = ")) { QString LocalId=line.section("= ",1,1).replace("\"","").replace(";",""); if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg(QString("user_fqdn")+" ("+i18n("local id")+")").arg(LocalId) ,debug); profiledata->setSpecialLocalID(LocalId); profiledata->setUseSpecialLocalID(true); profiledata->setLocalIDType("user_fqdn"); localidFound = false; } } if (line.startsWith("mode = ")) { QString IpsecExchangeMode=line.section("= ",1,1).replace(";",""); if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg(i18n("exchange mode")).arg(IpsecExchangeMode) ,debug); if (IpsecExchangeMode == "mode_aggressive") profiledata->setExchangeMode("aggressive"); else profiledata->setExchangeMode("main"); } if (line.startsWith("keytype = ")) { QString AuthType=line.section("= ",1,1).replace(";",""); if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("keytype").arg(AuthType) ,debug); if (AuthType == "keytype_pre_shared") profiledata->setAuthType(VpnAccountData::psk); else profiledata->setAuthType(VpnAccountData::cert); } if (line.startsWith("key = ")) { QString PreshardKey=line.section("= ",1,1).replace("\"","").replace(";",""); if (KvpncDebugLevel > 2 && KvpncDebugLevel < 5) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("key").arg("******") ,debug); if (KvpncDebugLevel > 5) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("key").arg(PreshardKey) ,debug); profiledata->setPreSharedKey(PreshardKey); profiledata->setPskIsInFile(false); } if (line.startsWith("cert_do_server_auth = ")) { bool cert_do_server_auth=false; if (line.section("= ",1,1).replace(";","") == "yes") cert_do_server_auth = true; if (KvpncDebugLevel > 2) if (cert_do_server_auth) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("cert_do_server_auth").arg(i18n("yes")) ,debug); else appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("cert_do_server_auth").arg(i18n("no")) ,debug); // nothing to to yet } if (line.startsWith("use_nat_t = ")) { bool UseNat=false; if (line.section("= ",1,1).replace(";","") == "yes") UseNat = true; if (KvpncDebugLevel > 2) if (UseNat) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("use_nat_t").arg(i18n("yes")) ,debug); else appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("use_nat_t").arg(i18n("no")) ,debug); profiledata->setUseNat(UseNat); profiledata->setUseUdp(true); } if (line.startsWith("use_xauth = ")) { bool UseXauth=false; if (line.section("= ",1,1).replace(";","") == "yes") UseXauth = true; if (KvpncDebugLevel > 2) if (UseXauth) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("use_xauth").arg(i18n("yes")) ,debug); else appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("use_xauth").arg(i18n("no")) ,debug); profiledata->setAuthWithUsernameAndPassword(UseXauth); } if (line.startsWith("use_cfgmode = ")) { bool ModeConfig=false; if (line.section("= ",1,1).replace(";","") == "yes") ModeConfig = true; if (KvpncDebugLevel > 2) if (ModeConfig) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("use_cfgmode").arg(i18n("yes")) ,debug); else appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg("use_cfgmode").arg(i18n("no")) ,debug); profiledata->setUseModeConfig(ModeConfig); } if (phase2localidFound) { if (line.startsWith("ipaddr = ")) { QString Phase2LocalId=line.section("= ",1,1).replace("\"","").replace(";",""); if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg(i18n("ip addr for phase 2")).arg(Phase2LocalId) ,debug); // nothing to do yet } } if (phase2remoteidFound && ipnetFound) { profiledata->setUseRemoteNetwork(true); if (line.startsWith("ipaddr = ")) { QString RemoteNetWorkAddr=line.section("= ",1,1).replace(";",""); if (KvpncDebugLevel > 2) appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg(i18n("remote network ip")).arg(RemoteNetWorkAddr) ,debug); profiledata->setRemoteNetAddr(RemoteNetWorkAddr); } if (line.startsWith("mask = ")) { QString RemoteNetWorkMask=line.section("= ",1,1).replace(";",""); QString RemoteNetWorkMaskNumeric = QString().setNum(Utils(this).dottedIpv4Netmask2NetmaskBytes(RemoteNetWorkMask)); if (KvpncDebugLevel > 2) { appendLogEntry(i18n ("import fritzbox config: %1 found: %2").arg(i18n("remote network netmask")).arg(RemoteNetWorkMask) ,debug); appendLogEntry(i18n("Netmask (dotted): %1, numeric value: %2").arg(RemoteNetWorkMask).arg(RemoteNetWorkMaskNumeric), debug); } profiledata->setRemoteNetMask(RemoteNetWorkMaskNumeric); } } } } if (policiesFound && nameFound) { bool ok = false; VpnAccountData * it; bool nameOk = false; while ( nameOk == false ) { for ( it = AccountList->first(); it; it = AccountList->next() ) { if ( it->getName() == profiledata->getName() ) { //account->setName( QString( account->getName() + "_2" ) ); // KMessageBox::information ( this, i18n( "Profile name exists!\n It will be renamed to \"%1\"." ).arg( account->getName() ), i18n( "Name exist, renamed" ) ); KMessageBox::error ( 0, i18n ( "Profile name exists!" ), i18n ( "Name Exists" ) ); nameOk = false; QString newName = KInputDialog::getText ( i18n ( "New Name" ), i18n ( "New name for profile:" ), QString ( profiledata->getName() + "_2" ), &ok ); if (newName.isEmpty()) { KMessageBox::information ( 0, i18n ( "Import was canceled." ) ); appendLogEntry ( i18n ( "Import was canceled." ), info ); return false; } if (newName != it->getName() ) { profiledata->setName ( newName ); nameOk = true; } } else { nameOk = true; } } } if ( nameOk == true ) { AccountList->append(profiledata); RetName = profiledata->getName(); saveOptions(true, RetName); appendLogEntry ( i18n ( "Import of \"%1\" (%2) was successful." ).arg ( profiledata->getName() ).arg ( "Fritzbox" ), info ); QString bin = "racoon"; ToolInfo *tool; //std::cout << "Tool (bin): " << bin << std::endl; if ( !ToolList->isEmpty() ) { for ( tool = ToolList->first(); tool; tool = ToolList->next() ) { if ( bin == tool->Name ) { if ( tool->PathToExec.section ( '/', -1 ) != bin ) { // program is NOT installed KMessageBox::information ( 0, i18n ( "The required tool (%1) is not installed, please install it before you are connecting and restart kvpnc." ).arg ( bin ), i18n ( "Tool Missing" ) ); } break; } } } } else { KMessageBox::information ( 0, i18n ( "Import was canceled." ) ); appendLogEntry ( i18n ( "Import was canceled." ), info ); return false; } } QString msg=""; if (policiesFound && nameFound) msg = i18n("Import was successful. 1 profile was imported."); else msg = i18n("Import was canceled because no profile was found."); KMessageBox::information ( 0, msg,i18n("Import success") ); return policiesFound && nameFound; } else { KMessageBox::error ( 0, i18n ( "Reading of \"%1\" has been failed!" ).arg ( filename ) ); return false; } return true; } VpnAccountData* KVpncConfig::findProfile(QPtrList *list,const QString& Name) { VpnAccountData *it=NULL; bool found=false; if ( !list->isEmpty() ) { for ( it = list->first(); it; it = list->next() ) { // std::cout << "findProfile(): it: " << it->getName() << " Name: " << Name << std::endl; if (Name == it->getName()) { found=true; // std::cout << "findProfile(): profile found." << std::endl; break; } } } if (found) return it; else { // std::cout << "findProfile(): profile not found." << std::endl; return NULL; } } QString KVpncConfig::removeWhiteSpaceAtBegin(const QString str) { QString newstr=""; int i=0; for (i=0;i<(int)str.length();i++) { if (!QChar(str.at(i)).isSpace()) break; } newstr = str.right(str.length()-i); return newstr; } void KVpncConfig::doBackupConfig() { KStandardDirs * dirs = KGlobal::dirs(); QString config = QString(dirs->saveLocation( "config" )+"/kvpncrc"); QFile OriginalConfFile( config ); QFile backupOriginalConfFile( config+".backup" ); QTextStream writestream( &backupOriginalConfFile ); QTextStream readstream( &OriginalConfFile ); if ( OriginalConfFile.open( IO_ReadOnly ) ) { if (backupOriginalConfFile.open(IO_WriteOnly)) { QString OriginalConfFileContent = QString( OriginalConfFile.readAll() ) ; writestream << OriginalConfFileContent; OriginalConfFile.close(); backupOriginalConfFile.close(); } } } void KVpncConfig::restoreBackupConfig() { KStandardDirs * dirs = KGlobal::dirs(); QString config = QString(dirs->saveLocation( "config" )+"/kvpncrc"); QFile OriginalConfFile( config+".backup" ); QFile backupOriginalConfFile( config ); QTextStream writestream( &backupOriginalConfFile ); QTextStream readstream( &OriginalConfFile ); if ( OriginalConfFile.open( IO_ReadOnly ) ) { if (backupOriginalConfFile.open(IO_WriteOnly)) { QString OriginalConfFileContent = QString( OriginalConfFile.readAll() ) ; writestream << OriginalConfFileContent; OriginalConfFile.close(); backupOriginalConfFile.close(); } } } void KVpncConfig::getToolsInfo() { ToolInfo *it; //std::cout << "Tool (bin): " << bin << std::endl; if (!ToolList->isEmpty()) { for ( it = ToolList->first(); it; it = ToolList->next() ) { it->collectToolInfo(); } } } void KVpncConfig::removeEntry(QString Name) { KStandardDirs * dirs = KGlobal::dirs(); QString filePath = dirs->findResource ( "config", "kvpncrc" ); appPointer->processEvents(); if (useKwallet && KWallet::Wallet::isEnabled()) config->deleteEntry( "First use of Kwallet", false ); /* = user data = */ VpnAccountData *it; if ( !AccountList->isEmpty() ) { for ( it = AccountList->first(); it; it = AccountList->next() ) { if ( !it->getName().isEmpty() ) { QString name = it->getName(); if (it->getName() == Name) { //std::cout << "Remove profile: " << it->getName() << std::endl; QString ProfileName = "Profile_"; ProfileName += name; config->setGroup( ProfileName ); /* passwords with kwallet */ if ( useKwallet && KWallet::Wallet::isEnabled()) { // if (KvpncDebugLevel > 0) // appendLogEntry(i18n( "Wallet enabled and available, writing to wallet." ),debug); // // Open local wallet wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet()); if (wallet != 0) { QString walletname="kvpnc"; // Check if folder exists, otherwise create it bool walletOK=true; if (!wallet->hasFolder(walletname)) { walletOK = wallet->createFolder(walletname); wallet->sync(); } if (walletOK) { wallet->setFolder(walletname); //std::cout << "[set] account: " << ProfileName << ", loginname: " << loginname << ", password: " << pwd << std::endl; bool UserPasswordOK = (wallet->removeEntry (QString(name+"__user_pw")) == 0); bool PskOK= (wallet->removeEntry (QString(name+"__psk")) == 0); bool PskKeyPassOK = (wallet->removeEntry (QString(name+"__priv_key_pwd")) == 0); // wallet->sync(); if (KvpncDebugLevel > 2) { if (UserPasswordOK) appendLogEntry(i18n( "delete of %1 was ok." ).arg(i18n("user password")), debug); else appendLogEntry(i18n( "delete of %1 has failed." ).arg(i18n("user password")), debug); // if (PskOK) appendLogEntry(i18n( "delete of %1 was successful." ).arg(i18n("preshared key")), debug); else appendLogEntry(i18n( "delete of %1 has failed." ).arg(i18n("preshared key")),debug); if (PskKeyPassOK) appendLogEntry(i18n( "delete of %1 was successful." ).arg(i18n("private key password")), debug); else appendLogEntry(i18n( "delete of %1 has failed." ).arg(i18n("private key password")),debug); // //std::cout << "success: " << pwdOK << std::endl; } } else { KMessageBox::error( 0, i18n( "Unable to create wallet folder for kvpnc!" ) ); appendLogEntry(i18n( "Unable to create wallet folder for kvpnc!" ), error); } } } if (KvpncDebugLevel > 0) appendLogEntry(i18n( "Wallet disabled or not available, writing to config file." ),debug); // write passwords to config file :| config->deleteEntry( "User password" ); config->deleteEntry( "Pre shared key" ); config->deleteEntry( "PrivateKey password" ); // } config->deleteEntry( "Connection type" ); config->deleteEntry( "VPN Gateway" ); config->deleteEntry( "VPN ID" ); config->deleteEntry( "Username" ); config->deleteEntry( "Save user password" ); config->deleteEntry( "Save PSK" ); config->deleteEntry( "Private key" ); config->deleteEntry( "Use advanced settings" ); config->deleteEntry( "Application version" ); config->deleteEntry( "Local port" ); config->deleteEntry( "NT domain name" ); config->deleteEntry( "Perfect forward secrety" ); config->deleteEntry( "IKE group" ); config->deleteEntry( "Use application version" ); config->deleteEntry( "Use global IPSec secret" ); config->deleteEntry( "Use IKE group" ); config->deleteEntry( "Use local port" ); config->deleteEntry( "Use NT domain name" ); config->deleteEntry( "Use single DES" ); config->deleteEntry( "Use perfect Forward Secrety" ); config->deleteEntry( "Remote net address" ); config->deleteEntry( "Remote net mask" ); config->deleteEntry( "x509 certificate" ); config->deleteEntry( "Ca certificate" ); config->deleteEntry( "Network device" ); config->deleteEntry( "Cert path" ); config->deleteEntry( "Auth type"); config->deleteEntry( "do ping ip" ); config->deleteEntry( "Ping host IP" ); config->deleteEntry( "Use special remote ID" ); config->deleteEntry( "Special server certificate" ); config->deleteEntry( "Use special server certificate" ); config->deleteEntry( "Special remote ID" ); config->deleteEntry( "Use UDP-protocol" ); config->deleteEntry( "Use UDP-port" ); config->deleteEntry( "local UDP port" ); config->deleteEntry( "use DNS_UPDATE" ); config->deleteEntry( "use DNS-server" ); config->deleteEntry( "DNS server" ); config->deleteEntry( "get dns server from peer" ); config->deleteEntry( "refuse 40 bit encryption" ); appPointer->processEvents(); config->deleteEntry( "refuse 128 bit encryption" ); config->deleteEntry( "require stateless encryption" ); config->deleteEntry( "require mppe" ); config->deleteEntry( "Disable MPPE compression" ); config->deleteEntry( "Local virtual IP" ); config->deleteEntry( "Remote virtual IP" ); config->deleteEntry( "Pre shared key file" ); config->deleteEntry( "Execute command before connect" ); config->deleteEntry( "Execute command after connect" ); config->deleteEntry( "Execute command before disconnect" ); config->deleteEntry( "Execute command after disconnect" ); config->deleteEntry( "Command before connect" ); config->deleteEntry( "Command after connect" ); config->deleteEntry( "Command before disconnect" ); config->deleteEntry( "Command after disconnect" ); config->deleteEntry( "Use no BSD compression" ); config->deleteEntry( "Use no deflate" ); config->deleteEntry( "Set default route" ); config->deleteEntry( "Replace default route" ); config->deleteEntry( "Use own MTU" ); config->deleteEntry( "Use own MRU" ); config->deleteEntry( "MTU for pppd" ); config->deleteEntry( "MRU for pppd" ); config->deleteEntry( "Use Virtual IP" ); config->deleteEntry( "Virtual IP" ); config->deleteEntry( "PSK is in file" ); config->deleteEntry( "Use additional network routes" ); config->deleteEntry( "Hash algorithm" ); config->deleteEntry( "Tunnel device type" ); config->deleteEntry( "Use userdefined port" ); config->deleteEntry( "Userdefined port" ); config->deleteEntry( "Keep default route" ); config->deleteEntry( "Additional network routes" ); config->deleteEntry("AuthWithUsernameAndPassword" ); config->deleteEntry("AllowEmptyGroupPassword" ); config->deleteEntry("Encryption algorithm"); config->deleteEntry("Authentication algorithm"); config->deleteGroup( ProfileName ); /* give info */ //slotStatusMsg ( i18n( "Profile \"%1\" removed." ).arg( Name ), ID_FLASH_MSG ); appendLogEntry ( i18n( "Profile \"%1\" removed." ).arg( Name ) , info); AccountList->remove(it); break; } } } appPointer->processEvents(); } config->sync(); appPointer->processEvents(); }