Ticket #48583: patch-utmp.c.diff

File patch-utmp.c.diff, 3.4 KB (added by youvegotmoxie@…, 9 years ago)

Fix build failure

  • utmp.c

    old new  
    2626 ****************************************************************
    2727 */
    2828
     29#include <sys/param.h>
    2930#include <sys/types.h>
    3031#include <sys/stat.h>
    3132#include <fcntl.h>
     
    151152 * how = 0      try to withdraw a utmp slot.
    152153 *
    153154 * w_slot = -1  window not logged in.
    154  * w_slot = 0   window not logged in, but should be logged in. 
     155 * w_slot = 0   window not logged in, but should be logged in.
    155156 *              (unable to write utmp, or detached).
    156157 */
    157158
     
    400401 * down the name of his terminal line; else he is remote and we keep
    401402 * the hostname here. The letter S and the window id will be appended.
    402403 * A saved utmp entry in wi->w_savut serves as a template, usually.
    403  */ 
     404 */
    404405
    405406int
    406407SetUtmp(wi)
     
    409410  register slot_t slot;
    410411  struct utmp u;
    411412  int saved_ut;
    412 #ifdef UTHOST
    413   char *p;
    414   char host[sizeof(D_loginhost) + 15];
    415 #else
    416   char *host = 0;
    417 #endif /* UTHOST */
    418413
    419414  wi->w_slot = (slot_t)0;
    420415  if (!utmpok || wi->w_type != W_TYPE_PTY)
     
    435430    makeuser(&u, stripdev(wi->w_tty), LoginName, wi->w_pid);
    436431
    437432#ifdef UTHOST
    438   host[sizeof(host) - 15] = '\0';
    439   if (display)
    440     {
    441       strncpy(host, D_loginhost, sizeof(host) - 15);
    442       if (D_loginslot != (slot_t)0 && D_loginslot != (slot_t)-1 && host[0] != '\0')
    443         {
    444           /*
    445            * we want to set our ut_host field to something like
    446            * ":ttyhf:s.0" or
    447            * "faui45:s.0" or
    448            * "132.199.81.4:s.0" (even this may hurt..), but not
    449            * "faui45.informati"......:s.0
    450            * HPUX uses host:0.0, so chop at "." and ":" (Eric Backus)
    451            */
    452           for (p = host; *p; p++)
    453             if ((*p < '0' || *p > '9') && (*p != '.'))
    454               break;
    455           if (*p)
    456             {
    457               for (p = host; *p; p++)
    458                 if (*p == '.' || (*p == ':' && p != host))
    459                   {
    460                     *p = '\0';
    461                     break;
    462                   }
    463             }
    464         }
    465       else
    466         {
    467           strncpy(host + 1, stripdev(D_usertty), sizeof(host) - 15 - 1);
    468           host[0] = ':';
    469         }
    470     }
    471   else
    472     strncpy(host, "local", sizeof(host) - 15);
    473 
    474   sprintf(host + strlen(host), ":S.%d", wi->w_number);
    475   debug1("rlogin hostname: '%s'\n", host);
    476 
    477433# if !defined(_SEQUENT_) && !defined(sequent)
    478   strncpy(u.ut_host, host, sizeof(u.ut_host));
     434  strncpy(u.ut_host, D_loginhost, sizeof(u.ut_host));
    479435# endif
    480436#endif /* UTHOST */
    481437
    482   if (pututslot(slot, &u, host, wi) == 0)
     438  if (pututslot(slot, &u, D_loginhost, wi) == 0)
    483439    {
    484440      Msg(errno,"Could not write %s", UtmpName);
    485441      UT_CLOSE;
     
    598554struct utmp *u;
    599555{
    600556  u->ut_type = DEAD_PROCESS;
    601 #if (!defined(linux) || defined(EMPTY)) && !defined(__CYGWIN__)
     557#if (!defined(linux) || defined(EMPTY)) && !defined(__CYGWIN__) && !defined(__Darwin__)
    602558  u->ut_exit.e_termination = 0;
    603559  u->ut_exit.e_exit = 0;
    604560#endif
     
    631587  /* must use temp variable because of NetBSD/sparc64, where
    632588   * ut_xtime is long(64) but time_t is int(32) */
    633589  (void)time(&now);
     590#if defined(__Darwin_version) && __Darwin_version < 900000
     591  u->ut_time =  now;
     592#else
    634593  u->ut_tv.tv_sec = now;
     594#endif
    635595}
    636596
    637597static slot_t
     
    743703  strncpy(u->ut_line, line, sizeof(u->ut_line));
    744704  strncpy(u->ut_name, user, sizeof(u->ut_name));
    745705  (void)time(&now);
    746   u->ut_tv.tv_sec = now;
     706#if defined(__Darwin_version) && __Darwin_version < 900000
     707  u->ut_time =  now;
     708#else
     709  u->ut_time = now;
     710#endif
    747711}
    748712
    749713static slot_t
     
    890854  return u->ut_type == u2->ut_type ? u : 0;
    891855}
    892856#endif
    893