Fri Jul 5 17:34:47 1996 Miles Bader <miles@gnu.ai.mit.edu>
authorMiles Bader <miles@gnu.org>
Sat, 6 Jul 1996 03:57:56 +0000 (03:57 +0000)
committerMiles Bader <miles@gnu.org>
Sat, 6 Jul 1996 03:57:56 +0000 (03:57 +0000)
* login/logout.c (logout): Do nothing if getutline_r returns ESRCH.

* login/pututline_r.c (pututline_r): Since we assign RESULT from
lseek now, check that it's >= 0, not == 0.

Wed Jul  3 13:28:04 1996  Miles Bader  <miles@gnu.ai.mit.edu>

* login/login.c (login): Make a copy of *UT, fill in various
fields that we supply (ut_line, ut_type, ut_pid), and use the copy
in place of UT.

* login/getutline_r.c (getutline_r): When we return ESRCH, mark
UTMP_DATA->ubuf invalid (by setting UTMP_DATA->loc_utmp to 0).

ChangeLog
login/login.c
login/logout.c

index f44123a..168cd67 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+Fri Jul  5 17:34:47 1996  Miles Bader  <miles@gnu.ai.mit.edu>
+
+       * login/logout.c (logout): Do nothing if getutline_r returns ESRCH.
+
+       * login/pututline_r.c (pututline_r): Since we assign RESULT from
+       lseek now, check that it's >= 0, not == 0.
+
+Wed Jul  3 13:28:04 1996  Miles Bader  <miles@gnu.ai.mit.edu>
+
+       * login/login.c (login): Make a copy of *UT, fill in various
+       fields that we supply (ut_line, ut_type, ut_pid), and use the copy
+       in place of UT.
+
+       * login/getutline_r.c (getutline_r): When we return ESRCH, mark
+       UTMP_DATA->ubuf invalid (by setting UTMP_DATA->loc_utmp to 0).
+
 Fri Jul  5 12:22:51 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>
 
        * hurd/hurdsig.c (_hurd_internal_post_signal): In case of handled
index bbd3be9..76f27a0 100644 (file)
@@ -87,6 +87,13 @@ login (const struct utmp *ut)
   int found_tty;
   const char *ttyp;
   struct utmp_data data = { -1 };
+  struct utmp copy = *ut;
+
+  /* Fill in those fields we supply.  */
+#if _HAVE_UT_TYPE - 0
+  copy.ut_type = USER_PROCESS;
+#endif
+  copy.ut_pid = getpid ();
 
   /* Seek tty.  */
   found_tty = tty_name (STDIN_FILENO, &tty, sizeof (_tty));
@@ -97,39 +104,35 @@ login (const struct utmp *ut)
 
   if (found_tty >= 0)
     {
+      /* We only want to insert the name of the tty without path.  */
+      ttyp = basename (tty);
+
+      /* Position to record for this tty.  */
+      strncpy (copy.ut_line, ttyp, UT_LINESIZE);
+
       /* Tell that we want to use the UTMP file.  */
       if (utmpname (_PATH_UTMP) != 0)
        {
-         struct utmp tmp;
          struct utmp *old;
 
          /* Open UTMP file.  */
          setutent_r (&data);
 
-         /* We only want to insert the name of the tty without path.  */
-         ttyp = basename (tty);
-
-         /* Position to record for this tty.  */
-#if _HAVE_UT_TYPE - 0
-         tmp.ut_type = USER_PROCESS;
-#endif
-         strncpy (tmp.ut_line, ttyp, UT_LINESIZE);
-
          /* Read the record.  */
-         if (getutline_r (&tmp, &old, &data) >= 0)
+         if (getutline_r (&copy, &old, &data) >= 0)
            {
 #if _HAVE_UT_TYPE - 0
              /* We have to fake the old entry because this `login'
                 function does not fit well into the UTMP file
                 handling scheme.  */
-             old->ut_type = ut->ut_type;
+             old->ut_type = copy.ut_type;
 #endif
-             pututline_r (ut, &data);
+             pututline_r (&copy, &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);
+           pututline_r (&copy, &data);
 
          /* Close UTMP file.  */
          endutent_r (&data);
@@ -153,9 +156,9 @@ login (const struct utmp *ut)
          /* We have to fake the old entry because this `login'
             function does not fit well into the UTMP file handling
             scheme.  */
-         data.ubuf.ut_type = ut->ut_type;
+         data.ubuf.ut_type = copy.ut_type;
 #endif
-         pututline_r (ut, &data);
+         pututline_r (&copy, &data);
        }
 
       /* Close WTMP file.  */
index 1b8dc31..bf45451 100644 (file)
@@ -44,7 +44,7 @@ logout (const char *line)
   strncpy (tmp.ut_line, line, sizeof tmp.ut_line);
 
   /* Read the record.  */
-  if (getutline_r (&tmp, &ut, &data) >= 0 || errno == ESRCH)
+  if (getutline_r (&tmp, &ut, &data) >= 0)
     {
       /* Clear information about who & from where.  */
       bzero (ut->ut_name, sizeof ut->ut_name);