From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZwwbM-0003kG-KW for mharc-grub-devel@gnu.org; Thu, 12 Nov 2015 13:28:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwwbJ-0003im-Jq for grub-devel@gnu.org; Thu, 12 Nov 2015 13:28:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwwbE-00048G-Hy for grub-devel@gnu.org; Thu, 12 Nov 2015 13:28:01 -0500 Received: from mail-lb0-x234.google.com ([2a00:1450:4010:c04::234]:36622) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwwbE-00048A-63 for grub-devel@gnu.org; Thu, 12 Nov 2015 13:27:56 -0500 Received: by lbblt2 with SMTP id lt2so40533685lbb.3 for ; Thu, 12 Nov 2015 10:27:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=NOlxagalU2xtIv0PGwYH75er++sjVwLK1cmUpmp9m7I=; b=dStaIuEsZxuma4RPhWsDqDzZ1IuGE7KFHSt9J5WlxC3EyjJ1CL4CeOh1zFkOizyBoW AweS6Hj/lOtwR5y+MPOmtSkDYYilEnVFWHETDgb8Je3bZLINj0DNg7RqkzxM8K4EKksf napzX3KAmCCsJwRRAJnTHm2U2JB45jQyo/hnCZrMSQO9vd0Expm/4dY9Qg7chl9gPpDF roIXZ2wTXr+3Tp4C1N1UhffJpy7mbN0WHuOetDW2qQ5wzMrd3338PbxabDrmo+VTKQ/F m0580fmVTSVvsE7RUqtmC/sEaeFBhMZY4HtxKV2EeUg7UDSl06pwi5EkwV0nKbRkgqDU iANA== X-Received: by 10.112.198.69 with SMTP id ja5mr8363184lbc.106.1447352875461; Thu, 12 Nov 2015 10:27:55 -0800 (PST) Received: from [192.168.1.41] (ppp91-76-25-247.pppoe.mtu-net.ru. [91.76.25.247]) by smtp.gmail.com with ESMTPSA id o137sm2491651lfe.31.2015.11.12.10.27.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Nov 2015 10:27:54 -0800 (PST) Subject: Re: [PATCH] broken ESC navigation if authentication is used To: grub-devel@gnu.org References: <201506101829.59882.florian_kaiser@genua.de> <20150610223152.1c2f2564@opensuse.site> <20150611065531.47ffab1f@opensuse.site> <563FB6C4.1010609@gmail.com> From: Andrei Borzenkov Message-ID: <5644DA29.3010401@gmail.com> Date: Thu, 12 Nov 2015 21:27:53 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <563FB6C4.1010609@gmail.com> Content-Type: multipart/mixed; boundary="------------010205060702060004040603" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::234 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2015 18:28:02 -0000 This is a multi-part message in MIME format. --------------010205060702060004040603 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 08.11.2015 23:55, Vladimir 'φ-coder/phcoder' Serbinenko пишет: > On 11.06.2015 05:55, Andrei Borzenkov wrote: >> В Wed, 10 Jun 2015 21:35:51 +0200 >> "Vladimir 'phcoder' Serbinenko" пишет: >> >>> This patch may allow to escape to shell if menu was called from context >>> without menu entries. This may happen inadvertently I.a. when using >>> configfile. You need to add an additional parameter to indicate whether >>> it's OK to break from menu >> >> Could you explain? Grub does >> >> grub_enter_normal >> grub_normal_execute >> grub_show_menu >> grub_cmdline_run >> >> if after processing config file there are no menu entries we do not >> even call grub_show_menu. And even if we do, after return from it there >> is mandatory authentication in grub_cmdline_run. >> > Imagine something like following: > grub.cfg: > # Use another config file > configfile grub2.cfg > grub2.cfg: > superusers=root > .... > Then pressing escape would lead you to the parent context where there is > no password protection. > Question is whether this is a misconfiguration on grub.cfg side (i.a. > should have been source, not configfile) or something to deal on code side. OK what about attached patch? it moves authentication where it belongs - to return from nested configfile. --------------010205060702060004040603 Content-Type: text/x-patch; name="submenu-auth.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="submenu-auth.diff" From: Andrei Borzenkov Subject: [PATCH] normal: allow return from submenu without authentication This change removes a superfluous authorization request, which prevented the user from navigating backwards through the menu tree using the ESC Key. To preserve current semantic, require authentication when returning from menu in nested configfile. Based on patch suggested by Florian Kaiser Also-By: Florian Kaiser --- grub-core/normal/main.c | 21 ++++++++++++++++++--- grub-core/normal/menu.c | 34 ++-------------------------------- include/grub/normal.h | 2 +- 3 files changed, 21 insertions(+), 36 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index 78a70a8..dc675ae 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -287,9 +287,24 @@ grub_normal_execute (const char *config, int nested, int batch) { grub_boot_time ("Entering menu"); - grub_show_menu (menu, nested, 0); - if (nested) - grub_normal_free_menu (menu); + while (1) + { + grub_show_menu (menu, nested, 0); + if (grub_normal_exit_level) + break; + if (nested) + { + if (grub_auth_check_authentication (NULL)) + { + grub_print_error (); + grub_errno = GRUB_ERR_NONE; + grub_wait_after_message (); + continue; + } + grub_normal_free_menu (menu); + break; + } + } } } } diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index 719e2fb..d93c19e 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -852,8 +852,8 @@ static struct grub_menu_execute_callback execution_callback = .notify_failure = notify_execution_failure }; -static grub_err_t -show_menu (grub_menu_t menu, int nested, int autobooted) +void +grub_show_menu (grub_menu_t menu, int nested, int autobooted) { while (1) { @@ -879,34 +879,4 @@ show_menu (grub_menu_t menu, int nested, int autobooted) if (autobooted) break; } - - return GRUB_ERR_NONE; -} - -grub_err_t -grub_show_menu (grub_menu_t menu, int nested, int autoboot) -{ - grub_err_t err1, err2; - - while (1) - { - err1 = show_menu (menu, nested, autoboot); - autoboot = 0; - grub_print_error (); - - if (grub_normal_exit_level) - break; - - err2 = grub_auth_check_authentication (NULL); - if (err2) - { - grub_print_error (); - grub_errno = GRUB_ERR_NONE; - continue; - } - - break; - } - - return err1; } diff --git a/include/grub/normal.h b/include/grub/normal.h index 218cbab..ae2e0dd 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -112,7 +112,7 @@ void grub_print_message_indented (const char *msg, int margin_left, struct grub_term_output *term); void grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested); -grub_err_t +void grub_show_menu (grub_menu_t menu, int nested, int autobooted); /* Defined in `handler.c'. */ -- tg: (c899d9f..) u/submenu-without-authentication (depends on: master) --------------010205060702060004040603--