Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KSjSa-0002X9-4l for mharc-grub-devel@gnu.org; Mon, 11 Aug 2008 22:18:08 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KSjSY-0002V5-JQ for grub-devel@gnu.org; Mon, 11 Aug 2008 22:18:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KSjSX-0002Sv-7M for grub-devel@gnu.org; Mon, 11 Aug 2008 22:18:06 -0400 Received: from [199.232.76.173] (port=40818 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KSjSW-0002So-TA for grub-devel@gnu.org; Mon, 11 Aug 2008 22:18:04 -0400 Received: from ti-out-0910.google.com ([209.85.142.184]:1967) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KSjSW-0005KF-O7 for grub-devel@gnu.org; Mon, 11 Aug 2008 22:18:05 -0400 Received: by ti-out-0910.google.com with SMTP id u5so1091965tia.10 for ; Mon, 11 Aug 2008 19:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=Fac94TraufFtBrHcxvusrGovSCujUsVe1FwXmnd1+KA=; b=T3woXNaK+atVV2vUbOZBT8u+9ZDi70chjSodyItWb5n0M4ucPjy5kUXWZrfcCbf1ad WiYc8Ett2wC3okgt1IdQqblPGHAee/4LsLDnFQNWQth2Y6MjNt/HRGqlRfuDwpHYOowc IaNOge/NvPzrhGy6uGtH6XjNWaxbj3CajcwpY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=mhLDUpzdYdU5T1AcTcLaAU+kLwM6HiPJdCwgvfqkiJ4rcXybCHHO0u8TWavQ/tWmgR n94EgEKRksvKGkgo8mk9xW/rMVXwB6BQri4sJnXDB8wmNcagxBt/U6/xoNq1rMG3LFAX c5H0UtMuU9vp5sVHefRdDynDpwuWgy7o5ne1c= Received: by 10.110.109.12 with SMTP id h12mr10390432tic.34.1218507482704; Mon, 11 Aug 2008 19:18:02 -0700 (PDT) Received: by 10.110.16.5 with HTTP; Mon, 11 Aug 2008 19:18:02 -0700 (PDT) Message-ID: Date: Tue, 12 Aug 2008 10:18:02 +0800 From: Bean To: "The development of GRUB 2" MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Idea: implementation of the password command X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Aug 2008 02:18:06 -0000 Hi, First of all, we can store the encrypted password in a variable, like PASSWORD. It's better to store it in grubenv. as it is more flexible, and also allows the user to change it from the grub environment. Then, we can add a password hook to normal.mod. Whenever we need password verification, like before execution of menu or switching to console mode, we call the hook and check the return value. I introduce the attribute list concept in the other post. For example, we can assign some attribute to a menuitem, one of which is "locked". If we found this attribute, we call the password hook, otherwise execute the menu directly. We can also add a userland command check_password, which check the password and return true or false. This can be used in script to run some part of code when password matches. Another way for userland interactive is to use variable hook instead of command. For example, GET_PASSWORD. Whenever its value is query, we prompt the user for password and return the encrypted value. Here are some example of its usage: # Verify password if ($PASSWORD = $GET_PASSWORD) then ... fi # Store the new password PASSWORD=$GET_PASSWORD save_env PASSWORD This way looks neat, but it requires a working test command to be useful. -- Bean