summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-03-29 14:35:04 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-31 13:57:59 +0200
commit51d390cc2c7e41bc7778c6010cc62664239ce88d (patch)
treeb95d4b47b07bd1838a5222d289cb93833b037b4a
parent99335922839a3f11895d0f8c2424a9bed61d5da1 (diff)
downloaddt-utils-51d390cc2c7e41bc7778c6010cc62664239ce88d.tar.gz
barebox-state: implement skipping authentification (again)
Implement authentification again, this time wihtout the need of passing a "force" argument through half of the function call stack. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--src/barebox-state.c14
-rw-r--r--src/barebox-state.h2
-rw-r--r--src/keystore-blob.c2
3 files changed, 13 insertions, 5 deletions
diff --git a/src/barebox-state.c b/src/barebox-state.c
index 5399209..4bd77cf 100644
--- a/src/barebox-state.c
+++ b/src/barebox-state.c
@@ -308,7 +308,7 @@ static int state_set_var(struct state *state, const char *var, const char *val)
}
-struct state *state_get(const char *name, bool readonly)
+struct state *state_get(const char *name, bool readonly, bool auth)
{
struct device_node *root, *node, *partition_node;
char *path;
@@ -368,7 +368,11 @@ struct state *state_get(const char *name, bool readonly)
return ERR_CAST(state);
}
- ret = state_load(state);
+ if (auth)
+ ret = state_load(state);
+ else
+ ret = state_load_no_auth(state);
+
if (ret)
pr_err("Failed to load persistent state, continuing with defaults, %d\n", ret);
@@ -433,12 +437,13 @@ int main(int argc, char *argv[])
int nr_states = 0;
bool readonly = true;
int pr_level = 5;
+ int auth = 1;
INIT_LIST_HEAD(&sg_list);
INIT_LIST_HEAD(&state_list.list);
while (1) {
- c = getopt_long(argc, argv, "hg:s:dvn:q", long_options, &option_index);
+ c = getopt_long(argc, argv, "hg:s:dvn:qf", long_options, &option_index);
if (c < 0)
break;
switch (c) {
@@ -458,6 +463,9 @@ int main(int argc, char *argv[])
list_add_tail(&sg->list, &sg_list);
readonly = false;
break;
+ case 'f':
+ auth = 0;
+ break;
case 'd':
do_dump = 1;
break;
diff --git a/src/barebox-state.h b/src/barebox-state.h
index 00c758f..bd89cf4 100644
--- a/src/barebox-state.h
+++ b/src/barebox-state.h
@@ -1,7 +1,7 @@
#ifndef __BAREBOX_STATE__
#define __BAREBOX_STATE__
-struct state *state_get(const char *name, bool readonly);
+struct state *state_get(const char *name, bool readonly, bool auth);
char *state_get_var(struct state *state, const char *var);
#endif /* __BAREBOX_STATE__ */
diff --git a/src/keystore-blob.c b/src/keystore-blob.c
index e3bffb3..028dd8b 100644
--- a/src/keystore-blob.c
+++ b/src/keystore-blob.c
@@ -30,7 +30,7 @@ int keystore_get_secret(const char *name, const unsigned char **key, int *key_le
if (!state) {
struct state *tmp;
- tmp = state_get(keystore_state_name, true);
+ tmp = state_get(keystore_state_name, true, false);
if (IS_ERR(tmp))
return PTR_ERR(tmp);
state = tmp;