From 4592ae65d42e5d8eba77350f8339e07350ad0908 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 11 Feb 2020 16:17:02 +0100 Subject: T2026: use unique exit codes for commit errors. --- src/commit2.cpp | 14 +++++++++++++- src/vyos-errors.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/commit2.cpp b/src/commit2.cpp index 4594d08..aaccb08 100644 --- a/src/commit2.cpp +++ b/src/commit2.cpp @@ -8,6 +8,7 @@ #include /* g_type_init */ #include "common/common.h" #include "cli_path_utils.h" +#include "vyos-errors.h" #define cond_plog(cond, prio, fmt, ...) do { \ if (cond) { \ @@ -408,7 +409,18 @@ main(int argc, char** argv) //remove tmp changes file as all the work is now done unlink(COMMIT_CHANGES_FILE); - exit (errors == 2 ? 0 : 1); + int vyos_exit_code; + if (errors == 2) { + vyos_exit_code = 0; + } + else if (errors == 3) { + vyos_exit_code = VYOS_PARTIAL_COMMIT; + } + else { + vyos_exit_code = VYOS_COMMIT_FAILURE; + } + + exit (vyos_exit_code); } struct ExecuteHookData diff --git a/src/vyos-errors.h b/src/vyos-errors.h index 4ac9f57..b607659 100644 --- a/src/vyos-errors.h +++ b/src/vyos-errors.h @@ -3,3 +3,5 @@ #define VYOS_INVALID_PATH 2 #define VYOS_EMPTY_CONFIG 3 #define VYOS_CONFIG_PARSE_ERROR 4 +#define VYOS_COMMIT_FAILURE 5 +#define VYOS_PARTIAL_COMMIT 6 -- cgit v1.2.3