/* ARGSUSED */
void
cleanup(int sig)
{
	char *p, c;

	p = line + sizeof(_PATH_DEV) - 1;
#ifdef SUPPORT_UTMP
	if (logout(p))
		logwtmp(p, "", "");
#endif
#ifdef SUPPORT_UTMPX
	if (logoutx(p, 0, DEAD_PROCESS))
		logwtmpx(p, "", "", 0, DEAD_PROCESS);
#endif
	(void)chmod(line, 0666);
	(void)chown(line, 0, 0);
	c = *p; *p = 'p';
	(void)chmod(line, 0666);
	(void)chown(line, 0, 0);
	*p = c;
	if (ttyaction(line, "telnetd", "root"))
		syslog(LOG_ERR, "%s: ttyaction failed", line);
	(void) shutdown(net, 2);
	exit(1);
}
Пример #2
0
/* Records that the user has logged out. */
void
record_logout(pid_t pid, const char *tty)
{
#if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX)
	const char *line = tty + 5;	/* /dev/ttyq8 -> ttyq8 */
#endif
#ifdef SUPPORT_UTMP
	if (logout(line))
		logwtmp(line, "", "");
#endif
#ifdef SUPPORT_UTMPX
	/* XXX: no exit info yet */
	if (logoutx(line, 0, DEAD_PROCESS))
		logwtmpx(line, "", "", 0, DEAD_PROCESS);
#endif
}
Пример #3
0
void
utmp_logout (char *line)
{
#ifdef HAVE_UTMPX_H
  struct utmpx utx;
  struct utmpx *ut;

  strncpy (utx.ut_line, line, sizeof (utx.ut_line));

# ifdef HAVE_PUTUTXLINE
  setutxent();
  ut = getutxline (&utx);
  if (ut)
    {
      struct timeval tv;

      ut->ut_type = DEAD_PROCESS;
#  ifdef HAVE_STRUCT_UTMPX_UT_EXIT
      memset (&ut->ut_exit, 0, sizeof (ut->ut_exit));
#  endif
      gettimeofday (&tv, 0);
      ut->ut_tv.tv_sec = tv.tv_sec;
      ut->ut_tv.tv_usec = tv.tv_usec;
#  ifdef HAVE_STRUCT_UTMPX_UT_USER
      memset (&ut->ut_user, 0, sizeof (ut->ut_user));
#  elif defined HAVE_STRUCT_UTMPX_UT_NAME
      memset (&ut->ut_name, 0, sizeof (ut->ut_name));
#  endif
#  ifdef HAVE_STRUCT_UTMPX_UT_HOST
      memset (ut->ut_host, 0, sizeof (ut->ut_host));
#   ifdef HAVE_STRUCT_UTMPX_UT_SYSLEN
      ut->ut_syslen = 1;	/* Counting NUL.  */
#   endif
#  endif /* UT_HOST */
      pututxline (ut);
      /* Some systems perform wtmp updating
       * already in calling pututxline().
       */
#  ifdef HAVE_UPDWTMPX
      updwtmpx (PATH_WTMPX, ut);
#  elif defined HAVE_LOGWTMPX
      logwtmpx (ut->ut_line, "", "", 0, DEAD_PROCESS);
#  endif
    }
  endutxent ();
# elif defined HAVE_LOGOUTX /* !HAVE_PUTUTXLINE */
  if (logoutx (line, 0, DEAD_PROCESS))
    logwtmpx (line, "", "", 0, DEAD_PROCESS);
# endif /* HAVE_LOGOUTX */

#else /* !HAVE_UTMPX_H */
  struct utmp utx;
# ifdef HAVE_PUTUTLINE
  struct utmp *ut;
# endif

  strncpy (utx.ut_line, line, sizeof (utx.ut_line));

# ifdef HAVE_PUTUTLINE
  setutent();
  ut = getutline (&utx);
  if (ut)
    {
#  ifdef HAVE_STRUCT_UTMP_UT_TV
      struct timeval tv;
#  endif

#  ifdef HAVE_STRUCT_UTMP_UT_TYPE
      ut->ut_type = DEAD_PROCESS;
#  endif
#  ifdef HAVE_STRUCT_UTMP_UT_EXIT
      memset (&ut->ut_exit, 0, sizeof (ut->ut_exit));
#  endif
#  ifdef HAVE_STRUCT_UTMP_UT_TV
      gettimeofday (&tv, 0);
      ut->ut_tv.tv_sec = tv.tv_sec;
      ut->ut_tv.tv_usec = tv.tv_usec;
#  else /* !HAVE_STRUCT_UTMP_UT_TV */
      time (&(ut->ut_time));
#  endif
#  ifdef HAVE_STRUCT_UTMP_UT_USER
      memset (&ut->ut_user, 0, sizeof (ut->ut_user));
#  elif defined HAVE_STRUCT_UTMP_UT_NAME
      memset (&ut->ut_name, 0, sizeof (ut->ut_name));
#  endif
#  ifdef HAVE_STRUCT_UTMP_UT_HOST
      memset (ut->ut_host, 0, sizeof (ut->ut_host));
#  endif
      pututline (ut);
#  ifdef HAVE_UPDWTMP
      updwtmp (WTMP_FILE, ut);
#  elif defined HAVE_LOGWTMP /* !HAVE_UPDWTMP */
      logwtmp (ut->ut_line, "", "");
#  endif
    }
  endutent ();
# elif defined HAVE_LOGOUT /* !HAVE_PUTUTLINE */
  if (logout (line))
    logwtmp (line, "", "");
# endif /* HAVE_LOGOUT */
#endif
}