summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2016-07-01 13:27:17 +0200
committerJakub Hrozek <jhrozek@redhat.com>2016-07-07 10:30:23 +0200
commit552390afcc81af96ca201fa6c25ddefbbecbeb4e (patch)
tree891e4baf5ee9f011c9407409613bb4832156e5c4
parenta0b824ac01c6b58fe6055d48aa6e29e94219646d (diff)
downloadsssd-552390afcc81af96ca201fa6c25ddefbbecbeb4e.zip
sssd-552390afcc81af96ca201fa6c25ddefbbecbeb4e.tar.gz
sssd-552390afcc81af96ca201fa6c25ddefbbecbeb4e.tar.xz
TOOLS: Add the upgrade-cache command
Allows to upgrade the cache using the sssctl tool, which might be useful e.g. in RPM %post scripts. Reviewed-by: Sumit Bose <sbose@redhat.com>
-rw-r--r--src/tools/sssctl/sssctl.c1
-rw-r--r--src/tools/sssctl/sssctl.h4
-rw-r--r--src/tools/sssctl/sssctl_data.c30
3 files changed, 35 insertions, 0 deletions
diff --git a/src/tools/sssctl/sssctl.c b/src/tools/sssctl/sssctl.c
index 8e18569..be5f1b4 100644
--- a/src/tools/sssctl/sssctl.c
+++ b/src/tools/sssctl/sssctl.c
@@ -267,6 +267,7 @@ int main(int argc, const char **argv)
SSS_TOOL_COMMAND("backup-local-data", "Backup local data", 0, sssctl_backup_local_data),
SSS_TOOL_COMMAND("restore-local-data", "Restore local data from backup", 0, sssctl_restore_local_data),
SSS_TOOL_COMMAND("remove-cache", "Backup local data and remove cached content", 0, sssctl_remove_cache),
+ SSS_TOOL_COMMAND("upgrade-cache", "Perform cache upgrade", ERR_SYSDB_VERSION_TOO_OLD, sssctl_upgrade_cache),
SSS_TOOL_DELIMITER("Log files tools:"),
SSS_TOOL_COMMAND("remove-logs", "Remove existing SSSD log files", 0, sssctl_remove_logs),
SSS_TOOL_COMMAND("fetch-logs", "Archive SSSD log files in tarball", 0, sssctl_fetch_logs),
diff --git a/src/tools/sssctl/sssctl.h b/src/tools/sssctl/sssctl.h
index 4bcc6de..ae6e62c 100644
--- a/src/tools/sssctl/sssctl.h
+++ b/src/tools/sssctl/sssctl.h
@@ -76,6 +76,10 @@ errno_t sssctl_remove_cache(struct sss_cmdline *cmdline,
struct sss_tool_ctx *tool_ctx,
void *pvt);
+errno_t sssctl_upgrade_cache(struct sss_cmdline *cmdline,
+ struct sss_tool_ctx *tool_ctx,
+ void *pvt);
+
errno_t sssctl_remove_logs(struct sss_cmdline *cmdline,
struct sss_tool_ctx *tool_ctx,
void *pvt);
diff --git a/src/tools/sssctl/sssctl_data.c b/src/tools/sssctl/sssctl_data.c
index f1162da..3ab2ddf 100644
--- a/src/tools/sssctl/sssctl_data.c
+++ b/src/tools/sssctl/sssctl_data.c
@@ -22,7 +22,9 @@
#include <stdio.h>
#include "util/util.h"
+#include "db/sysdb.h"
#include "tools/common/sss_tools.h"
+#include "tools/common/sss_process.h"
#include "tools/sssctl/sssctl.h"
#define CACHE_FILE(db) " " DB_PATH "/" db
@@ -256,3 +258,31 @@ errno_t sssctl_remove_cache(struct sss_cmdline *cmdline,
return EOK;
}
+
+errno_t sssctl_upgrade_cache(struct sss_cmdline *cmdline,
+ struct sss_tool_ctx *tool_ctx,
+ void *pvt)
+{
+ struct sysdb_upgrade_ctx db_up_ctx;
+ errno_t ret;
+
+ if (sss_deamon_running()) {
+ return ERR_SSSD_RUNNING;
+ }
+
+ ret = confdb_get_domains(tool_ctx->confdb, &tool_ctx->domains);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, "No domains configured.\n");
+ return ret;
+ }
+
+ db_up_ctx.cdb = tool_ctx->confdb;
+ ret = sysdb_init_ext(tool_ctx, tool_ctx->domains, &db_up_ctx,
+ true, 0, 0);
+ if (ret != EOK) {
+ SYSDB_VERSION_ERROR_DAEMON(ret);
+ return ret;
+ }
+
+ return EOK;
+}