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 /defaultenv | |
parent | f38ba32965c5686c062884fab2e9f505015af82a (diff) | |
download | barebox-90e766a78fe8ebf8acdc19713e9194266c78c093.tar.gz |
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 'defaultenv')
-rw-r--r-- | defaultenv/defaultenv-2-base/bin/init | 18 |
1 files changed, 0 insertions, 18 deletions
diff --git a/defaultenv/defaultenv-2-base/bin/init b/defaultenv/defaultenv-2-base/bin/init index 30651e55d2..37ee3651ba 100644 --- a/defaultenv/defaultenv-2-base/bin/init +++ b/defaultenv/defaultenv-2-base/bin/init @@ -27,25 +27,15 @@ magicvar -a global.allow_color "Allow color on the console (boolean)" [ -e /env/config-board ] && /env/config-board /env/config -# request password to login if a timeout is specified and password set -if [ -n ${global.login.timeout} ]; then - [ ${global.login.timeout} -gt 0 ] && login_cmd=login -fi -# allow the input if not -[ -n ${global.console.input_allow} ] && global.console.input_allow=1 - # allow to stop the boot before execute the /env/init/* # but without waiting timeout -s -a -v key 0 autoboot="$?" if [ "${key}" = "q" ]; then - ${login_cmd} exit fi -[ -n ${login_cmd} ] && global.console.input_allow=0 - for i in /env/init/*; do . $i done @@ -56,17 +46,12 @@ else echo -e -n "\nHit any key to stop autoboot: " fi -[ -n ${login_cmd} ] && global.console.input_allow=1 - if [ "$autoboot" = 0 ]; then timeout -a $global.autoboot_timeout -v key autoboot="$?" fi -[ -n ${login_cmd} ] && global.console.input_allow=0 - if [ "${key}" = "q" ]; then - ${login_cmd} exit fi @@ -75,12 +60,9 @@ if [ "$autoboot" = 0 ]; then fi if [ -e /env/menu ]; then - ${login_cmd} if [ "${key}" != "m" ]; then echo -e "\ntype exit to get to the menu" sh fi /env/menu/mainmenu fi - -${login_cmd} |