From aef367ebff0722f9228e1af865a1725d896743cb Mon Sep 17 00:00:00 2001 From: chrisparker126 Date: Sat, 10 Apr 2010 22:06:11 +0000 Subject: [PATCH] added commandline option '-U' to allow user to access different profile - in the situation where autologin is enabled - BUG found (or rather autologin induced it), if one asks to make friends to a peer (in ConfCertDialg) 'within' a session that uses autologin it freezes git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2703 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/rsserver/rsinit.cc | 217 +++++++++++++++------------ 1 file changed, 123 insertions(+), 94 deletions(-) diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 56538823c..03d9da32b 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -296,100 +296,107 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored) #endif /******************************** WINDOWS/UNIX SPECIFIC PART ******************/ - int c; - /* getopt info: every availiable option is listet here. if it is followed by a ':' it - needs an argument. If it is followed by a '::' the argument is optional. - */ - while((c = getopt(argc, argv,"hesamui:p:c:w:l:d:")) != -1) - { - switch (c) - { - case 'a': - RsInitConfig::autoLogin = true; - RsInitConfig::startMinimised = true; - std::cerr << "AutoLogin Allowed / Start Minimised On"; - std::cerr << std::endl; - break; - case 'm': - RsInitConfig::startMinimised = true; - std::cerr << "Start Minimised On"; - std::cerr << std::endl; - break; - case 'l': - strncpy(RsInitConfig::logfname, optarg, 1024); - std::cerr << "LogFile (" << RsInitConfig::logfname; - std::cerr << ") Selected" << std::endl; - RsInitConfig::haveLogFile = true; - break; - case 'w': - RsInitConfig::passwd = optarg; - std::cerr << "Password Specified(" << RsInitConfig::passwd; - std::cerr << ") Selected" << std::endl; - RsInitConfig::havePasswd = true; - break; - case 'i': - strncpy(RsInitConfig::inet, optarg, 256); - std::cerr << "New Inet Addr(" << RsInitConfig::inet; - std::cerr << ") Selected" << std::endl; - RsInitConfig::forceLocalAddr = true; - break; - case 'p': - RsInitConfig::port = atoi(optarg); - std::cerr << "New Listening Port(" << RsInitConfig::port; - std::cerr << ") Selected" << std::endl; - break; - case 'c': - RsInitConfig::basedir = optarg; - std::cerr << "New Base Config Dir("; - std::cerr << RsInitConfig::basedir; - std::cerr << ") Selected" << std::endl; - break; - case 's': - RsInitConfig::outStderr = true; - RsInitConfig::haveLogFile = false; - std::cerr << "Output to Stderr"; - std::cerr << std::endl; - break; - case 'd': - RsInitConfig::haveDebugLevel = true; - RsInitConfig::debugLevel = atoi(optarg); - std::cerr << "Opt for new Debug Level"; - std::cerr << std::endl; - break; - case 'u': - RsInitConfig::udpListenerOnly = true; - std::cerr << "Opt for only udpListener"; - std::cerr << std::endl; - break; - case 'e': - RsInitConfig::forceExtPort = true; - std::cerr << "Opt for External Port Mode"; - std::cerr << std::endl; - break; - case 'h': - std::cerr << "Help: " << std::endl; - std::cerr << "The commandline options are for retroshare-nogui, a headless server in a shell, or systems without QT." << std::endl << std::endl; - std::cerr << "-l [logfile] Set the logfilename" << std::endl; - std::cerr << "-w [password] Set the password" << std::endl; - std::cerr << "-i [ip_adress] Set IP Adress to use" << std::endl; - std::cerr << "-p [port] Set the Port to listen on" << std::endl; - std::cerr << "-c [basedir] Set the config basdir" << std::endl; - std::cerr << "-s Output to Stderr" << std::endl; - std::cerr << "-d [debuglevel] Set the debuglevel" << std::endl; - std::cerr << "-a AutoLogin (Windows Only) + StartMinimised" << std::endl; - std::cerr << "-m StartMinimised" << std::endl; - std::cerr << "-u Only listen to UDP" << std::endl; - std::cerr << "-e Use a forwarded external Port" << std::endl << std::endl; - std::cerr << "Example" << std::endl; - std::cerr << "./retroshare-nogui -wmysecretpassword -e" << std::endl; - exit(1); - break; - default: - std::cerr << "Unknown Option!" << std::endl; - std::cerr << "Use '-h' for help." << std::endl; - exit(1); - } - } + int c; + std::string prefPgpName = ""; + /* getopt info: every availiable option is listed here. if it is followed by a ':' it + needs an argument. If it is followed by a '::' the argument is optional. + */ + while((c = getopt(argc, argv,"hesamui:p:c:w:l:d:U:")) != -1) + { + switch (c) + { + case 'a': + RsInitConfig::autoLogin = true; + RsInitConfig::startMinimised = true; + std::cerr << "AutoLogin Allowed / Start Minimised On"; + std::cerr << std::endl; + break; + case 'm': + RsInitConfig::startMinimised = true; + std::cerr << "Start Minimised On"; + std::cerr << std::endl; + break; + case 'l': + strncpy(RsInitConfig::logfname, optarg, 1024); + std::cerr << "LogFile (" << RsInitConfig::logfname; + std::cerr << ") Selected" << std::endl; + RsInitConfig::haveLogFile = true; + break; + case 'w': + RsInitConfig::passwd = optarg; + std::cerr << "Password Specified(" << RsInitConfig::passwd; + std::cerr << ") Selected" << std::endl; + RsInitConfig::havePasswd = true; + break; + case 'i': + strncpy(RsInitConfig::inet, optarg, 256); + std::cerr << "New Inet Addr(" << RsInitConfig::inet; + std::cerr << ") Selected" << std::endl; + RsInitConfig::forceLocalAddr = true; + break; + case 'p': + RsInitConfig::port = atoi(optarg); + std::cerr << "New Listening Port(" << RsInitConfig::port; + std::cerr << ") Selected" << std::endl; + break; + case 'c': + RsInitConfig::basedir = optarg; + std::cerr << "New Base Config Dir("; + std::cerr << RsInitConfig::basedir; + std::cerr << ") Selected" << std::endl; + break; + case 's': + RsInitConfig::outStderr = true; + RsInitConfig::haveLogFile = false; + std::cerr << "Output to Stderr"; + std::cerr << std::endl; + break; + case 'd': + RsInitConfig::haveDebugLevel = true; + RsInitConfig::debugLevel = atoi(optarg); + std::cerr << "Opt for new Debug Level"; + std::cerr << std::endl; + break; + case 'u': + RsInitConfig::udpListenerOnly = true; + std::cerr << "Opt for only udpListener"; + std::cerr << std::endl; + break; + case 'e': + RsInitConfig::forceExtPort = true; + std::cerr << "Opt for External Port Mode"; + std::cerr << std::endl; + break; + case 'U': + prefPgpName = optarg; + std::cerr << "Opt for User Id "; + std::cerr << std::endl; + break; + case 'h': + std::cerr << "Help: " << std::endl; + std::cerr << "The commandline options are for retroshare-nogui, a headless server in a shell, or systems without QT." << std::endl << std::endl; + std::cerr << "-l [logfile] Set the logfilename" << std::endl; + std::cerr << "-w [password] Set the password" << std::endl; + std::cerr << "-i [ip_adress] Set IP Adress to use" << std::endl; + std::cerr << "-p [port] Set the Port to listen on" << std::endl; + std::cerr << "-c [basedir] Set the config basdir" << std::endl; + std::cerr << "-s Output to Stderr" << std::endl; + std::cerr << "-d [debuglevel] Set the debuglevel" << std::endl; + std::cerr << "-a AutoLogin (Windows Only) + StartMinimised" << std::endl; + std::cerr << "-m StartMinimised" << std::endl; + std::cerr << "-u Only listen to UDP" << std::endl; + std::cerr << "-e Use a forwarded external Port" << std::endl << std::endl; + std::cerr << "-U [User Name] Sets Account to Use, Useful when Autologin is enabled" << std::endl; + std::cerr << "Example" << std::endl; + std::cerr << "./retroshare-nogui -wmysecretpassword -e" << std::endl; + exit(1); + break; + default: + std::cerr << "Unknown Option!" << std::endl; + std::cerr << "Use '-h' for help." << std::endl; + exit(1); + } + } // set the default Debug Level... @@ -479,6 +486,27 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored) std::list::iterator it; getAvailableAccounts(RsInitConfig::accountIds); + // if a different user id has been passed to cmd line check for that instead + + bool pgpNameFound = false; + if(prefPgpName != ""){ + + for(it = RsInitConfig::accountIds.begin() ; it!= RsInitConfig::accountIds.end() ; it++){ + + if(prefPgpName == it->pgpName){ + + RsInitConfig::preferedId = it->sslId; + pgpNameFound = true; + } + } + if(!pgpNameFound){ + std::cerr << "Invalid User name -U pgpName not Found" << std::endl; + exit(1); + } + } + + + /* check that preferedId */ std::string userName; std::string userId; @@ -498,6 +526,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored) { std::cerr << "No Existing User" << std::endl; RsInitConfig::preferedId == ""; + }