Crinit -- Configurable Rootfs Init
Loading...
Searching...
No Matches
confparse.h File Reference

(/usr/bin/git 2025-03-14, commit: 62abb16)

Header related to the Config Parser. More...

#include <stdbool.h>
#include <sys/types.h>
#include "fseries.h"
Include dependency graph for confparse.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  crinitConfKvList_t
 

Macros

#define CRINIT_CONFIG_KEYSTR_TASKS   "TASKS"
 
#define CRINIT_CONFIG_KEYSTR_INCLUDES   "INCLUDES"
 
#define CRINIT_CONFIG_KEYSTR_TASKDIR_SYMLINKS   "TASKDIR_FOLLOW_SYMLINKS"
 
#define CRINIT_CONFIG_KEYSTR_DEBUG   "DEBUG"
 
#define CRINIT_CONFIG_KEYSTR_TASKDIR   "TASKDIR"
 
#define CRINIT_CONFIG_KEYSTR_INCLDIR   "INCLUDEDIR"
 
#define CRINIT_CONFIG_KEYSTR_SHDGRACEP   "SHUTDOWN_GRACE_PERIOD_US"
 
#define CRINIT_CONFIG_KEYSTR_USE_SYSLOG   "USE_SYSLOG"
 
#define CRINIT_CONFIG_KEYSTR_USE_ELOS   "USE_ELOS"
 
#define CRINIT_CONFIG_KEYSTR_ELOS_SERVER   "ELOS_SERVER"
 
#define CRINIT_CONFIG_KEYSTR_ELOS_PORT   "ELOS_PORT"
 
#define CRINIT_CONFIG_KEYSTR_ELOS_EVENT_POLL_INTERVAL   "ELOS_EVENT_POLL_INTERVAL"
 
#define CRINIT_CONFIG_KEYSTR_LAUNCHER_CMD   "LAUNCHER_CMD"
 
#define CRINIT_CONFIG_KEYSTR_INCL_SUFFIX   "INCLUDE_SUFFIX"
 
#define CRINIT_CONFIG_KEYSTR_TASK_FILE_SUFFIX   "TASK_FILE_SUFFIX"
 
#define CRINIT_CONFIG_KEYSTR_SIGKEYDIR   "sigkeydir"
 
#define CRINIT_CONFIG_KEYSTR_SIGNATURES   "signatures"
 
#define CRINIT_CONFIG_KEYSTR_COMMAND   "COMMAND"
 
#define CRINIT_CONFIG_KEYSTR_DEPENDS   "DEPENDS"
 
#define CRINIT_CONFIG_KEYSTR_ENV_SET   "ENV_SET"
 
#define CRINIT_CONFIG_KEYSTR_FILTER_DEFINE   "FILTER_DEFINE"
 
#define CRINIT_CONFIG_KEYSTR_INCLUDE   "INCLUDE"
 
#define CRINIT_CONFIG_KEYSTR_IOREDIR   "IO_REDIRECT"
 
#define CRINIT_CONFIG_KEYSTR_NAME   "NAME"
 
#define CRINIT_CONFIG_KEYSTR_PROVIDES   "PROVIDES"
 
#define CRINIT_CONFIG_KEYSTR_RESPAWN   "RESPAWN"
 
#define CRINIT_CONFIG_KEYSTR_RESPAWN_RETRIES   "RESPAWN_RETRIES"
 
#define CRINIT_CONFIG_KEYSTR_STOP_COMMAND   "STOP_COMMAND"
 
#define CRINIT_CONFIG_KEYSTR_USER   "USER"
 
#define CRINIT_CONFIG_KEYSTR_GROUP   "GROUP"
 
#define CRINIT_CONFIG_DEFAULT_TASK_FILE_SUFFIX   ".crinit"
 
#define CRINIT_CONFIG_KEYSTR_INCL_FILE_SUFFIX   "INCL_FILE_SUFFIX"
 
#define CRINIT_CONFIG_DEFAULT_INCL_FILE_SUFFIX   ".crincl"
 
#define CRINIT_CONFIG_DEFAULT_DEBUG   false
 
#define CRINIT_CONFIG_DEFAULT_TASKDIR_SYMLINKS   true
 
#define CRINIT_CONFIG_DEFAULT_LAUNCHER_CMD   "/usr/bin/crinit-launch"
 
#define CRINIT_CONFIG_DEFAULT_SHDGRACEP   100000uLL
 
#define CRINIT_CONFIG_DEFAULT_USE_SYSLOG   false
 
