child_common.c revision 1c48b5a62f73234ed26bb20f0ab345ab61cda0ab
/*
SSSD
Common helper functions to be used in child processes
Authors:
Sumit Bose <sbose@redhat.com>
Copyright (C) 2009 Red Hat
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 <fcntl.h>
#include <tevent.h>
#include <errno.h>
#include "util/find_uid.h"
#include "providers/child_common.h"
/* Async communication with the child process via a pipe */
struct write_pipe_state {
int fd;
};
struct tevent_context *ev,
{
struct tevent_req *req;
struct write_pipe_state *state;
goto fail;
}
return req;
fail:
return NULL;
}
{
struct write_pipe_state);
if (flags & TEVENT_FD_READ) {
" this should not happen.\n"));
return;
}
if (size == -1) {
return;
} else if (size >= 0) {
return;
}
} else {
return;
}
return;
}
}
{
return EOK;
}
struct read_pipe_state {
int fd;
};
{
struct tevent_req *req;
struct read_pipe_state *state;
goto fail;
}
return req;
fail:
return NULL;
}
{
struct read_pipe_state);
if (flags & TEVENT_FD_WRITE) {
" this should not happen.\n"));
return;
}
if (size == -1) {
return;
}
return;
} else if (size > 0) {
return;
}
} else if (size == 0) {
return;
} else {
return;
}
}
{
struct read_pipe_state *state;
return EOK;
}
/* The pipes to communicate with the child must be nonblocking */
void fd_nonblocking(int fd)
{
int flags;
int ret;
if (flags == -1) {
return;
}
}
return;
}
{
int ret;
int child_status;
do {
errno = 0;
if (ret == -1) {
} else if (ret == 0) {
} else {
if (WEXITSTATUS(child_status) != 0) {
child_status));
} else {
}
}
--count;
} while (count < 0);
return;
}
int child_debug_fd,
const char *binary,
char ***_argv)
{
char ** argv;
/* Save the current state in case an interrupt changes it */
bool child_debug_to_file = debug_to_file;
if (child_debug_to_file) argc++;
if (!child_debug_timestamps) argc++;
/* program name, debug_level,
* debug_to_file, debug_timestamps
* and NULL */
return ENOMEM;
}
goto fail;
}
if (child_debug_to_file) {
goto fail;
}
}
if (!child_debug_timestamps) {
goto fail;
}
}
goto fail;
}
if (argc != 0) {
goto fail;
}
return EOK;
fail:
return ret;
}
int *pipefd_to_child, int *pipefd_from_child,
{
int ret;
char **argv;
if (ret == -1) {
return err;
}
close(pipefd_from_child[0]);
if (ret == -1) {
return err;
}
return ret;
}
if (ret == -1) {
return err;
}
return EOK;
}
{
int ret;
if (readfd != -1) {
}
}
if (writefd != -1) {
}
}
}