libptytty sync
authorayin <ayin>
Tue, 11 Dec 2007 21:49:12 +0000 (21:49 +0000)
committerayin <ayin>
Tue, 11 Dec 2007 21:49:12 +0000 (21:49 +0000)
src/logging.C
src/ptytty.C

index 1c5ef7b690fd2f4de8b8cc5878cf0823420d01c4..ff6b848590dab608fdf1c7fd1b451087b10cf3cf 100644 (file)
@@ -106,7 +106,8 @@ update_wtmp (const char *fname, const struct utmp *putmp)
     else if (errno != EAGAIN && errno != EACCES)
       break;
   if (!gotlock)
-    {          /* give it up */
+    {
+      /* give it up */
       close (fd);
       return;
     }
@@ -218,7 +219,7 @@ ptytty_unix::login (int cmd_pid, bool login_shell, const char *hostname)
     strncpy (ut_id, pty + 3, sizeof (ut_id));
   else if (sscanf (pty, "pts/%d", &i) == 1)
     sprintf (ut_id, "vt%02x", (i & 0xff));     /* sysv naming */
-  else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3))
+  else
     {
       ptytty_warn ("can't parse tty name \"%s\", not adding utmp entry.\n", pty);
       return;
@@ -232,7 +233,6 @@ ptytty_unix::login (int cmd_pid, bool login_shell, const char *hostname)
   strncpy (ut->ut_id, ut_id, sizeof (ut->ut_id));
   ut->ut_type = DEAD_PROCESS;
   getutid (ut);                /* position to entry in utmp file */
-  strncpy (this->ut_id, ut_id, sizeof (this->ut_id));
 # endif
 #endif
 
@@ -242,29 +242,24 @@ ptytty_unix::login (int cmd_pid, bool login_shell, const char *hostname)
   strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id));
   utx->ut_type = DEAD_PROCESS;
   getutxid (utx);              /* position to entry in utmp file */
-  strncpy (this->ut_id, ut_id, sizeof (this->ut_id));
 #endif
 
 #ifdef HAVE_STRUCT_UTMP
   strncpy (ut->ut_line, pty, sizeof (ut->ut_line));
+# ifdef HAVE_UTMP_HOST
+  strncpy (ut->ut_host, hostname, sizeof (ut->ut_host));
+# endif
   ut->ut_time = time (NULL);
 # ifdef HAVE_UTMP_PID
   strncpy (ut->ut_user, name, sizeof (ut->ut_user));
   strncpy (ut->ut_id, ut_id, sizeof (ut->ut_id));
-  ut->ut_time = time (NULL);
   ut->ut_pid = cmd_pid;
-#  ifdef HAVE_UTMP_HOST
-  strncpy (ut->ut_host, hostname, sizeof (ut->ut_host));
-#  endif
   ut->ut_type = USER_PROCESS;
   pututline (ut);
   endutent ();                 /* close the file */
   utmp_pos = 0;
 # else
   strncpy (ut->ut_name, name, sizeof (ut->ut_name));
-#  ifdef HAVE_UTMP_HOST
-  strncpy (ut->ut_host, hostname, sizeof (ut->ut_host));
-#  endif
 # endif
 #endif
 
index 6d03fd5eaaa5bb40d3b23c91122a566f2a0ee3f0..989b2a50c79bc05d82e39f21c93372d9bc51e654 100644 (file)
@@ -88,7 +88,8 @@
       {
         if (grantpt (pfd) == 0 /* change slave permissions */
             && unlockpt (pfd) == 0)
-          {    /* slave now unlocked */
+          {
+            /* slave now unlocked */
             *ttydev = strdup (ptsname (pfd));  /* get slave's name */
             return pfd;
           }
@@ -327,7 +328,8 @@ static struct ttyconf {
       struct group *gr = getgrnam ("tty");
 
       if (gr)
-        {           /* change group ownership of tty to "tty" */
+        {
+          /* change group ownership of tty to "tty" */
           mode = S_IRUSR | S_IWUSR | S_IWGRP;
           gid = gr->gr_gid;
         }