2023-06-20 12:52:35 +02:00
|
|
|
/*
|
|
|
|
* No copyright is claimed. This code is in the public domain; do with
|
|
|
|
* it what you wish.
|
|
|
|
*/
|
2010-12-24 01:07:48 +01:00
|
|
|
#ifndef UTIL_LINUX_ENV_H
|
|
|
|
#define UTIL_LINUX_ENV_H
|
|
|
|
|
2012-06-05 15:44:12 +02:00
|
|
|
#include "c.h"
|
2016-08-16 12:35:57 +02:00
|
|
|
#include "nls.h"
|
2012-06-05 15:44:12 +02:00
|
|
|
|
2020-08-25 10:43:07 +02:00
|
|
|
struct ul_env_list;
|
|
|
|
|
2012-10-17 21:26:14 +02:00
|
|
|
extern void sanitize_env(void);
|
2020-08-25 10:43:07 +02:00
|
|
|
extern void __sanitize_env(struct ul_env_list **org);
|
|
|
|
|
|
|
|
extern int env_list_setenv(struct ul_env_list *ls);
|
|
|
|
extern void env_list_free(struct ul_env_list *ls);
|
2023-02-27 03:18:31 +01:00
|
|
|
extern struct ul_env_list *env_from_fd(int pid);
|
2020-08-25 10:43:07 +02:00
|
|
|
|
2010-12-24 01:07:48 +01:00
|
|
|
extern char *safe_getenv(const char *arg);
|
|
|
|
|
2016-08-16 12:35:57 +02:00
|
|
|
|
|
|
|
#ifndef XSETENV_EXIT_CODE
|
|
|
|
# define XSETENV_EXIT_CODE EXIT_FAILURE
|
|
|
|
#endif
|
|
|
|
|
2012-10-17 21:26:14 +02:00
|
|
|
static inline void xsetenv(char const *name, char const *val, int overwrite)
|
2012-06-01 14:51:18 +02:00
|
|
|
{
|
2012-10-17 21:26:14 +02:00
|
|
|
if (setenv(name, val, overwrite) != 0)
|
2016-08-16 12:35:57 +02:00
|
|
|
err(XSETENV_EXIT_CODE, _("failed to set the %s environment variable"), name);
|
2012-06-01 14:51:18 +02:00
|
|
|
}
|
|
|
|
|
2020-04-12 09:53:32 +02:00
|
|
|
static inline int remote_entry(char **argv, int remove, int last)
|
|
|
|
{
|
|
|
|
memmove(argv + remove, argv + remove + 1, sizeof(char *) * (last - remove));
|
|
|
|
return last - 1;
|
|
|
|
}
|
|
|
|
|
2010-12-24 01:07:48 +01:00
|
|
|
#endif /* UTIL_LINUX_ENV_H */
|