From: Miles Bader Date: Wed, 3 Jul 1996 05:22:21 +0000 (+0000) Subject: (login): Only Frob OLD->ut_type if getutline_r actually found any entry. X-Git-Tag: upstream/2.30~29294 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74e1a5ff229f5cb7173ad770f8c41a5c6e878a25;p=external%2Fglibc.git (login): Only Frob OLD->ut_type if getutline_r actually found any entry. --- diff --git a/login/login.c b/login/login.c index ea1a947..bbd3be92 100644 --- a/login/login.c +++ b/login/login.c @@ -116,7 +116,7 @@ login (const struct utmp *ut) strncpy (tmp.ut_line, ttyp, UT_LINESIZE); /* Read the record. */ - if (getutline_r (&tmp, &old, &data) >= 0 || errno == ESRCH) + if (getutline_r (&tmp, &old, &data) >= 0) { #if _HAVE_UT_TYPE - 0 /* We have to fake the old entry because this `login' @@ -126,6 +126,10 @@ login (const struct utmp *ut) #endif pututline_r (ut, &data); } + else if (errno == ESRCH) + /* We didn't find anything. pututline_r will add UT at the end + of the file in this case. */ + pututline_r (ut, &data); /* Close UTMP file. */ endutent_r (&data);