101 for (current = *list, prev = NULL; current != NULL; current = current->
next)
111 *list = current->
next;
168 if (es && es->
gc == NULL)
208 return item ? item->
string : NULL;
228 msg(msglevel,
"ENV [%d] '%s'", i, e->
string);
243 msg(
M_ERR,
"could not write env set to '%s'", path);
294 snprintf(buf,
sizeof(buf),
"%d", value);
302 snprintf(buf,
sizeof(buf),
"%" PRIi64, (int64_t)value);
324 msg(
M_WARN,
"setenv_str_safe: name overflow");
365 const char *name_tmp;
366 const char *val_tmp = NULL;
368 ASSERT(name && strlen(name) > 1);
383#if DEBUG_VERBOSE_SETENV
449 for (e = es->
list; e != NULL; e = e->
next)
462 for (e = es->
list; e != NULL; e = e->
next)
473 return (
const char **)ret;
bool buf_printf(struct buffer *buf, const char *format,...)
printf-style append to a buffer with overflow check.
void * gc_malloc(size_t size, bool clear, struct gc_arena *a)
Allocate memory and, optionally, zero it.
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
Allocate a buffer of the given size under garbage collection.
const char * string_mod_const(const char *str, const unsigned int inclusive, const unsigned int exclusive, const char replace, struct gc_arena *gc)
Returns a copy of a string with certain classes of characters of it replaced with a specified charact...
bool checked_snprintf(char *str, size_t size, const char *format,...)
Like snprintf() but returns an boolean.
char * string_alloc(const char *str, struct gc_arena *gc)
Duplicate a string, allocating memory under garbage collection.
#define BSTR(buf)
Return the buffer content pointer cast to char *.
#define ALLOC_ARRAY_CLEAR_GC(dptr, type, n, gc)
Allocate and zero-initialise a garbage-collected array of n elements.
static void buf_set_write(struct buffer *buf, uint8_t *data, int size)
Initialise a buffer with an externally provided writable memory region.
static void secure_memzero(void *data, size_t len)
Securely zeroise memory.
#define ALLOC_OBJ_CLEAR_GC(dptr, type, gc)
Allocate and zero-initialise a garbage-collected object of the given type.
#define ALLOC_OBJ_GC(dptr, type, gc)
Allocate a garbage-collected object of the given type (uninitialised).
#define CC_NAME
alphanumeric plus underscore
static void gc_free(struct gc_arena *a)
Free all allocations in a garbage collection arena.
#define CC_PRINT
printable (>= 32, != 127)
static struct gc_arena gc_new(void)
Allocate and return a new, empty garbage collection arena.
void setenv_counter(struct env_set *es, const char *name, counter_type value)
static bool env_set_del_nolock(struct env_set *es, const char *str)
void env_set_destroy(struct env_set *es)
void setenv_int(struct env_set *es, const char *name, int value)
void setenv_int_i(struct env_set *es, const char *name, const int value, const int i)
static const char * setenv_format_indexed_name(const char *name, const int i, struct gc_arena *gc)
void env_set_print(msglvl_t msglevel, const struct env_set *es)
void setenv_str_i(struct env_set *es, const char *name, const char *value, const int i)
static void env_set_add_nolock(struct env_set *es, const char *str)
void env_set_write_file(const char *path, const struct env_set *es)
Write a struct env_set to a file.
static char * construct_name_value(const char *name, const char *value, struct gc_arena *gc)
void setenv_str(struct env_set *es, const char *name, const char *value)
const char ** make_env_array(const struct env_set *es, const bool check_allowed, struct gc_arena *gc)
void env_set_add(struct env_set *es, const char *str)
static bool env_string_equal(const char *s1, const char *s2)
static void add_env_item(char *str, const bool do_alloc, struct env_item **list, struct gc_arena *gc)
void setenv_str_ex(struct env_set *es, const char *name, const char *value, const unsigned int name_include, const unsigned int name_exclude, const char name_replace, const unsigned int value_include, const unsigned int value_exclude, const char value_replace)
const char * env_set_get(const struct env_set *es, const char *name)
void env_set_inherit(struct env_set *es, const struct env_set *src)
void setenv_str_incr(struct env_set *es, const char *name, const char *value)
Store the supplied name value pair in the env_set.
void setenv_str_safe(struct env_set *es, const char *name, const char *value)
struct env_set * env_set_create(struct gc_arena *gc)
bool env_allowed(const char *str)
bool env_set_del(struct env_set *es, const char *str)
void setenv_long_long(struct env_set *es, const char *name, long long value)
static bool remove_env_item(const char *str, const bool do_free, struct env_item **list)
void setenv_del(struct env_set *es, const char *name)
static bool is_password_env_var(const char *str)
static bool env_safe_to_print(const char *str)
static bool check_debug_level(msglvl_t level)
int script_security(void)
#define SSEC_PW_ENV
allow calling of built-in programs and user-defined scripts that may receive a password as an environ...
Wrapper structure for dynamically allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
Garbage collection arena used to keep track of dynamically allocated memory.