|
Crinit -- Configurable Rootfs Init
|
Implementation of type- and target-specific handler functions for configuration parsing. More...
#include "confhdl.h"#include <ctype.h>#include <grp.h>#include <pwd.h>#include <stdint.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>#include "common.h"#include "confconv.h"#include "globopt.h"#include "lexers.h"#include "logio.h"
Macros | |
| #define | crinitCfgHandlerTypeCheck(t) |
Functions | |
| static int | crinitCfgHandlerSetTaskOptFromStr (crinitTaskOpts_t *tgt, crinitTaskOpts_t opt, const char *val) |
| static void * | crinitCfgHandlerManageArrayMem (void *dynArr, size_t elementSize, size_t curSize, size_t reqSize) |
| static bool | crinitDirExists (const char *path) |
| static bool | crinitFileIsExecutable (const char *path) |
| static bool | crinitUsernameToUid (const char *name, uid_t *uid) |
| static bool | crinitUidToUsername (uid_t uid, char **name) |
| static bool | crinitGroupnameToGid (const char *name, gid_t *gid) |
| static bool | crinitGidToGroupname (gid_t gid, char **name) |
| int | crinitCfgCmdHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgStopCmdHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgDepHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgPrvHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgEnvHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgFilterHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgIoRedirHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgNameHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgRespHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgRespRetHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitTaskIncludeHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgUserHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgGroupHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgDebugHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgInclSuffixHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgInclDirHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgShdGpHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgTaskSuffixHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgTaskDirHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgTaskDirSlHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgTasksHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgSyslogHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgElosHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgElosServerHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgElosPortHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgElosEventPollIntervalHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgLauncherCmdHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgSigKeyDirHandler (void *tgt, const char *val, crinitConfigType_t type) |
| int | crinitCfgSignaturesHandler (void *tgt, const char *val, crinitConfigType_t type) |
Implementation of type- and target-specific handler functions for configuration parsing.
| #define crinitCfgHandlerTypeCheck | ( | t | ) |
Macro to assert that the given crinitConfigType_t in a crinitConfigHandler_t has a specific value.
| t | The target value of the parameter type. If unequal to the value given to the encompassing function, the function will print an error and return -1. |
| int crinitCfgCmdHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for COMMAND config directives. See crinitConfigHandler_t.
| int crinitCfgDebugHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for DEBUG config directives. See crinitConfigHandler_t.
| int crinitCfgDepHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for DEPENDS config directives. See crinitConfigHandler_t.
| int crinitCfgElosEventPollIntervalHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for ELOS_EVENT_POLL_INTERVAL config directive. See crinitConfigHandler_t.
| int crinitCfgElosHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for USE_ELOS config directives. See crinitConfigHandler_t.
| int crinitCfgElosPortHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for ELOS_PORT config directives. See crinitConfigHandler_t.
| int crinitCfgElosServerHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for ELOS_SERVER config directives. See crinitConfigHandler_t.
| int crinitCfgEnvHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for ENV_SET config directives. See crinitConfigHandler_t.
| int crinitCfgFilterHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for FILTER_DEFINE config directives. See crinitConfigHandler_t.
| int crinitCfgGroupHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for GROUP config directives. See crinitConfigHandler_t
|
inlinestatic |
(Re-)allocate memory for generic arrays.
Given current size of an array and required size, the function will allocate/grow the array. Shrinking is unsupported and will lead to an error being returned. Initializes newly allocated memory to 0.
| dynArr | The array to reallocate or NULL if we want a new array. |
| elementSize | Size of a single element in the array. |
| curSize | Current number of elements in the array. |
| reqSize | Required number of elements in the array. |
|
inlinestatic |
Helper function to set a bitmask value in crinitTask_t::opts.
| tgt | Direct pointer to the crinitTaskOpts_t inside an crinitTask_t which shall be modified. |
| opt | Bitmask of the task option to be set, one of CRINIT_TASK_OPT_* |
| val | The string value indicating if the bit should be set or unset. Uses crinitConfConvToBool(). |
| int crinitCfgInclDirHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for INCLUDEDIR config directives. See crinitConfigHandler_t.
| int crinitCfgInclSuffixHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for INCLUDE_SUFFIX config directives. See crinitConfigHandler_t.
| int crinitCfgIoRedirHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for IO_REDIRECT config directives. See crinitConfigHandler_t.
| int crinitCfgLauncherCmdHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for LAUNCHER_CMD config directive. See crinitConfigHandler_t.
| int crinitCfgNameHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for NAME config directives. See crinitConfigHandler_t.
| int crinitCfgPrvHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for PROVIDES config directives. See crinitConfigHandler_t.
| int crinitCfgRespHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for RESPAWN config directives. See crinitConfigHandler_t.
| int crinitCfgRespRetHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for RESPAWN_RETRIES config directives. See crinitConfigHandler_t.
| int crinitCfgShdGpHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for SHUTDOWN_GRACE_PERIOD_US config directives. See crinitConfigHandler_t.
| int crinitCfgSigKeyDirHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for crinit.sigkeydir Kernel command line setting. See crinitConfigHandler_t.
| int crinitCfgSignaturesHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for crinit.signatures Kernel command line setting. See crinitConfigHandler_t.
| int crinitCfgStopCmdHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for STOP_COMMAND config directives. See crinitConfigHandler_t.
| int crinitCfgSyslogHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for USE_SYSLOG config directives. See crinitConfigHandler_t.
| int crinitCfgTaskDirHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for TASKDIR config directives. See crinitConfigHandler_t.
| int crinitCfgTaskDirSlHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for TASKDIR_FOLLOW_SYMLINKS config directives. See crinitConfigHandler_t.
| int crinitCfgTasksHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for TASKS config directives. See crinitConfigHandler_t.
| int crinitCfgTaskSuffixHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for TASK_SUFFIX config directives. See crinitConfigHandler_t.
| int crinitCfgUserHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for USER config directives. See crinitConfigHandler_t
|
static |
Check if a path exists, is accessible, and a directory.
Uses stat() with S_ISDIR().
| path | The path to check. |
|
static |
Check if a path exists, is accessible, a file and is executable by owner.
Uses stat().
| path | The path to check. |
|
static |
Check if given GID exists and convert to groupname.
| gid | GID to query |
| name | Pointer to result. Caller must free the pointer allocated by the function. |
|
static |
Check if given groupname exists and convert into numeric ID.
| name | groupname |
| gid | Pointer to gid_t object |
| int crinitTaskIncludeHandler | ( | void * | tgt, |
| const char * | val, | ||
| crinitConfigType_t | type | ||
| ) |
Handler for INCLUDE config directives. See crinitConfigHandler_t.
|
static |
Check if given UID exists and convert to username.
| uid | UID to query |
| name | Pointer to result. Caller must free the pointer allocated by the function. |
|
static |
Check if given username exists and convert into numeric ID.
| name | Username |
| uid | Pointer to uid_t object |