tools_mc_util.c revision 82dc11348718bf8e2ff07da696f91f6703293c24
/*
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"
{
struct sss_mc_header h;
int ret;
if (pos == -1) {
/* What do we do now ? */
return errno;
}
errno = 0;
if (ret == -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 succesful */
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 = 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;
}