2009-02-03 14:42:07 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* "$Id: retroshare.cc,v 1.4 2007-04-21 19:08:51 rmf24 Exp $"
|
|
|
|
*
|
|
|
|
* RetroShare C++ Interface.
|
|
|
|
*
|
|
|
|
* Copyright 2004-2006 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsiface.h> /* definition of iface */
|
|
|
|
#include <retroshare/rsinit.h> /* definition of iface */
|
2009-02-03 14:42:07 -05:00
|
|
|
|
|
|
|
#include "notifytxt.h"
|
|
|
|
|
2012-04-12 19:29:39 -04:00
|
|
|
#include <unistd.h>
|
2013-08-06 13:01:38 -04:00
|
|
|
#include <util/argstream.h>
|
2009-02-03 14:42:07 -05:00
|
|
|
#include <iostream>
|
|
|
|
#ifdef WINDOWS_SYS
|
|
|
|
#include <winsock2.h>
|
|
|
|
#endif
|
|
|
|
|
2012-02-07 12:01:07 -05:00
|
|
|
#ifdef RS_INTRO_SERVER
|
|
|
|
#include "introserver.h"
|
|
|
|
#endif
|
2009-02-03 14:42:07 -05:00
|
|
|
|
2012-08-05 13:08:29 -04:00
|
|
|
#ifdef RS_SSH_SERVER
|
|
|
|
#include "ssh/rssshd.h"
|
2012-08-07 19:55:43 -04:00
|
|
|
|
|
|
|
#include "menu/menus.h"
|
2012-08-20 10:59:41 -04:00
|
|
|
#include "menu/stdiocomms.h"
|
|
|
|
|
|
|
|
#include "rpc/rpcsetup.h"
|
2012-08-07 19:55:43 -04:00
|
|
|
|
2012-12-17 14:15:04 -05:00
|
|
|
// NASTY GLOBAL VARIABLE HACK - NEED TO THINK OF A BETTER SYSTEM.
|
|
|
|
#include "rpc/proto/rpcprotosystem.h"
|
|
|
|
|
2012-08-05 13:08:29 -04:00
|
|
|
#endif
|
|
|
|
|
2013-08-06 13:01:38 -04:00
|
|
|
#ifdef RS_SSH_SERVER
|
|
|
|
void generatePasswordHash() ;
|
|
|
|
#endif
|
|
|
|
|
2009-02-03 14:42:07 -05:00
|
|
|
/* Basic instructions for running libretroshare as background thread.
|
|
|
|
* ******************************************************************* *
|
|
|
|
* This allows your program to communicate with authenticated peers.
|
|
|
|
*
|
|
|
|
* libretroshare's interfaces are defined in libretroshare/src/rsiface.
|
|
|
|
* This should be the only headers that you need to include.
|
|
|
|
*
|
|
|
|
* The startup routine's are defined in rsiface.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
/* Retroshare startup is configured using an RsInit object.
|
|
|
|
* This is an opaque class, which the user cannot directly tweak
|
|
|
|
* If you want to peek at whats happening underneath look in
|
|
|
|
* libretroshare/src/rsserver/p3face-startup.cc
|
|
|
|
*
|
|
|
|
* You create it with InitRsConfig(), and delete with CleanupRsConfig()
|
|
|
|
* InitRetroshare(argv, argc, config) parses the command line options,
|
|
|
|
* and initialises the config paths.
|
|
|
|
*
|
|
|
|
* *** There are several functions that I should add to modify
|
|
|
|
* **** the config the moment these can only be set via the commandline
|
|
|
|
* - RsConfigDirectory(...) is probably the most useful.
|
|
|
|
* - RsConfigNetAddr(...) for setting port, etc.
|
|
|
|
* - RsConfigOutput(...) for logging and debugging.
|
|
|
|
*
|
|
|
|
* Next you need to worry about loading your certificate, or making
|
|
|
|
* a new one:
|
|
|
|
*
|
|
|
|
* RsGenerateCertificate(...) To create a new key, certificate
|
|
|
|
* LoadPassword(...) set password for existing certificate.
|
|
|
|
**/
|
|
|
|
|
2012-08-09 09:45:05 -04:00
|
|
|
bool strictCheck = true;
|
|
|
|
|
|
|
|
#ifdef RS_SSH_SERVER
|
|
|
|
/* parse commandline for additional nogui options */
|
|
|
|
|
|
|
|
int c;
|
|
|
|
// libretroshare's getopt str - so don't use any of these: "hesamui:p:c:w:l:d:U:r:R:"
|
|
|
|
// need options for
|
|
|
|
// enable SSH. (-S)
|
|
|
|
// set user/password for SSH. -L "user:pwdhash"
|
|
|
|
// accept RSA Key Auth. -K "RsaPubKeyFile"
|
|
|
|
// Terminal mode. -T
|
2012-08-20 10:59:41 -04:00
|
|
|
bool enableRpc = false;
|
2012-08-09 09:45:05 -04:00
|
|
|
bool enableSsh = false;
|
|
|
|
bool enableSshHtml = false;
|
|
|
|
bool enableTerminal = false;
|
|
|
|
bool enableSshRsa = false;
|
|
|
|
bool genPwdHash = false;
|
|
|
|
std::string sshUser = "user";
|
|
|
|
std::string sshPwdHash = "";
|
|
|
|
std::string sshRsaFile = "";
|
2012-12-17 15:34:38 -05:00
|
|
|
std::string sshPortStr = "0";
|
2012-08-09 09:45:05 -04:00
|
|
|
|
2012-12-17 14:15:04 -05:00
|
|
|
uint16_t extPort = 0;
|
2013-08-06 13:01:38 -04:00
|
|
|
uint16_t sshPort = 7022;
|
2012-12-17 14:15:04 -05:00
|
|
|
bool extPortSet = false;
|
2013-08-06 13:01:38 -04:00
|
|
|
bool displayRPCInfo = false ;
|
2012-12-17 14:15:04 -05:00
|
|
|
|
2013-08-06 13:01:38 -04:00
|
|
|
argstream as(argc,argv) ;
|
|
|
|
|
|
|
|
as >> option('X',"enable-ssh" ,enableSsh ,"Enable SSH" )
|
|
|
|
>> option('T',"enable-terminal",enableTerminal ,"Enable terminal interface." )
|
|
|
|
>> option('C',"enable-rpc" ,enableRpc ,"Enable RPC protocol. To be used with e.g. -X (SSH).")
|
|
|
|
>> option('G',"gen-password" ,genPwdHash ,"Generate password hash (to supply to option -P)")
|
|
|
|
#if 0
|
|
|
|
>> option('H',"enable-ssh-html",enableSshHtml ,"Enable SSH html." )
|
2012-08-09 09:45:05 -04:00
|
|
|
#endif
|
2013-08-06 13:01:38 -04:00
|
|
|
>> parameter('S',"ssh-port" ,sshPort ,"port" ,"SSH port to contact the interface.",false)
|
|
|
|
>> parameter('E',"ext-port" ,extPort ,"port" ,"Specify Alternative External Port (provided to Clients)",false)
|
|
|
|
>> parameter('L',"ssh-user" ,sshUser ,"name" ,"Ssh login user",false)
|
|
|
|
>> parameter('P',"ssh-p-hash" ,sshPwdHash ,"hash" ,"Ssh login password hash (Generated by retroshare-nogui -G)",false)
|
|
|
|
>> parameter('K',"ssh-key-file" ,sshRsaFile ,"RSA key file", "RSA key file for SSH login (not yet implemented).",false )// NOT FINISHED YET.
|
|
|
|
|
|
|
|
>> help() ;
|
|
|
|
|
|
|
|
// Normally argstream would handle this by itself, if we called
|
|
|
|
// as.defaultErrorHandling() ;
|
|
|
|
//
|
|
|
|
// but we have other parameter handling functions after, so we don't want to quit if help is requested.
|
|
|
|
//
|
|
|
|
if (as.helpRequested())
|
|
|
|
{
|
|
|
|
std::cerr << "\nSpecific Help Options:" << std::endl;
|
|
|
|
std::cerr << as.usage() << std::endl;
|
|
|
|
std::cerr << "\t To setup rs-nogui as a SSH Server is a three step process: " << std::endl;
|
|
|
|
std::cerr << "\t 1) Generate a RSA keypair in the current directory: \"ssh-keygen -t rsa -f rs_ssh_host_rsa_key\" " << std::endl;
|
|
|
|
std::cerr << "\t 2) Generate a password hash for the RPC login: \"./retroshare-nogui -G\" " << std::endl;
|
|
|
|
std::cerr << "\t 3) Launch the RS with remote control enabled: \"./retroshare-nogui -X/-T [-C] -S [port] -L <user> -P <passwordhash>\" " << std::endl;
|
|
|
|
|
|
|
|
std::cerr << "\nAdditional options: \n" << std::endl;
|
|
|
|
}
|
|
|
|
if (!as.isOk())
|
|
|
|
{
|
|
|
|
std::cerr << as.errorLog();
|
|
|
|
return 1;
|
2012-08-09 09:45:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (genPwdHash)
|
|
|
|
{
|
2013-08-06 13:01:38 -04:00
|
|
|
generatePasswordHash() ;
|
|
|
|
return 0 ;
|
2012-08-09 09:45:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* enforce conditions */
|
2013-08-06 13:01:38 -04:00
|
|
|
if ((!sshRsaFile.empty() || !sshPwdHash.empty()) && (!enableSsh))
|
2012-08-09 09:45:05 -04:00
|
|
|
{
|
2013-08-06 13:01:38 -04:00
|
|
|
std::cerr << "ERROR: SSH Server (-X) must be enabled to specify SSH Pwd (-P) or SSH RSA (-K)";
|
2012-08-09 09:45:05 -04:00
|
|
|
std::cerr << std::endl;
|
2013-08-06 13:01:38 -04:00
|
|
|
return 1 ;
|
2012-08-09 09:45:05 -04:00
|
|
|
}
|
|
|
|
|
2013-08-06 13:01:38 -04:00
|
|
|
if (enableSsh && (!enableSshRsa) && sshPwdHash.empty())
|
2012-08-09 09:45:05 -04:00
|
|
|
{
|
2013-08-06 13:01:38 -04:00
|
|
|
std::cerr << "ERROR: One of (or both) SSH Pwd (-P) and SSH RSA (-K) must be specified with SSH Server (-X)";
|
2012-08-09 09:45:05 -04:00
|
|
|
std::cerr << std::endl;
|
2013-08-06 13:01:38 -04:00
|
|
|
return 1 ;
|
2012-08-09 09:45:05 -04:00
|
|
|
}
|
|
|
|
|
2012-08-20 10:59:41 -04:00
|
|
|
if (enableRpc && (!enableSsh))
|
|
|
|
{
|
2013-08-06 13:01:38 -04:00
|
|
|
std::cerr << "ERROR: RPC Mode (-C) requires SSH Server (-X) enabled";
|
2012-08-20 10:59:41 -04:00
|
|
|
std::cerr << std::endl;
|
2013-08-06 13:01:38 -04:00
|
|
|
return 1 ;
|
2012-08-20 10:59:41 -04:00
|
|
|
}
|
|
|
|
|
2012-08-09 09:45:05 -04:00
|
|
|
|
|
|
|
/* parse -S, -L & -K parameters */
|
|
|
|
if (enableSshRsa)
|
|
|
|
{
|
|
|
|
/* check the file exists */
|
|
|
|
/* TODO */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enableSsh)
|
|
|
|
{
|
|
|
|
/* try parse it */
|
|
|
|
/* TODO */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-08-06 13:01:38 -04:00
|
|
|
#else
|
|
|
|
std::cerr << "\nRetroshare command line interface." << std::endl;
|
2012-08-09 09:45:05 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
RsInit::InitRsConfig();
|
2012-08-09 09:45:05 -04:00
|
|
|
int initResult = RsInit::InitRetroShare(argc, argv, strictCheck);
|
2010-11-03 18:54:34 -04:00
|
|
|
|
|
|
|
if (initResult < 0) {
|
|
|
|
/* Error occured */
|
|
|
|
switch (initResult) {
|
|
|
|
case RS_INIT_AUTH_FAILED:
|
|
|
|
std::cerr << "RsInit::InitRetroShare AuthGPG::InitAuth failed" << std::endl;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* Unexpected return code */
|
|
|
|
std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2009-02-03 14:42:07 -05:00
|
|
|
|
|
|
|
/* load password should be called at this point: LoadPassword()
|
|
|
|
* otherwise loaded from commandline.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Now setup the libretroshare interface objs
|
|
|
|
* You will need to create you own NotifyXXX class
|
|
|
|
* if you want to receive notifications of events */
|
|
|
|
|
|
|
|
NotifyTxt *notify = new NotifyTxt();
|
|
|
|
RsIface *iface = createRsIface(*notify);
|
2010-06-27 12:28:44 -04:00
|
|
|
RsControl *rsServer = createRsControl(*iface, *notify);
|
|
|
|
rsicontrol = rsServer ;
|
2009-02-03 14:42:07 -05:00
|
|
|
|
|
|
|
notify->setRsIface(iface);
|
|
|
|
|
2010-10-14 16:53:48 -04:00
|
|
|
std::string preferredId, gpgId, gpgName, gpgEmail, sslName;
|
|
|
|
RsInit::getPreferedAccountId(preferredId);
|
|
|
|
|
|
|
|
if (RsInit::getAccountDetails(preferredId, gpgId, gpgName, gpgEmail, sslName))
|
|
|
|
{
|
|
|
|
RsInit::SelectGPGAccount(gpgId);
|
|
|
|
}
|
|
|
|
|
2010-06-27 12:28:44 -04:00
|
|
|
/* Key + Certificate are loaded into libretroshare */
|
2009-02-03 14:42:07 -05:00
|
|
|
|
2011-04-11 09:15:48 -04:00
|
|
|
std::string error_string ;
|
|
|
|
int retVal = RsInit::LockAndLoadCertificates(false,error_string);
|
2010-07-01 16:30:36 -04:00
|
|
|
switch(retVal)
|
|
|
|
{
|
|
|
|
case 0: break;
|
|
|
|
case 1: std::cerr << "Error: another instance of retroshare is already using this profile" << std::endl;
|
|
|
|
return 1;
|
|
|
|
case 2: std::cerr << "An unexpected error occurred while locking the profile" << std::endl;
|
|
|
|
return 1;
|
|
|
|
case 3: std::cerr << "An error occurred while login with the profile" << std::endl;
|
|
|
|
return 1;
|
|
|
|
default: std::cerr << "Main: Unexpected switch value " << retVal << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
2009-02-26 09:10:26 -05:00
|
|
|
|
2012-08-05 13:08:29 -04:00
|
|
|
#ifdef RS_SSH_SERVER
|
|
|
|
// Says it must be called before all the threads are launched! */
|
|
|
|
// NB: this port number is not currently used.
|
2012-08-09 09:45:05 -04:00
|
|
|
RsSshd *ssh = NULL;
|
|
|
|
|
|
|
|
if (enableSsh)
|
|
|
|
{
|
|
|
|
ssh = RsSshd::InitRsSshd(sshPortStr, "rs_ssh_host_rsa_key");
|
|
|
|
// TODO Parse Option
|
|
|
|
if (enableSshRsa)
|
|
|
|
{
|
|
|
|
//ssh->adduser("anrsuser", "test");
|
|
|
|
}
|
|
|
|
|
2013-08-06 13:01:38 -04:00
|
|
|
if (!sshPwdHash.empty())
|
2012-08-09 09:45:05 -04:00
|
|
|
{
|
|
|
|
ssh->adduserpwdhash(sshUser, sshPwdHash);
|
|
|
|
}
|
|
|
|
|
2012-12-17 14:15:04 -05:00
|
|
|
if (!extPortSet)
|
|
|
|
{
|
|
|
|
extPort = atoi(sshPortStr.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
// NASTY GLOBAL VARIABLE HACK - NEED TO THINK OF A BETTER SYSTEM.
|
|
|
|
RpcProtoSystem::mExtPort = extPort;
|
2012-08-09 09:45:05 -04:00
|
|
|
}
|
2012-08-05 13:08:29 -04:00
|
|
|
#endif
|
|
|
|
|
2010-06-27 12:28:44 -04:00
|
|
|
/* Start-up libretroshare server threads */
|
|
|
|
rsServer -> StartupRetroShare();
|
2012-02-07 12:01:07 -05:00
|
|
|
|
|
|
|
#ifdef RS_INTRO_SERVER
|
|
|
|
RsIntroServer rsIS;
|
|
|
|
#endif
|
2009-02-03 14:42:07 -05:00
|
|
|
|
2012-08-05 13:08:29 -04:00
|
|
|
#ifdef RS_SSH_SERVER
|
2012-08-09 09:45:05 -04:00
|
|
|
uint32_t baseDrawFlags = 0;
|
|
|
|
if (enableSshHtml)
|
2012-08-20 10:59:41 -04:00
|
|
|
{
|
2012-08-09 09:45:05 -04:00
|
|
|
baseDrawFlags = MENU_DRAW_FLAGS_HTML;
|
2012-08-20 10:59:41 -04:00
|
|
|
}
|
2012-08-09 09:45:05 -04:00
|
|
|
|
|
|
|
if (enableSsh)
|
|
|
|
{
|
2012-08-20 10:59:41 -04:00
|
|
|
if (enableRpc)
|
|
|
|
{
|
|
|
|
/* Build RPC Server */
|
2012-09-21 19:15:26 -04:00
|
|
|
RpcMediator *med = CreateRpcSystem(ssh, notify);
|
2012-08-20 10:59:41 -04:00
|
|
|
ssh->setRpcSystem(med);
|
|
|
|
ssh->setSleepPeriods(0.01, 0.1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* create menu system for SSH */
|
|
|
|
Menu *baseMenu = CreateMenuStructure(notify);
|
|
|
|
MenuInterface *menuInterface = new MenuInterface(ssh, baseMenu, baseDrawFlags | MENU_DRAW_FLAGS_ECHO);
|
|
|
|
ssh->setRpcSystem(menuInterface);
|
2012-08-23 10:04:01 -04:00
|
|
|
ssh->setSleepPeriods(0.05, 0.5);
|
2012-08-20 10:59:41 -04:00
|
|
|
}
|
2012-08-09 09:45:05 -04:00
|
|
|
|
|
|
|
ssh->start();
|
|
|
|
}
|
|
|
|
|
2012-08-20 10:59:41 -04:00
|
|
|
MenuInterface *terminalMenu = NULL;
|
2012-08-09 09:45:05 -04:00
|
|
|
if (enableTerminal)
|
|
|
|
{
|
|
|
|
/* Terminal Version */
|
2012-08-20 10:59:41 -04:00
|
|
|
RpcComms *stdioComms = new StdioComms(fileno(stdin), fileno(stdout));
|
2012-08-09 09:45:05 -04:00
|
|
|
Menu *baseMenu = CreateMenuStructure(notify);
|
2012-08-20 10:59:41 -04:00
|
|
|
terminalMenu = new MenuInterface(stdioComms, baseMenu, baseDrawFlags | MENU_DRAW_FLAGS_NOQUIT);
|
|
|
|
//menuTerminal = new RsConsole(menuInterface, fileno(stdin), fileno(stdout));
|
2012-08-09 09:45:05 -04:00
|
|
|
}
|
2012-08-07 19:55:43 -04:00
|
|
|
|
|
|
|
|
2012-08-05 13:08:29 -04:00
|
|
|
#endif
|
|
|
|
|
2009-02-03 14:42:07 -05:00
|
|
|
/* pass control to the GUI */
|
|
|
|
while(1)
|
|
|
|
{
|
2012-08-07 19:55:43 -04:00
|
|
|
//std::cerr << "GUI Tick()" << std::endl;
|
2012-02-07 12:01:07 -05:00
|
|
|
|
|
|
|
#ifdef RS_INTRO_SERVER
|
|
|
|
rsIS.tick();
|
|
|
|
#endif
|
2012-08-07 19:55:43 -04:00
|
|
|
|
2012-08-09 09:45:05 -04:00
|
|
|
int rt = 0;
|
2012-08-07 19:55:43 -04:00
|
|
|
#ifdef RS_SSH_SERVER
|
2012-08-20 10:59:41 -04:00
|
|
|
if (terminalMenu)
|
2012-08-09 09:45:05 -04:00
|
|
|
{
|
2012-08-20 10:59:41 -04:00
|
|
|
rt = terminalMenu->tick();
|
2012-08-09 09:45:05 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// If we have a MenuTerminal ...
|
|
|
|
// only want to sleep if there is no input. (rt == 0).
|
|
|
|
if (rt == 0)
|
|
|
|
{
|
|
|
|
#ifndef WINDOWS_SYS
|
|
|
|
sleep(1);
|
|
|
|
#else
|
|
|
|
Sleep(1000);
|
2012-08-07 19:55:43 -04:00
|
|
|
#endif
|
2012-08-09 09:45:05 -04:00
|
|
|
}
|
2012-08-07 19:55:43 -04:00
|
|
|
|
2012-08-20 10:59:41 -04:00
|
|
|
usleep(1000);
|
|
|
|
|
2009-02-03 14:42:07 -05:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2013-08-06 13:01:38 -04:00
|
|
|
|
|
|
|
#ifdef RS_SSH_SERVER
|
|
|
|
void generatePasswordHash()
|
|
|
|
{
|
|
|
|
std::string saltBin;
|
|
|
|
std::string pwdHashRadix64;
|
|
|
|
std::string sshPwdForHash = "";
|
|
|
|
|
|
|
|
std::string passwd1,passwd2 ;
|
|
|
|
|
|
|
|
if(!NotifyTxt().askForPassword("Type your password (at least 8 chars) : ",false,passwd1)) exit(1) ;
|
|
|
|
|
|
|
|
if(passwd1.length() < 8)
|
|
|
|
{
|
|
|
|
std::cerr << "Password must be at least 8 characters long." << std::endl;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!NotifyTxt().askForPassword("Type your password (checking) : ",false,passwd2)) exit(1) ;
|
|
|
|
|
|
|
|
if(passwd1 != passwd2)
|
|
|
|
{
|
|
|
|
std::cerr << "Passwords differ. Please retry." << std::endl;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
sshPwdForHash = passwd1 ;
|
|
|
|
|
|
|
|
//std::cerr << "Chosen Password : " << sshPwdForHash;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
GenerateSalt(saltBin);
|
|
|
|
if (!GeneratePasswordHash(saltBin, sshPwdForHash, pwdHashRadix64))
|
|
|
|
{
|
|
|
|
std::cerr << "Error Generating Password Hash, password probably too short";
|
|
|
|
std::cerr << pwdHashRadix64;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "Generated Password Hash for rs-nogui: ";
|
|
|
|
std::cout << pwdHashRadix64;
|
|
|
|
std::cout << std::endl;
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
|
|
|
/* checking match */
|
|
|
|
if (CheckPasswordHash(pwdHashRadix64, sshPwdForHash))
|
|
|
|
{
|
|
|
|
std::cerr << "Passed Check Okay!";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "ERROR: Failed CheckPassword!";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::cerr << "Usage:";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << " - for SSH access: ./retroshare-nogui -X -S [port] -L <username> -P " << pwdHashRadix64;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << " - for RPC access: ./retroshare-nogui -C -S [port] -L <username> -P " << pwdHashRadix64;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|