Skip to content
Permalink
Browse files

SSSCTL: Add cache-expire command

Add sssctl cache-expire as a wrapper for the sss_cache utility to
invalidate cached objects.

Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Reviewed-by: Michal Židek <mzidek@redhat.com>
  • Loading branch information...
justin-stephenson authored and Lukas Slebodnik committed Jul 23, 2017
1 parent da19eae commit f74408e37a3007aa41b19ab2afb693a91694da42
Showing with 49 additions and 0 deletions.
  1. +1 −0 src/tools/sssctl/sssctl.c
  2. +4 −0 src/tools/sssctl/sssctl.h
  3. +44 −0 src/tools/sssctl/sssctl_data.c
@@ -273,6 +273,7 @@ int main(int argc, const char **argv)
SSS_TOOL_COMMAND("client-data-restore", "Restore local data from backup", 0, sssctl_client_data_restore),
SSS_TOOL_COMMAND("cache-remove", "Backup local data and remove cached content", 0, sssctl_cache_remove),
SSS_TOOL_COMMAND("cache-upgrade", "Perform cache upgrade", ERR_SYSDB_VERSION_TOO_OLD, sssctl_cache_upgrade),
SSS_TOOL_COMMAND("cache-expire", "Invalidate cached objects", 0, sssctl_cache_expire),
SSS_TOOL_DELIMITER("Log files tools:"),
SSS_TOOL_COMMAND("logs-remove", "Remove existing SSSD log files", 0, sssctl_logs_remove),
SSS_TOOL_COMMAND("logs-fetch", "Archive SSSD log files in tarball", 0, sssctl_logs_fetch),
@@ -98,6 +98,10 @@ errno_t sssctl_cache_upgrade(struct sss_cmdline *cmdline,
struct sss_tool_ctx *tool_ctx,
void *pvt);

errno_t sssctl_cache_expire(struct sss_cmdline *cmdline,
struct sss_tool_ctx *tool_ctx,
void *pvt);

errno_t sssctl_logs_remove(struct sss_cmdline *cmdline,
struct sss_tool_ctx *tool_ctx,
void *pvt);
@@ -30,6 +30,7 @@
#define SSS_BACKUP_DIR SSS_STATEDIR "/backup"
#define SSS_BACKUP_USER_OVERRIDES SSS_BACKUP_DIR "/sssd_user_overrides.bak"
#define SSS_BACKUP_GROUP_OVERRIDES SSS_BACKUP_DIR "/sssd_group_overrides.bak"
#define SSS_CACHE "sss_cache"

struct sssctl_data_opts {
int override;
@@ -289,3 +290,46 @@ errno_t sssctl_cache_upgrade(struct sss_cmdline *cmdline,

return EOK;
}

errno_t sssctl_cache_expire(struct sss_cmdline *cmdline,
struct sss_tool_ctx *tool_ctx,
void *pvt)
{
errno_t ret;
char *cmd_args = NULL;
const char *cachecmd = SSS_CACHE;
char *cmd = NULL;
int i;

if (cmdline->argc == 0) {
ret = sssctl_run_command(cachecmd);
goto done;
}

cmd_args = talloc_strdup(tool_ctx, "");
if (cmd_args == NULL) {
ret = ENOMEM;
goto done;
}

for (i = 0; i < cmdline->argc; i++) {
cmd_args = talloc_strdup_append(cmd_args, cmdline->argv[i]);
if (i != cmdline->argc - 1) {
cmd_args = talloc_strdup_append(cmd_args, " ");
}
}

cmd = talloc_asprintf(tool_ctx, "%s %s", cachecmd, cmd_args);
if (cmd == NULL) {
ret = ENOMEM;
goto done;
}

ret = sssctl_run_command(cmd);

done:
talloc_free(cmd_args);
talloc_free(cmd);

return ret;
}

0 comments on commit f74408e

Please sign in to comment.
You can’t perform that action at this time.