mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 02:56:18 +05:00
Close #67: possibility to ignore password prompt from CLI
XCA automatically checks whether the current arguments need a password
This commit is contained in:
parent
8daf06dcac
commit
5f1d394530
@ -34,6 +34,8 @@
|
||||
|
||||
xca_db Database;
|
||||
|
||||
bool database_model::open_without_password = false;
|
||||
|
||||
QSqlError database_model::initSqlDB()
|
||||
{
|
||||
#define MAX_SCHEMAS 7
|
||||
@ -424,7 +426,6 @@ void database_model::openDatabase(const QString &descriptor, const Passwd &pass)
|
||||
|
||||
qDebug() << "IS REMOTE?" << params.size() << NUM_PARAM << type << params;
|
||||
try {
|
||||
Passwd pwd(pass);
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase(type);
|
||||
connName = db.connectionName();
|
||||
if (!isRemote) {
|
||||
@ -432,7 +433,7 @@ void database_model::openDatabase(const QString &descriptor, const Passwd &pass)
|
||||
throw errorEx(tr("No SqLite3 driver available. Please install the qt-sqlite package of your distribution"));
|
||||
openLocalDatabase(connName, descriptor);
|
||||
} else {
|
||||
openRemoteDatabase(connName, params, pwd);
|
||||
openRemoteDatabase(connName, params, pass);
|
||||
}
|
||||
DbTransaction::setHasTransaction(
|
||||
db.driver()->hasFeature(QSqlDriver::Transactions));
|
||||
@ -483,7 +484,7 @@ enum open_result database_model::initPass(const QString &dbName, const QString &
|
||||
salt = Entropy::makeSalt();
|
||||
pki_evp::passHash =pki_evp::sha512passwT(pki_evp::passwd,salt);
|
||||
Settings["pwhash"] = pki_evp::passHash;
|
||||
} else {
|
||||
} else if (!open_without_password) {
|
||||
pwhash_upgrade();
|
||||
while (pki_evp::sha512passwT(pki_evp::passwd, pki_evp::passHash)
|
||||
!= pki_evp::passHash)
|
||||
@ -501,6 +502,7 @@ enum open_result database_model::initPass(const QString &dbName, const QString &
|
||||
pwhash_upgrade();
|
||||
}
|
||||
}
|
||||
open_without_password = false;
|
||||
if (pki_evp::passwd.isNull())
|
||||
pki_evp::passwd = "";
|
||||
return pw_ok;
|
||||
|
||||
@ -49,6 +49,7 @@ class database_model: public QObject
|
||||
void pkiChangedSlot(pki_base *pki);
|
||||
|
||||
public:
|
||||
static bool open_without_password;
|
||||
database_model(const QString &dbName,
|
||||
const Passwd &pass = Passwd());
|
||||
~database_model();
|
||||
|
||||
@ -159,6 +159,9 @@ static void read_cmdline(int argc, char *argv[])
|
||||
if (cmd_opts.getResult() != 0)
|
||||
cmd_help(EXIT_FAILURE, cmd_opts.resultString().toUtf8());
|
||||
|
||||
if (!cmd_opts.has("password"))
|
||||
database_model::open_without_password = true;
|
||||
|
||||
if (cmd_opts.has("database"))
|
||||
Database.open(cmd_opts["database"], sqlpw);
|
||||
|
||||
@ -189,6 +192,8 @@ static void read_cmdline(int argc, char *argv[])
|
||||
cmd_help(EXIT_FAILURE, msg[opt]);
|
||||
}
|
||||
}
|
||||
database_model::open_without_password = true;
|
||||
|
||||
if (cmd_opts.has("list-curves")) {
|
||||
QStringList list;
|
||||
foreach(const builtin_curve &c, builtinCurves) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user