~ubuntu-branches/ubuntu/saucy/sssd/saucy

« back to all changes in this revision

Viewing changes to server/providers/child_common.h

  • Committer: Stéphane Graber
  • Date: 2011-06-15 16:23:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: stgraber@ubuntu.com-20110615162314-rbhoppnpaxfqo5q7
Merge 1.5.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    SSSD
3
 
 
4
 
    Common helper functions to be used in child processes
5
 
 
6
 
    Authors:
7
 
        Sumit Bose   <sbose@redhat.com>
8
 
 
9
 
    Copyright (C) 2009 Red Hat
10
 
 
11
 
    This program is free software; you can redistribute it and/or modify
12
 
    it under the terms of the GNU General Public License as published by
13
 
    the Free Software Foundation; either version 3 of the License, or
14
 
    (at your option) any later version.
15
 
 
16
 
    This program is distributed in the hope that it will be useful,
17
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 
    GNU General Public License for more details.
20
 
 
21
 
    You should have received a copy of the GNU General Public License
22
 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 
*/
24
 
 
25
 
#ifndef __CHILD_COMMON_H__
26
 
#define __CHILD_COMMON_H__
27
 
 
28
 
#include <errno.h>
29
 
#include <sys/types.h>
30
 
#include <sys/wait.h>
31
 
#include <tevent.h>
32
 
 
33
 
#include "util/util.h"
34
 
 
35
 
#define IN_BUF_SIZE         512
36
 
#define MAX_CHILD_MSG_SIZE  255
37
 
 
38
 
struct response {
39
 
    size_t max_size;
40
 
    size_t size;
41
 
    uint8_t *buf;
42
 
};
43
 
 
44
 
struct io_buffer {
45
 
    uint8_t *data;
46
 
    size_t size;
47
 
};
48
 
 
49
 
/* Async communication with the child process via a pipe */
50
 
struct tevent_req *write_pipe_send(TALLOC_CTX *mem_ctx,
51
 
                                   struct tevent_context *ev,
52
 
                                   uint8_t *buf, size_t len, int fd);
53
 
int write_pipe_recv(struct tevent_req *req);
54
 
 
55
 
struct tevent_req *read_pipe_send(TALLOC_CTX *mem_ctx,
56
 
                                  struct tevent_context *ev, int fd);
57
 
int read_pipe_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
58
 
                   uint8_t **buf, ssize_t *len);
59
 
 
60
 
/* The pipes to communicate with the child must be nonblocking */
61
 
void fd_nonblocking(int fd);
62
 
 
63
 
void child_sig_handler(struct tevent_context *ev,
64
 
                       struct tevent_signal *sige, int signum,
65
 
                       int count, void *__siginfo, void *pvt);
66
 
 
67
 
errno_t exec_child(TALLOC_CTX *mem_ctx,
68
 
                   int *pipefd_to_child, int *pipefd_from_child,
69
 
                   const char *binary, int debug_fd);
70
 
 
71
 
void child_cleanup(int readfd, int writefd);
72
 
 
73
 
#endif /* __CHILD_COMMON_H__ */