linux.debian.devel.mentors
[Top] [All Lists]

Re: Handling password inputs and verification in config scripts so that

Subject: Re: Handling password inputs and verification in config scripts so that special characters are allowed in passwords
From: Cyril Brulebois <kibi@xxxxxxxxxx>
Date: Mon, 28 Jul 2008 15:20:17 +0200
Newsgroups: linux.debian.devel.mentors
Olivier Berger <olivier.berger@xxxxxxxxxxxxxx> (28/07/2008):
>           if [ "$password" != "$confirm" ] ; then
> 
> If I'm not mistaken, whenever a user inputs a password containing
> characters like a double quote ("), the script may fail to properly
> manage such a password.

I suspect you didn't even try.

| # Matching double quotes first.
| kibi@cyril-ksrv32:~$ a='"miaou"'
| kibi@cyril-ksrv32:~$ b='"miaaa"'
| kibi@cyril-ksrv32:~$ echo $a
| "miaou"
| kibi@cyril-ksrv32:~$ echo $b
| "miaaa"
|| kibi@cyril-ksrv32:~$ if [ "$a" != "$b" ] ; then echo You fail. ; fi
| You fail.
 
| # Unbalanced double quote.
| kibi@cyril-ksrv32:~$ a='"miaou'
| kibi@cyril-ksrv32:~$ echo $a
| "miaou
| kibi@cyril-ksrv32:~$ if [ "$a" != "$b" ] ; then echo You fail. ; fi
| You fail.

Of course, same behaviour within a shell script rather than in an
interactive shell.

Yes, you are mistaken.

Mraw,
KiBi.
<Prev in Thread] Current Thread [Next in Thread>