[PATCH 2/2] defaultenv-2: add login support

Sascha Hauer s.hauer at pengutronix.de
Fri Sep 6 03:06:06 EDT 2013


On Wed, Sep 04, 2013 at 12:10:12PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> request password to login is a timeout is specified and /env/etc/passwd
> present
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  defaultenv-2/base/bin/init | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/defaultenv-2/base/bin/init b/defaultenv-2/base/bin/init
> index ca02ba6..e696dce 100644
> --- a/defaultenv-2/base/bin/init
> +++ b/defaultenv-2/base/bin/init
> @@ -16,11 +16,15 @@ global editcmd=sedit
>  [ -e /env/config-board ] && /env/config-board
>  /env/config
>  
> +# request password to login is a timeout is specified and /env/etc/passwd present
> +[ -n ${global.login.timeout} ] && login_cmd=login
> +
>  # allow to stop the boot before execute the /env/init/*
>  # but without waiting
>  timeout -s -a -v key 0
>  
>  if [ "${key}" = "q" ]; then
> +	${login_cmd}
>  	exit
>  fi
>  
> @@ -38,6 +42,7 @@ timeout -a $global.autoboot_timeout -v key
>  autoboot="$?"
>  
>  if [ "${key}" = "q" ]; then
> +	${login_cmd}
>  	exit
>  fi
>  
> @@ -48,7 +53,11 @@ fi
>  if [ -e /env/menu ]; then
>  	if [ "${key}" != "m" ]; then
>  		echo -e "\ntype exit to get to the menu"
> +		${login_cmd}
>  		sh
>  	fi
> +	${login_cmd}
>  	/env/menu/mainmenu

You should do it like this:

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

Otherwise you get prompted for a password when entering the shell and
agin when going to the menu.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list