[07/10] config: add support for CRIU_CONFIG_FILE

Submitted by Adrian Reber on Aug. 1, 2018, 4:31 p.m.

Details

Message ID 20180801163122.19872-8-adrian@lisas.de
State Accepted
Series "Series without cover letter"
Headers show

Commit Message

Adrian Reber Aug. 1, 2018, 4:31 p.m.
From: Adrian Reber <areber@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@redhat.com>
---
 criu/config.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch hide | download patch | download mbox

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)