Backup functionality working, the UI still needs work.

This commit is contained in:
eelke 2017-03-05 21:23:36 +01:00
parent d0ea9dfa0c
commit 73528ca965
12 changed files with 606 additions and 194 deletions

View file

@ -1,5 +1,7 @@
#include "connectionconfig.h"
#include "util.h"
#include <QCoreApplication>
#include <QProcessEnvironment>
namespace {
@ -259,3 +261,60 @@ void ConnectionConfig::clean()
{
m_dirty = false;
}
/*
PGHOST behaves the same as the host connection parameter.
PGHOSTADDR behaves the same as the hostaddr connection parameter. This can be set instead of or in addition to PGHOST to avoid DNS lookup overhead.
PGPORT behaves the same as the port connection parameter.
PGDATABASE behaves the same as the dbname connection parameter.
PGUSER behaves the same as the user connection parameter.
PGPASSWORD behaves the same as the password connection parameter. Use of this environment variable is not recommended for security reasons, as some operating systems allow non-root users to see process environment variables via ps; instead consider using the ~/.pgpass file (see Section 31.15).
PGPASSFILE specifies the name of the password file to use for lookups. If not set, it defaults to ~/.pgpass (see Section 31.15).
PGSERVICE behaves the same as the service connection parameter.
PGSERVICEFILE specifies the name of the per-user connection service file. If not set, it defaults to ~/.pg_service.conf (see Section 31.16).
PGREALM sets the Kerberos realm to use with PostgreSQL, if it is different from the local realm. If PGREALM is set, libpq applications will attempt authentication with servers for this realm and use separate ticket files to avoid conflicts with local ticket files. This environment variable is only used if GSSAPI authentication is selected by the server.
PGOPTIONS behaves the same as the options connection parameter.
PGAPPNAME behaves the same as the application_name connection parameter.
PGSSLMODE behaves the same as the sslmode connection parameter.
PGREQUIRESSL behaves the same as the requiressl connection parameter.
PGSSLCOMPRESSION behaves the same as the sslcompression connection parameter.
PGSSLCERT behaves the same as the sslcert connection parameter.
PGSSLKEY behaves the same as the sslkey connection parameter.
PGSSLROOTCERT behaves the same as the sslrootcert connection parameter.
PGSSLCRL behaves the same as the sslcrl connection parameter.
PGREQUIREPEER behaves the same as the requirepeer connection parameter.
PGKRBSRVNAME behaves the same as the krbsrvname connection parameter.
PGGSSLIB behaves the same as the gsslib connection parameter.
PGCONNECT_TIMEOUT behaves the same as the connect_timeout connection parameter.
PGCLIENTENCODING behaves the same as the client_encoding connection parameter.
*/
void ConnectionConfig::writeToEnvironment(QProcessEnvironment &env) const
{
strToEnv(env, "PGHOST", m_host);
strToEnv(env, "PGHOSTADDR", m_hostaddr);
strToEnv(env, "PGPORT", m_port);
strToEnv(env, "PGDATABASE", m_dbname);
strToEnv(env, "PGUSER", m_user);
strToEnv(env, "PGPASSWORD", m_password);
strToEnv(env, "PGSSLMODE", m_sslMode);
strToEnv(env, "PGSSLCERT", m_sslCert);
strToEnv(env, "PGSSLKEY", m_sslKey);
strToEnv(env, "PGSSLROOTCERT", m_sslRootCert);
strToEnv(env, "PGSSLCRL", m_sslCrl);
strToEnv(env, "PGSSLCOMPRESSION", "0");
strToEnv(env, "PGCONNECT_TIMEOUT", "10");
env.insert("PGCLIENTENCODING", "utf8");
env.remove("PGREQUIRESSL");
}
void ConnectionConfig::strToEnv(QProcessEnvironment &env, const QString &var, const std::string &val)
{
if (val.empty())
env.remove(var);
else
env.insert(var, stdStrToQ(val));
}