shadow/lib/nscd.c
nekral-guest 39e5c0a1ab Fix some compilation warnings:
* src/login.c: "dereferencing type-punned pointer will break
   strict-aliasing rules", add a variable indirection: ptr_pam_user.
 * lib/commonio.c: do not initialize the sb stat structure.
 * lib/pwio.c, lib/shadowio.c, lib/sgroupio.c, lib/groupio.c:
   initialize the security context if WITH_SELINUX.
 * lib/nscd.c: The service argument is not const (used in the exec*
   parameters). This matches with the prototype definition.
 * src/groupmems.c: Avoid ++i when i is also used in the same line.
 * src/newusers.c: i is positive every time it is compared. Add
   cast to unsigned int.
 * src/nologin.c: Use a main() prototype with no arguments.
 * libmisc/getdate.y: Initialize the type and value fields of the
   terminating entry for each TABLE.
 * libmisc/tz.c: Use "TZ=CST6CDT" as the default timezone.
2007-11-19 20:25:36 +00:00

51 lines
1.0 KiB
C

/* Author: Peter Vrabec <pvrabec@redhat.com> */
/* because of TEMP_FAILURE_RETRY */
#define _GNU_SOURCE
#include <features.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <spawn.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/types.h>
/*
* nscd_flush_cache - flush specified service buffer in nscd cache
*/
int nscd_flush_cache (char *service)
{
pid_t pid, termpid;
int err, status;
char *spawnedArgs[] = {"/usr/sbin/nscd", "nscd", "-i", service, NULL};
char *spawnedEnv[] = {NULL};
/* spawn process */
if( (err=posix_spawn(&pid, spawnedArgs[0], NULL, NULL,
spawnedArgs, spawnedEnv)) !=0 )
{
fprintf(stderr, "posix_spawn() error=%d\n", err);
return -1;
}
/* Wait for the spawned process to exit */
termpid = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
if (termpid == -1)
{
perror("waitpid");
return -1;
}
else if (termpid != pid)
{
fprintf(stderr, "waitpid returned %ld != %ld\n",
(long int) termpid, (long int) pid);
return -1;
}
return 0;
}