cfengine  3.15.4
About: CFEngine is a configuration management system for configuring and maintaining Unix-like computers (using an own high level policy language). Community version.
  Fossies Dox: cfengine-3.15.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pipes_unix.c File Reference
#include <pipes.h>
#include <mutex.h>
#include <global_mutex.h>
#include <exec_tools.h>
#include <rlist.h>
#include <policy.h>
#include <eval_context.h>
#include <file_lib.h>
#include <signals.h>
#include <string_lib.h>
Include dependency graph for pipes_unix.c:

Go to the source code of this file.

Data Structures

struct  IOPipe
 

Functions

static bool CfSetuid (uid_t uid, gid_t gid)
 
static int cf_pwait (pid_t pid)
 
static void ChildrenFDInit ()
 
static void ChildrenFDUnsafeClose ()
 
static void ChildrenFDSet (int fd, pid_t pid)
 
static pid_t GenericCreatePipeAndFork (IOPipe *pipes)
 
static pid_t CreatePipeAndFork (const char *type, int *pd)
 
static pid_t CreatePipesAndFork (const char *type, int *pd, int *pdb)
 
IOData cf_popen_full_duplex (const char *command, bool capture_stderr, bool require_full_path)
 
FILE * cf_popen (const char *command, const char *type, bool capture_stderr)
 
FILE * cf_popensetuid (const char *command, const char *type, uid_t uid, gid_t gid, char *chdirv, char *chrootv, int background)
 
FILE * cf_popen_sh (const char *command, const char *type)
 
FILE * cf_popen_shsetuid (const char *command, const char *type, uid_t uid, gid_t gid, char *chdirv, char *chrootv, int background)
 
void cf_pclose_nowait (FILE *pp)
 
int cf_pclose (FILE *pp)
 
int cf_pclose_full_duplex_side (int fd)
 
int cf_pclose_full_duplex (IOData *data)
 
bool PipeToPid (pid_t *pid, FILE *pp)
 
int PipeIsReadWriteReady (const IOData *io, int timeout_sec)
 

Variables

static pid_t * CHILDREN = NULL
 
static int MAX_FD = 2048
 

Function Documentation

◆ cf_pclose()

◆ cf_pclose_full_duplex()

int cf_pclose_full_duplex ( IOData data)

◆ cf_pclose_full_duplex_side()

int cf_pclose_full_duplex_side ( int  fd)

Definition at line 852 of file pipes_unix.c.

References cft_count, CHILDREN, Log(), LOG_LEVEL_ERR, MAX_FD, NULL, ThreadLock, and ThreadUnlock.

Referenced by PipeWrite().

◆ cf_pclose_nowait()

void cf_pclose_nowait ( FILE *  pp)

Closes the pipe without waiting the child.

Parameters
pppipe to the child process

Definition at line 798 of file pipes_unix.c.

References GetErrorStr(), Log(), and LOG_LEVEL_ERR.

Referenced by RepairExec().

◆ cf_popen()

◆ cf_popen_full_duplex()

IOData cf_popen_full_duplex ( const char *  command,
bool  capture_stderr,
bool  require_full_path 
)

◆ cf_popen_sh()

◆ cf_popen_shsetuid()

FILE* cf_popen_shsetuid ( const char *  command,
const char *  type,
uid_t  uid,
gid_t  gid,
char *  chdirv,
char *  chrootv,
int  background 
)

◆ cf_popensetuid()

FILE* cf_popensetuid ( const char *  command,
const char *  type,
uid_t  uid,
gid_t  gid,
char *  chdirv,
char *  chrootv,
int  background 
)

◆ cf_pwait()

◆ CfSetuid()

static bool CfSetuid ( uid_t  uid,
gid_t  gid 
)
static

Definition at line 949 of file pipes_unix.c.

References GetErrorStr(), Log(), LOG_LEVEL_ERR, LOG_LEVEL_VERBOSE, and NULL.

Referenced by cf_popen_shsetuid(), and cf_popensetuid().

◆ ChildrenFDInit()

static void ChildrenFDInit ( )
static

Definition at line 45 of file pipes_unix.c.

References cft_count, CHILDREN, MAX_FD, NULL, ThreadLock, ThreadUnlock, and xcalloc().

Referenced by GenericCreatePipeAndFork().

◆ ChildrenFDSet()

static void ChildrenFDSet ( int  fd,
pid_t  pid 
)
static

◆ ChildrenFDUnsafeClose()

static void ChildrenFDUnsafeClose ( )
static

Definition at line 60 of file pipes_unix.c.

References CHILDREN, MAX_FD, and NULL.

Referenced by cf_popen(), cf_popen_full_duplex(), cf_popen_sh(), cf_popen_shsetuid(), and cf_popensetuid().

◆ CreatePipeAndFork()

static pid_t CreatePipeAndFork ( const char *  type,
int *  pd 
)
static

◆ CreatePipesAndFork()

static pid_t CreatePipesAndFork ( const char *  type,
int *  pd,
int *  pdb 
)
static

Definition at line 224 of file pipes_unix.c.

References GenericCreatePipeAndFork(), IOPipe::pipe_desc, and IOPipe::type.

Referenced by cf_popen_full_duplex().

◆ GenericCreatePipeAndFork()

static pid_t GenericCreatePipeAndFork ( IOPipe pipes)
static

Definition at line 129 of file pipes_unix.c.

References ALARM_PID, ChildrenFDInit(), errno, NULL, and PipeTypeIsOk().

Referenced by CreatePipeAndFork(), and CreatePipesAndFork().

◆ PipeIsReadWriteReady()

int PipeIsReadWriteReady ( const IOData io,
int  timeout_sec 
)

Definition at line 995 of file pipes_unix.c.

References GetErrorStr(), Log(), LOG_LEVEL_DEBUG, LOG_LEVEL_VERBOSE, NULL, IOData::read_fd, and UnexpectedError.

Referenced by PipeReadData().

◆ PipeToPid()

bool PipeToPid ( pid_t *  pid,
FILE *  pp 
)

Definition at line 930 of file pipes_unix.c.

References cft_count, CHILDREN, NULL, ThreadLock, and ThreadUnlock.

Referenced by LocalExec().

Variable Documentation

◆ CHILDREN

◆ MAX_FD