/*
SSSD
tools_mc_util - interface to the memcache for userspace tools
Copyright (C) Red Hat 2013
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <talloc.h>
#include <fcntl.h>
#include <signal.h>
#include "tools/tools_util.h"
#include "util/mmap_cache.h"
#include "util/sss_cli_cmd.h"
#include "sss_client/sss_cli.h"
#include "tools/common/sss_process.h"
/* This is a copy of sss_mc_set_recycled present in
* src/responder/nss/nsssrv_mmap_cache.c. If you modify this function,
* you should modify the original function too. */
{
struct sss_mc_header h;
if (pos == -1) {
/* What do we do now? */
return errno;
}
errno = 0;
if (written == -1) {
return errno;
}
/* Write error */
return EIO;
}
return EOK;
}
{
useconds_t t = 50000;
if (!mc_filename) {
return EINVAL;
}
if (mc_fd == -1) {
"does not exist.\n", mc_filename);
return EOK;
} else {
return ret;
}
}
"File %s already locked by someone else.\n", mc_filename);
goto done;
goto done;
}
/* Mark the mc file as recycled. */
"as recycled.\n", mc_filename);
goto done;
}
done:
if (mc_fd != -1) {
/* Closing the file also releases the lock */
/* Only unlink the file if invalidation was successful */
if (pret == -1) {
"Failed to unlink file %s, %d [%s]. "
"Will be unlinked later by sssd_nss.\n",
}
}
}
return ret;
}
{
int ret;
*sssd_nss_is_off = false;
return EOK;
} else {
return ret;
}
}
*sssd_nss_is_off = false;
return EOK;
} else {
return ret;
}
}
*sssd_nss_is_off = false;
return EOK;
} else {
return ret;
}
}
*sssd_nss_is_off = true;
return EOK;
}
{
int ret;
for (size_t i = 0; i < steps_count; ++i) {
if (ret == -1) {
/* nss responder has already invalidated memory caches */
return EOK;
}
}
}
return EAGAIN;
}
{
bool sssd_nss_is_off = false;
return EIO;
}
if (!sssd_nss_is_off) {
/* sssd_nss is running -> signal monitor to invalidate fastcache */
if (clear_mc_flag == NULL) {
"Failed to create clear_mc_flag file. "
"Memory cache will not be cleared.\n");
return EIO;
}
if (ret != 0) {
"Unable to close file descriptor: %s\n",
return EIO;
}
"Failed to send SIGHUP to monitor.\n");
return EIO;
}
ERROR("The fast memory caches was not invalidated by NSS "
"responder.\n");
}
}
return EOK;
}
enum sss_tools_ent {
};
{
cmd = SSS_CLI_NULL;
switch (ent) {
case SSS_TOOLS_USER:
break;
case SSS_TOOLS_GROUP:
break;
}
if (cmd == SSS_CLI_NULL) {
return EINVAL;
}
sss_nss_lock();
return EIO;
}
return EOK;
}
{
}
{
}
const char *shortname)
{
NULL };
size_t i;
char *parent_internal_name;
char *parent_outname;
char *internal_name;
return ENOMEM;
}
if (internal_name == NULL) {
goto done;
}
"Cannot refresh group %s from memory cache\n", shortname);
/* try to carry on */
}
&msg);
if (ret) {
goto done;
}
goto done;
}
/* This group is nested. We need to invalidate all its parents, too */
for (i=0; i < el->num_values; i++) {
continue;
}
if (parent_outname == NULL) {
goto done;
}
"Cannot refresh group %s from memory cache\n", parent_outname);
/* try to carry on */
}
}
done:
return ret;
}
char **groupnames)
{
int i;
bool failed = false;
if (!groupnames) return EOK;
for (i = 0; groupnames[i]; i++) {
"Cannot refresh group %s from memory cache\n",
groupnames[i]);
failed = true;
continue;
}
}
}