#define CRINIT_CONFIG_DEFAULT_USE_ELOS   false
 
#define CRINIT_CONFIG_DEFAULT_ELOS_SERVER   "127.0.0.1"
 
#define CRINIT_CONFIG_DEFAULT_ELOS_PORT   54321
 
#define CRINIT_CONFIG_DEFAULT_INCL_SUFFIX   ".crincl"
 
#define CRINIT_CONFIG_DEFAULT_SIGNATURES   false
 
#define CRINIT_CONFIG_STDOUT_NAME   "STDOUT"
 
#define CRINIT_CONFIG_STDERR_NAME   "STDERR"
 
#define CRINIT_CONFIG_STDIN_NAME   "STDIN"
 

Typedefs

typedef enum crinitConfigs_t crinitConfigs_t
 
typedef enum crinitConfigType_t crinitConfigType_t
 
typedef struct crinitConfKvList_t crinitConfKvList_t
 

Enumerations

enum  crinitConfigs_t {
  CRINIT_CONFIG_COMMAND = 0 , CRINIT_CONFIG_DEBUG , CRINIT_CONFIG_DEPENDS , CRINIT_CONFIG_ELOS_EVENT_POLL_INTERVAL ,
  CRINIT_CONFIG_ELOS_PORT , CRINIT_CONFIG_ELOS_SERVER , CRINIT_CONFIG_ENV_SET , CRINIT_CONFIG_FILTER_DEFINE ,
  CRINIT_CONFIG_GROUP , CRINIT_CONFIG_INCLUDE , CRINIT_CONFIG_INCLUDE_SUFFIX , CRINIT_CONFIG_INCLUDEDIR ,
  CRINIT_CONFIG_IOREDIR , CRINIT_CONFIG_NAME , CRINIT_CONFIG_PROVIDES , CRINIT_CONFIG_RESPAWN ,
  CRINIT_CONFIG_RESPAWN_RETRIES , CRINIT_CONFIG_SHDGRACEP , CRINIT_CONFIG_SIGKEYDIR , CRINIT_CONFIG_SIGNATURES ,
  CRINIT_CONFIG_STOP_COMMAND , CRINIT_CONFIG_TASK_FILE_SUFFIX , CRINIT_CONFIG_TASKDIR , CRINIT_CONFIG_TASKDIR_FOLLOW_SYMLINKS ,
  CRINIT_CONFIG_TASKS , CRINIT_CONFIG_USE_SYSLOG , CRINIT_CONFIG_USE_ELOS , CRINIT_CONFIG_USER ,
  CRINIT_CONFIG_LAUNCHER_CMD , CRINIT_CONFIGS_SIZE
}
 
enum  crinitConfigType_t { CRINIT_CONFIG_TYPE_SERIES , CRINIT_CONFIG_TYPE_TASK , CRINIT_CONFIG_TYPE_KCMDLINE }
 

Functions

int crinitParseConf (crinitConfKvList_t **confList, const char *filename)
 
void crinitFreeConfList (crinitConfKvList_t *confList)
 
void crinitFreeArgvArray (char **inArgv)
 
int crinitLoadSeriesConf (const char *filename)
 
int crinitLoadTasks (crinitFileSeries_t *series)
 

Detailed Description

Header related to the Config Parser.

Macro Definition Documentation

◆ CRINIT_CONFIG_DEFAULT_DEBUG

#define CRINIT_CONFIG_DEFAULT_DEBUG   false

Default value for DEBUG global option.

◆ CRINIT_CONFIG_DEFAULT_ELOS_PORT

#define CRINIT_CONFIG_DEFAULT_ELOS_PORT   54321

Default value for ELOS_SERVER global option.

◆ CRINIT_CONFIG_DEFAULT_ELOS_SERVER

#define CRINIT_CONFIG_DEFAULT_ELOS_SERVER   "127.0.0.1"

Default value for ELOS_SERVER global option.

◆ CRINIT_CONFIG_DEFAULT_INCL_FILE_SUFFIX

#define CRINIT_CONFIG_DEFAULT_INCL_FILE_SUFFIX   ".crincl"

Default filename extension of task include files.

◆ CRINIT_CONFIG_DEFAULT_INCL_SUFFIX

#define CRINIT_CONFIG_DEFAULT_INCL_SUFFIX   ".crincl"

Default filename extension of include files.

◆ CRINIT_CONFIG_DEFAULT_LAUNCHER_CMD

