sdap_sudo_shared.c revision e085a79acfcd5331b6f99748e21765579a9a99f2
112fd4f283bc07af680c305545d6e31dcde4b943gryzor Pavel Březina <pbrezina@redhat.com>
112fd4f283bc07af680c305545d6e31dcde4b943gryzor Copyright (C) 2015 Red Hat
112fd4f283bc07af680c305545d6e31dcde4b943gryzor This program is free software; you can redistribute it and/or modify
112fd4f283bc07af680c305545d6e31dcde4b943gryzor it under the terms of the GNU General Public License as published by
112fd4f283bc07af680c305545d6e31dcde4b943gryzor the Free Software Foundation; either version 3 of the License, or
112fd4f283bc07af680c305545d6e31dcde4b943gryzor (at your option) any later version.
112fd4f283bc07af680c305545d6e31dcde4b943gryzor This program is distributed in the hope that it will be useful,
112fd4f283bc07af680c305545d6e31dcde4b943gryzor but WITHOUT ANY WARRANTY; without even the implied warranty of
112fd4f283bc07af680c305545d6e31dcde4b943gryzor MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
112fd4f283bc07af680c305545d6e31dcde4b943gryzor GNU General Public License for more details.
112fd4f283bc07af680c305545d6e31dcde4b943gryzor You should have received a copy of the GNU General Public License
112fd4f283bc07af680c305545d6e31dcde4b943gryzor along with this program. If not, see <http://www.gnu.org/licenses/>.
112fd4f283bc07af680c305545d6e31dcde4b943gryzor smart = dp_opt_get_int(opts, SDAP_SUDO_SMART_REFRESH_INTERVAL);
112fd4f283bc07af680c305545d6e31dcde4b943gryzor full = dp_opt_get_int(opts, SDAP_SUDO_FULL_REFRESH_INTERVAL);
112fd4f283bc07af680c305545d6e31dcde4b943gryzor /* We don't allow both types to be disabled. At least smart refresh
112fd4f283bc07af680c305545d6e31dcde4b943gryzor * needs to be enabled. In this case smart refresh will catch up new
112fd4f283bc07af680c305545d6e31dcde4b943gryzor * and modified rules and deleted rules are caught when expired. */
112fd4f283bc07af680c305545d6e31dcde4b943gryzor smart = opts[SDAP_SUDO_SMART_REFRESH_INTERVAL].def_val.number;
112fd4f283bc07af680c305545d6e31dcde4b943gryzor DEBUG(SSSDBG_CONF_SETTINGS, "At least smart refresh needs to be "
112fd4f283bc07af680c305545d6e31dcde4b943gryzor "enabled. Setting smart refresh interval to default value "
112fd4f283bc07af680c305545d6e31dcde4b943gryzor /* In this case it does not make any sense to run smart refresh. */
112fd4f283bc07af680c305545d6e31dcde4b943gryzor DEBUG(SSSDBG_CONF_SETTINGS, "Smart refresh interval has to be lower "
112fd4f283bc07af680c305545d6e31dcde4b943gryzor "than full refresh interval. Periodical smart refresh will be "
112fd4f283bc07af680c305545d6e31dcde4b943gryzor "disabled.\n");
112fd4f283bc07af680c305545d6e31dcde4b943gryzor ret = sysdb_sudo_get_last_full_refresh(be_ctx->domain, &last_refresh);
112fd4f283bc07af680c305545d6e31dcde4b943gryzor DEBUG(SSSDBG_MINOR_FAILURE, "Unable to obtain time of last full "
112fd4f283bc07af680c305545d6e31dcde4b943gryzor "refresh. Assuming none was performed so far.\n");
112fd4f283bc07af680c305545d6e31dcde4b943gryzor /* If this is the first startup, we need to kick off an refresh
112fd4f283bc07af680c305545d6e31dcde4b943gryzor * immediately, to close a window where clients requesting sudo
112fd4f283bc07af680c305545d6e31dcde4b943gryzor * information won't get an immediate reply with no entries */
112fd4f283bc07af680c305545d6e31dcde4b943gryzor /* At least one update has previously run, so clients will get cached
112fd4f283bc07af680c305545d6e31dcde4b943gryzor * data. We will delay the refresh so we don't slow down the startup
112fd4f283bc07af680c305545d6e31dcde4b943gryzor * process if this is happening during system boot. */
112fd4f283bc07af680c305545d6e31dcde4b943gryzor /* Full refresh.
112fd4f283bc07af680c305545d6e31dcde4b943gryzor * Disable when offline and run immediately when SSSD goes back online.
112fd4f283bc07af680c305545d6e31dcde4b943gryzor * Since we have periodical online check we don't have to run this task
112fd4f283bc07af680c305545d6e31dcde4b943gryzor * when offline. */
112fd4f283bc07af680c305545d6e31dcde4b943gryzor ret = be_ptask_create(be_ctx, be_ctx, full, delay, 0, 0, full,
112fd4f283bc07af680c305545d6e31dcde4b943gryzor DEBUG(SSSDBG_CRIT_FAILURE, "Unable to setup full refresh ptask "
112fd4f283bc07af680c305545d6e31dcde4b943gryzor /* Smart refresh.
112fd4f283bc07af680c305545d6e31dcde4b943gryzor * Disable when offline and reschedule normally when SSSD goes back online.
if (smart > 0) {
return ret;
return EOK;
char *usn)
unsigned int usn_number;