Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Dec 2008 12:39:53 -0800
From:      "Garrett Cooper" <yanefbsd@gmail.com>
To:        "Giorgos Keramidas" <keramida@ceid.upatras.gr>
Cc:        freebsd-hackers@freebsd.org, =?ISO-8859-1?Q?Trond_Endrest=F8l?= <Trond.Endrestol@fagskolen.gjovik.no>
Subject:   Re: Small Change to chpass.c
Message-ID:  <7d6fde3d0812111239i7a47037mf9b5e4e5386b540@mail.gmail.com>
In-Reply-To: <87zlj2kg4e.fsf@kobe.laptop>
References:  <f4ecc0930812101800g601d9f10jc008e83d82b54a81@mail.gmail.com> <87vdtr9q8a.fsf@kobe.laptop> <20081211080955.T60586@ramstind.fig.ol.no> <87zlj2kg4e.fsf@kobe.laptop>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Dec 11, 2008 at 5:15 AM, Giorgos Keramidas
<keramida@ceid.upatras.gr> wrote:
> On Thu, 11 Dec 2008 08:11:20 +0100 (CET), Trond Endrest=F8l <Trond.Endres=
tol@fagskolen.gjovik.no> wrote:
>>On Thu, 11 Dec 2008 08:32+0200, Giorgos Keramidas wrote:
>>> On Wed, 10 Dec 2008 18:00:25 -0800, "Sheldon Givens" <sheldon@sigsegv.c=
a> wrote:
>>> > --- /usr/src/usr.bin/chpass.c   2008-12-11 01:55:27.000000000 -0800
>>> > +++ /usr/src/usr.bin/chpass.c   2008-12-11 01:57:09.000000000 -0800
>>> > @@ -80,10 +80,11 @@
>>> >  {
>>> >         enum { NEWSH, LOADENTRY, EDITENTRY, NEWPW, NEWEXP } op;
>>> >         struct passwd lpw, *old_pw, *pw;
>>> > -       int ch, pfd, tfd;
>>> > +       int ch, pfd, tfd, itr, auth;
>>> >         const char *password;
>>> >         char *arg =3D NULL;
>>> >         uid_t uid;
>>> > +       int max_retries =3D 3;
>>> >  #ifdef YP
>>> >         struct ypclnt *ypclnt;
>>> >         const char *yp_domain =3D NULL, *yp_host =3D NULL;
>>> > @@ -227,9 +228,16 @@
>>> >         }
>>> >
>>> >         if (old_pw && !master_mode) {
>>> > -               password =3D getpass("Password: ");
>>
>> I'm sure you have noticed the trailing space in the string.
>>
>>> > -               if (strcmp(crypt(password, old_pw->pw_passwd),
>>> > -                   old_pw->pw_passwd) !=3D 0)
>>> > +               auth =3D 0;
>>> > +               for(itr=3D0;itr<max_retries;itr++) {
>>> > +                       password =3D getpass("Password:");
>>
>> The space's missing in this string. It might be better to stay
>> consistent with the original code.
>
> Good catch.  No, I didn't notice the missing space the first time I read
> the diff :/

A better way to solve this may be to add an option to set the number
of retries before failure and then just pass it through to this
function.
-Garrett



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7d6fde3d0812111239i7a47037mf9b5e4e5386b540>