#define CRINIT_CONFIG_DEFAULT_LAUNCHER_CMD   "/usr/bin/crinit-launch"

◆ CRINIT_CONFIG_DEFAULT_SHDGRACEP

#define CRINIT_CONFIG_DEFAULT_SHDGRACEP   100000uLL

Default value for SHUTDOWN_GRACE_PERIOD_US global option

◆ CRINIT_CONFIG_DEFAULT_SIGNATURES

#define CRINIT_CONFIG_DEFAULT_SIGNATURES   false

◆ CRINIT_CONFIG_DEFAULT_TASK_FILE_SUFFIX

#define CRINIT_CONFIG_DEFAULT_TASK_FILE_SUFFIX   ".crinit"

Default filename extension of task files.

◆ CRINIT_CONFIG_DEFAULT_TASKDIR_SYMLINKS

#define CRINIT_CONFIG_DEFAULT_TASKDIR_SYMLINKS   true

Default value for the TASKDIR_FOLLOW_SYMLINKS global option.

◆ CRINIT_CONFIG_DEFAULT_USE_ELOS

#define CRINIT_CONFIG_DEFAULT_USE_ELOS   false

Default value for USE_ELOS global option.

◆ CRINIT_CONFIG_DEFAULT_USE_SYSLOG

#define CRINIT_CONFIG_DEFAULT_USE_SYSLOG   false

Default value for USE_SYSLOG global option.

◆ CRINIT_CONFIG_KEYSTR_COMMAND

#define CRINIT_CONFIG_KEYSTR_COMMAND   "COMMAND"

Config key to add a command to the task.

◆ CRINIT_CONFIG_KEYSTR_DEBUG

#define CRINIT_CONFIG_KEYSTR_DEBUG   "DEBUG"

Config file key for DEBUG global option.

◆ CRINIT_CONFIG_KEYSTR_DEPENDS

#define CRINIT_CONFIG_KEYSTR_DEPENDS   "DEPENDS"

Config key to add dependencies to the task.

◆ CRINIT_CONFIG_KEYSTR_ELOS_EVENT_POLL_INTERVAL

#define CRINIT_CONFIG_KEYSTR_ELOS_EVENT_POLL_INTERVAL   "ELOS_EVENT_POLL_INTERVAL"

Config file key for ELOS_EVENT_POLL_INTERVAL global option.

◆ CRINIT_CONFIG_KEYSTR_ELOS_PORT

#define CRINIT_CONFIG_KEYSTR_ELOS_PORT   "ELOS_PORT"

Config file key for ELOS_PORT global option.

◆ CRINIT_CONFIG_KEYSTR_ELOS_SERVER

#define CRINIT_CONFIG_KEYSTR_ELOS_SERVER   "ELOS_SERVER"

Config file key for ELOS_SERVER global option.

◆ CRINIT_CONFIG_KEYSTR_ENV_SET

#define CRINIT_CONFIG_KEYSTR_ENV_SET   "ENV_SET"

Config key to set an environment variable with.

◆ CRINIT_CONFIG_KEYSTR_FILTER_DEFINE

#define CRINIT_CONFIG_KEYSTR_FILTER_DEFINE   "FILTER_DEFINE"

Config key to define an elos filter.

◆ CRINIT_CONFIG_KEYSTR_GROUP

#define CRINIT_CONFIG_KEYSTR_GROUP   "GROUP"

Config key to set a specific group to run task's commands.

◆ CRINIT_CONFIG_KEYSTR_INCL_FILE_SUFFIX

#define CRINIT_CONFIG_KEYSTR_INCL_FILE_SUFFIX   "INCL_FILE_SUFFIX"

Config key for the task include file extension in dynamic configurations.

◆ CRINIT_CONFIG_KEYSTR_INCL_SUFFIX

#define CRINIT_CONFIG_KEYSTR_INCL_SUFFIX   "INCLUDE_SUFFIX"

Config file key for INCLUDE_SUFFIX global option.

◆ CRINIT_CONFIG_KEYSTR_INCLDIR

#define CRINIT_CONFIG_KEYSTR_INCLDIR   "INCLUDEDIR"

Config file key for INCLUDEDIR global option.

◆ CRINIT_CONFIG_KEYSTR_INCLUDE

#define CRINIT_CONFIG_KEYSTR_INCLUDE   "INCLUDE"

Config key for file include directives.

◆ CRINIT_CONFIG_KEYSTR_INCLUDES

