From 90e766a78fe8ebf8acdc19713e9194266c78c093 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 27 Aug 2015 15:29:58 +0200 Subject: 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 --- commands/menutree.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'commands/menutree.c') diff --git a/commands/menutree.c b/commands/menutree.c index 5d30b67ee5..ea5f65f3a1 100644 --- a/commands/menutree.c +++ b/commands/menutree.c @@ -12,12 +12,15 @@ #include #include #include +#include static int do_menutree(int argc, char *argv[]) { int opt, ret; char *path = "/env/menu"; + login(); + while ((opt = getopt(argc, argv, "m:")) > 0) { switch (opt) { case 'm': -- cgit v1.2.3