[CRIU] [PATCH 07/10] config: add support for CRIU_CONFIG_FILE

Adrian Reber adrian at lisas.de
Wed Aug 1 19:31:19 MSK 2018


From: Adrian Reber <areber at redhat.com>

With this it is possible to point the environment variable
CRIU_CONFIG_FILE to a CRIU configuration file.

The order the configuration files are evaluated now is:

 1. global (/etc/criu/default.conf)
 2. user ($HOME/.criu/default.conf)
 3. CRIU_CONFIG_FILE
 4. --config FILENAME
 5. CLI

Signed-off-by: Adrian Reber <areber at redhat.com>
---
 criu/config.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/criu/config.c b/criu/config.c
index 3d4dc4431..c2729a92d 100644
--- a/criu/config.c
+++ b/criu/config.c
@@ -160,6 +160,7 @@ static int next_config(char **argv, char ***_argv, bool no_default_config,
 {
 	char local_filepath[PATH_MAX + 1];
 	char *home_dir = NULL;
+	char *cfg_from_env = NULL;
 
 	if (state > PARSING_ARGV)
 		return 0;
@@ -183,6 +184,10 @@ static int next_config(char **argv, char ***_argv, bool no_default_config,
 			}
 			break;
 		case PARSING_ENV_CONF:
+			cfg_from_env = getenv("CRIU_CONFIG_FILE");
+			if (!cfg_from_env)
+				break;
+			*_argv = parse_config(cfg_from_env);
 			break;
 		case PARSING_CMDLINE_CONF:
 			if (!cfg_file)
-- 
2.18.0



More information about the CRIU mailing list