]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(login): Correct test for result of utmpname.
authorUlrich Drepper <drepper@redhat.com>
Sat, 16 Aug 1997 19:41:12 +0000 (19:41 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sat, 16 Aug 1997 19:41:12 +0000 (19:41 +0000)
Use updwtmp instead of implementing this here again.

login/login.c

index 0df11c68956b7fa87d3413aa19abdb37f2ee1539..4d08dbb47279d4e2e07d2710c32af417bc712585 100644 (file)
@@ -23,7 +23,8 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <utmp.h>
-\f
+
+
 /* Return the result of ttyname in the buffer pointed to by TTY, which should
    be of length BUF_LEN.  If it is too long to fit in this buffer, a
    sufficiently long buffer is allocated using malloc, and returned in TTY.
@@ -65,7 +66,6 @@ tty_name (int fd, char **tty, size_t buf_len)
          __set_errno (ENOMEM);
          break;
        }
-
       buf = new_buf;
     }
 
@@ -115,7 +115,7 @@ login (const struct utmp *ut)
       strncpy (copy.ut_line, ttyp, UT_LINESIZE);
 
       /* Tell that we want to use the UTMP file.  */
-      if (utmpname (_PATH_UTMP) != 0)
+      if (utmpname (_PATH_UTMP) == 0)
        {
          struct utmp *old;
 
@@ -137,20 +137,5 @@ login (const struct utmp *ut)
     }
 
   /* Update the WTMP file.  Here we have to add a new entry.  */
-  if (utmpname (_PATH_WTMP) != 0)
-    {
-      struct utmp *up;
-
-      /* Open the WTMP file.  */
-      setutent ();
-
-      /* Position at end of file.  */
-      while (! getutent_r (&utbuf, &up));
-
-      /* Write the new entry.  */
-      pututline (&copy);
-
-      /* Close WTMP file.  */
-      endutent ();
-    }
+  updwtmp (_PATH_WTMP, &copy);
 }