From: ayin Date: Tue, 11 Dec 2007 21:49:12 +0000 (+0000) Subject: libptytty sync X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=5b4629434f7094bae36d243490691bcb45ef5836;p=dana%2Furxvt.git libptytty sync --- diff --git a/src/logging.C b/src/logging.C index 1c5ef7b6..ff6b8485 100644 --- a/src/logging.C +++ b/src/logging.C @@ -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 diff --git a/src/ptytty.C b/src/ptytty.C index 6d03fd5e..989b2a50 100644 --- a/src/ptytty.C +++ b/src/ptytty.C @@ -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; }