1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #include <libconfig.h>
28 #include "system-recovery.h"
30 static char *get_action_from_config(config_t *cfg)
32 config_setting_t *node;
35 node = config_lookup(cfg, "headless_action");
39 action = config_setting_get_string(node);
41 return strdup(action);
44 int recovery_headless(config_t *cfg)
46 config_setting_t *node;
48 node = config_lookup(cfg, "action_handlers");
52 char *action = get_action_from_cmdline();
54 action = get_action_from_config(cfg);
59 int r = config_setting_lookup_string(node, action, &handler);
62 if (r == CONFIG_FALSE)
65 return system(handler);