2020-08-19 Fred Gleason <fredg@paravelsystems.com>

* Added a 'STATIONS.SSH_IDENTITY_FILE' field to the database.
	* Added a 'RECORDINGS.URL_USE_ID_FILE' field to the database.
	* Added a 'FEEDS.PURGE_USE_ID_FILE' field to the database.
	* Incremented the database version to 333.
	* Added 'RDStation::sshIdentityFile()' and
	'RDStation::setSshIdentityFile()' methods.
	* Added 'RDRecording::urlUseIdFile()' and
	'RDRecording::setUrlUseIdFile()' methods.
	* Added 'RDFeed::purgeUseIdFile()' and 'RDFeed::setPurgeUseIdFile()'
	methods.
	* Added a 'SSH Ident. File' control to the 'Host' dialog in
	rdadmin(1).
	* Added an 'Authenticate with local identity file' checkbox to
	the 'Feed' dialog in rdadmin(1).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2020-08-19 10:44:41 -04:00
parent afb3832f72
commit ecd2a2d427
42 changed files with 495 additions and 149 deletions

View File

@@ -112,6 +112,8 @@ int RDDownload::totalSteps() const
RDDownload::ErrorCode RDDownload::runDownload(const QString &username,
const QString &password,
const QString &id_filename,
bool use_id_filename,
bool log_debug)
{
CURL *curl=NULL;
@@ -120,6 +122,7 @@ RDDownload::ErrorCode RDDownload::runDownload(const QString &username,
long response_code=0;
RDDownload::ErrorCode ret=RDDownload::ErrorOk;
RDSystemUser *user=NULL;
char userpwd[256];
if(!urlIsSupported(conv_src_url)) {
return RDDownload::ErrorUnsupportedProtocol;
@@ -155,10 +158,23 @@ RDDownload::ErrorCode RDDownload::runDownload(const QString &username,
//
url.replace("#","%23");
//
// Authentication
//
if((conv_src_url.scheme().toLower()=="sftp")&&
(!id_filename.isEmpty())&&use_id_filename) {
curl_easy_setopt(curl,CURLOPT_USERNAME,username.toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_SSH_PRIVATE_KEYFILE,
id_filename.toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_KEYPASSWD,password.toUtf8().constData());
}
else {
strncpy(userpwd,(username+":"+password).utf8(),256);
curl_easy_setopt(curl,CURLOPT_USERPWD,userpwd);
}
curl_easy_setopt(curl,CURLOPT_URL,url.constData());
curl_easy_setopt(curl,CURLOPT_WRITEDATA,f);
curl_easy_setopt(curl,CURLOPT_USERNAME,username.toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_PASSWORD,password.toUtf8().constData());
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);
curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1);
curl_easy_setopt(curl,CURLOPT_PROGRESSFUNCTION,DownloadProgressCallback);