#define CRINIT_CONFIG_KEYSTR_INCLUDES   "INCLUDES"

Config key for the list of task file names.

◆ CRINIT_CONFIG_KEYSTR_IOREDIR

#define CRINIT_CONFIG_KEYSTR_IOREDIR   "IO_REDIRECT"

Config key for IO redirections.

◆ CRINIT_CONFIG_KEYSTR_LAUNCHER_CMD

#define CRINIT_CONFIG_KEYSTR_LAUNCHER_CMD   "LAUNCHER_CMD"

Config file key for LAUNCHER_CMD global option.

◆ CRINIT_CONFIG_KEYSTR_NAME

#define CRINIT_CONFIG_KEYSTR_NAME   "NAME"

Config key for the task name.

◆ CRINIT_CONFIG_KEYSTR_PROVIDES

#define CRINIT_CONFIG_KEYSTR_PROVIDES   "PROVIDES"

Config key for provided features.

◆ CRINIT_CONFIG_KEYSTR_RESPAWN

#define CRINIT_CONFIG_KEYSTR_RESPAWN   "RESPAWN"

Config key to set a task to be respawning.

◆ CRINIT_CONFIG_KEYSTR_RESPAWN_RETRIES

#define CRINIT_CONFIG_KEYSTR_RESPAWN_RETRIES   "RESPAWN_RETRIES"

Config key to set how often a task is allowed to respawn on failure.

◆ CRINIT_CONFIG_KEYSTR_SHDGRACEP

#define CRINIT_CONFIG_KEYSTR_SHDGRACEP   "SHUTDOWN_GRACE_PERIOD_US"

Config file key for SHUTDOWN_GRACE_PERIOD_US global option

◆ CRINIT_CONFIG_KEYSTR_SIGKEYDIR

#define CRINIT_CONFIG_KEYSTR_SIGKEYDIR   "sigkeydir"

Name of the option to set the public key dir from Kernel command line.

◆ CRINIT_CONFIG_KEYSTR_SIGNATURES

#define CRINIT_CONFIG_KEYSTR_SIGNATURES   "signatures"

Name of the option to activate signature checking on the Kernel command line.

◆ CRINIT_CONFIG_KEYSTR_STOP_COMMAND

#define CRINIT_CONFIG_KEYSTR_STOP_COMMAND   "STOP_COMMAND"

Config key to add a stop command to the task.

◆ CRINIT_CONFIG_KEYSTR_TASK_FILE_SUFFIX

#define CRINIT_CONFIG_KEYSTR_TASK_FILE_SUFFIX   "TASK_FILE_SUFFIX"

Config key for the task file extension in dynamic configurations.

◆ CRINIT_CONFIG_KEYSTR_TASKDIR

#define CRINIT_CONFIG_KEYSTR_TASKDIR   "TASKDIR"

Config file key for TASKDIR global option.

◆ CRINIT_CONFIG_KEYSTR_TASKDIR_SYMLINKS

#define CRINIT_CONFIG_KEYSTR_TASKDIR_SYMLINKS   "TASKDIR_FOLLOW_SYMLINKS"

Config key for the option to follow symbolic links from TASKDIR in dynamic configurations.

◆ CRINIT_CONFIG_KEYSTR_TASKS

#define CRINIT_CONFIG_KEYSTR_TASKS   "TASKS"

Config key for the list of task file names.

◆ CRINIT_CONFIG_KEYSTR_USE_ELOS

#define CRINIT_CONFIG_KEYSTR_USE_ELOS   "USE_ELOS"

Config file key for USE_ELOS global option.

◆ CRINIT_CONFIG_KEYSTR_USE_SYSLOG

#define CRINIT_CONFIG_KEYSTR_USE_SYSLOG   "USE_SYSLOG"

Config file key for USE_SYSLOG global option.

◆ CRINIT_CONFIG_KEYSTR_USER

#define CRINIT_CONFIG_KEYSTR_USER   "USER"

Config key to set a specific user to run task's commands.

◆ CRINIT_CONFIG_STDERR_NAME

#define CRINIT_CONFIG_STDERR_NAME   "STDERR"

What stderr is called in task configs.

◆ CRINIT_CONFIG_STDIN_NAME

#define CRINIT_CONFIG_STDIN_NAME   "STDIN"

What stdin is called in task configs.

◆ CRINIT_CONFIG_STDOUT_NAME

#define CRINIT_CONFIG_STDOUT_NAME   "STDOUT"

What stdout is called in task configs.

