diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-08-27 15:29:58 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-08-28 08:00:27 +0200 |
commit | 90e766a78fe8ebf8acdc19713e9194266c78c093 (patch) | |
tree | 58556b422db0819d335e60c4b5e573206d8c872d /common/hush.c | |
parent | f38ba32965c5686c062884fab2e9f505015af82a (diff) | |
download | barebox-90e766a78fe8ebf8acdc19713e9194266c78c093.tar.gz barebox-90e766a78fe8ebf8acdc19713e9194266c78c093.tar.xz |
login: rework login mechanism
We used to have the login functionality in the /env/bin/init script.
This is hard to review and it's too easy to break the login functionality
with changes to this script. Move the places to ask for a password to
C code where we have only a few places where we have to ask for a password.
Mainly these are run_shell() and the menutree command.
This patch introduces a login() function which will only return if the correct
password has been entered. Following calls will return immediately without
asking for a password again.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/hush.c')
-rw-r--r-- | common/hush.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/common/hush.c b/common/hush.c index ffd251339e..abe87137b5 100644 --- a/common/hush.c +++ b/common/hush.c @@ -116,6 +116,7 @@ #include <errno.h> #include <fs.h> #include <libbb.h> +#include <password.h> #include <glob.h> #include <getopt.h> #include <libfile.h> @@ -1914,6 +1915,8 @@ int run_shell(void) struct p_context ctx; int exit = 0; + login(); + do { setup_file_in_str(&input); rcode = parse_stream_outer(&ctx, &input, FLAG_PARSE_SEMICOLON); |