tools_mc_util.c revision b08bcc387ad99b9c408183960c127dc77975b6ff
/*
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 "tools/tools_util.h"
#include "util/mmap_cache.h"
#include "sss_client/sss_cli.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;
}
{
int mc_fd = -1;
useconds_t t = 50000;
int retries = 2;
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. "
"Will be unlinked later by sssd_nss.\n",
}
}
}
return ret;
}
static int clear_fastcache(bool *sssd_nss_is_off)
{
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;
}
{
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;
}
}
return EOK;
}
enum sss_tools_ent {
};
{
enum sss_cli_command cmd;
struct sss_cli_req_data rd;
enum nss_status nret;
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 *name)
{
struct ldb_message *msg;
struct ldb_message_element *el;
const char *attrs[] = { SYSDB_MEMBEROF,
NULL };
size_t i;
char *parent_name;
"Cannot refresh group %s from memory cache\n", name);
/* try to carry on */
}
if (ret) {
return ret;
}
return EOK;
}
/* This group is nested. We need to invalidate all its parents, too */
for (i=0; i < el->num_values; i++) {
&parent_name);
continue;
}
"Cannot refresh group %s from memory cache\n", name);
/* try to carry on */
}
}
return EOK;
}
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;
}
}
}