Typedef Documentation

◆ crinitConfigs_t

Enumeration of all configuration keys. Goes together with crinitTaskCfgMap and crinitSeriesCfgMap.

◆ crinitConfigType_t

Different types of configuration sources

◆ crinitConfKvList_t

Linked list to hold key/value pairs read from the config file.

Enumeration Type Documentation

◆ crinitConfigs_t

Enumeration of all configuration keys. Goes together with crinitTaskCfgMap and crinitSeriesCfgMap.

Enumerator
CRINIT_CONFIG_COMMAND 
CRINIT_CONFIG_DEBUG 
CRINIT_CONFIG_DEPENDS 
CRINIT_CONFIG_ELOS_EVENT_POLL_INTERVAL 
CRINIT_CONFIG_ELOS_PORT 
CRINIT_CONFIG_ELOS_SERVER 
CRINIT_CONFIG_ENV_SET 
CRINIT_CONFIG_FILTER_DEFINE 
CRINIT_CONFIG_GROUP 
CRINIT_CONFIG_INCLUDE 
CRINIT_CONFIG_INCLUDE_SUFFIX 
CRINIT_CONFIG_INCLUDEDIR 
CRINIT_CONFIG_IOREDIR 
CRINIT_CONFIG_NAME 
CRINIT_CONFIG_PROVIDES 
CRINIT_CONFIG_RESPAWN 
CRINIT_CONFIG_RESPAWN_RETRIES 
CRINIT_CONFIG_SHDGRACEP 
CRINIT_CONFIG_SIGKEYDIR 
CRINIT_CONFIG_SIGNATURES 
CRINIT_CONFIG_STOP_COMMAND 
CRINIT_CONFIG_TASK_FILE_SUFFIX 
CRINIT_CONFIG_TASKDIR 
CRINIT_CONFIG_TASKDIR_FOLLOW_SYMLINKS 
CRINIT_CONFIG_TASKS 
CRINIT_CONFIG_USE_SYSLOG 
CRINIT_CONFIG_USE_ELOS 
CRINIT_CONFIG_USER 
CRINIT_CONFIG_LAUNCHER_CMD 
CRINIT_CONFIGS_SIZE 

◆ crinitConfigType_t

Different types of configuration sources

Enumerator
CRINIT_CONFIG_TYPE_SERIES 

Configurations set from the series file.

CRINIT_CONFIG_TYPE_TASK 

Configurations set from a task file.

CRINIT_CONFIG_TYPE_KCMDLINE 

Configurations set from the Kernel command line.

Function Documentation

◆ crinitFreeArgvArray()

void crinitFreeArgvArray ( char **  inArgv)

Frees a string array with a backing string.

Parameters
inArgvThe string array to free, must be a double pointer with 2 allocations, one array of pointers and a single inner array of char.

◆ crinitFreeConfList()

void crinitFreeConfList ( crinitConfKvList_t confList)

Frees memory allocated for an crinitConfKvList_t by crinitParseConf().

Parameters
confListPointer to crinitConfKvList_t allocated by crinitParseConf() and not freed before. If confList is NULL, crinitFreeConfList() will return without freeing any memory.

◆ crinitLoadSeriesConf()

int crinitLoadSeriesConf ( const char *  filename)

Parse a series file.

Will return the task config and include files to be loaded in series. Will also set any global options specified in the series file.

Parameters
filenameThe path to the series file to load.
Returns
0 on success, -1 on failure

◆ crinitLoadTasks()

int crinitLoadTasks ( crinitFileSeries_t series)

Load all tasks related to a series file.

Parameters
seriesReturns the paths to the task configs specified in the series file (or scanned from TASKDIR, if configured).
Returns
0 on success, -1 on failure

◆ crinitParseConf()

int crinitParseConf ( crinitConfKvList_t **  confList,
const char *  filename 
)

Parse a config file into a crinitConfKvList_t.

Parses a config file and fills confList. Items of confList are dynamically allocated (grown) and need to be freed using free_confList(). The format of the config file is expected to be KEY1=VALUE1<newline>KEY2=VALUE2<newline>... Lines beginning with # are considered comments.

If the Kernel command line option crinit.signatures is set to yes, this function will also check the configuration file's signature. A non-matching signature is handled as a parser error.

Parameters
confListwill return a pointer to dynamically allocated memory of a ConfKvList filled with the key/value-pairs from the config file.
filenamePath to the configuration file.
Returns
0 on success, -1 on error