Ticket #48583: patch-utmp.c.diff
File patch-utmp.c.diff, 3.4 KB (added by youvegotmoxie@…, 9 years ago) |
---|
-
utmp.c
old new 26 26 **************************************************************** 27 27 */ 28 28 29 #include <sys/param.h> 29 30 #include <sys/types.h> 30 31 #include <sys/stat.h> 31 32 #include <fcntl.h> … … 151 152 * how = 0 try to withdraw a utmp slot. 152 153 * 153 154 * 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. 155 156 * (unable to write utmp, or detached). 156 157 */ 157 158 … … 400 401 * down the name of his terminal line; else he is remote and we keep 401 402 * the hostname here. The letter S and the window id will be appended. 402 403 * A saved utmp entry in wi->w_savut serves as a template, usually. 403 */ 404 */ 404 405 405 406 int 406 407 SetUtmp(wi) … … 409 410 register slot_t slot; 410 411 struct utmp u; 411 412 int saved_ut; 412 #ifdef UTHOST413 char *p;414 char host[sizeof(D_loginhost) + 15];415 #else416 char *host = 0;417 #endif /* UTHOST */418 413 419 414 wi->w_slot = (slot_t)0; 420 415 if (!utmpok || wi->w_type != W_TYPE_PTY) … … 435 430 makeuser(&u, stripdev(wi->w_tty), LoginName, wi->w_pid); 436 431 437 432 #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 like446 * ":ttyhf:s.0" or447 * "faui45:s.0" or448 * "132.199.81.4:s.0" (even this may hurt..), but not449 * "faui45.informati"......:s.0450 * 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 else466 {467 strncpy(host + 1, stripdev(D_usertty), sizeof(host) - 15 - 1);468 host[0] = ':';469 }470 }471 else472 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 477 433 # 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)); 479 435 # endif 480 436 #endif /* UTHOST */ 481 437 482 if (pututslot(slot, &u, host, wi) == 0)438 if (pututslot(slot, &u, D_loginhost, wi) == 0) 483 439 { 484 440 Msg(errno,"Could not write %s", UtmpName); 485 441 UT_CLOSE; … … 598 554 struct utmp *u; 599 555 { 600 556 u->ut_type = DEAD_PROCESS; 601 #if (!defined(linux) || defined(EMPTY)) && !defined(__CYGWIN__) 557 #if (!defined(linux) || defined(EMPTY)) && !defined(__CYGWIN__) && !defined(__Darwin__) 602 558 u->ut_exit.e_termination = 0; 603 559 u->ut_exit.e_exit = 0; 604 560 #endif … … 631 587 /* must use temp variable because of NetBSD/sparc64, where 632 588 * ut_xtime is long(64) but time_t is int(32) */ 633 589 (void)time(&now); 590 #if defined(__Darwin_version) && __Darwin_version < 900000 591 u->ut_time = now; 592 #else 634 593 u->ut_tv.tv_sec = now; 594 #endif 635 595 } 636 596 637 597 static slot_t … … 743 703 strncpy(u->ut_line, line, sizeof(u->ut_line)); 744 704 strncpy(u->ut_name, user, sizeof(u->ut_name)); 745 705 (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 747 711 } 748 712 749 713 static slot_t … … 890 854 return u->ut_type == u2->ut_type ? u : 0; 891 855 } 892 856 #endif 893