Changeset 988 for vendor/current/source3/smbd/utmp.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/utmp.c
r740 r988 116 116 117 117 void sys_utmp_claim(const char *username, const char *hostname, 118 const char *ip_addr_str, 119 const char *id_str, int id_num) 118 const char *id_str, int id_num) 120 119 {} 121 120 122 121 void sys_utmp_yield(const char *username, const char *hostname, 123 const char *ip_addr_str, 124 const char *id_str, int id_num) 122 const char *id_str, int id_num) 125 123 {} 126 124 127 125 #else /* WITH_UTMP */ 128 126 127 #ifdef HAVE_UTMP_H 129 128 #include <utmp.h> 129 #endif 130 130 131 131 #ifdef HAVE_UTMPX_H … … 219 219 /* For w-files, first look for explicit "wtmp dir" */ 220 220 if (uw_name[0] == 'w') { 221 dirname = talloc_strdup(ctx, lp_wtmp dir());221 dirname = talloc_strdup(ctx, lp_wtmp_directory()); 222 222 if (!dirname) { 223 223 return NULL; … … 228 228 /* For u-files and non-explicit w-dir, look for "utmp dir" */ 229 229 if ((dirname == NULL) || (strlen(dirname) == 0)) { 230 dirname = talloc_strdup(ctx, lp_utmp dir());230 dirname = talloc_strdup(ctx, lp_utmp_directory()); 231 231 if (!dirname) { 232 232 return NULL; … … 473 473 const char *ut_id_encstr = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 474 474 475 fourbyte[0] = 'S';476 fourbyte[1] = 'M';477 478 475 /* 479 * Encode remaining 2 bytes from 'i'.480 476 * 'ut_id_encstr' is the character set on which modulo arithmetic is done. 481 477 * Example: digits would produce the base-10 numbers from '001'. … … 483 479 nbase = strlen(ut_id_encstr); 484 480 481 fourbyte[0] = ut_id_encstr[i % nbase]; 482 i /= nbase; 483 fourbyte[1] = ut_id_encstr[i % nbase]; 484 i /= nbase; 485 485 fourbyte[3] = ut_id_encstr[i % nbase]; 486 486 i /= nbase; … … 488 488 i /= nbase; 489 489 490 return(i); /* 0: good; else overflow */ 490 /* we do not care about overflows as i is a random number */ 491 return 0; 491 492 } 492 493 #endif /* defined(HAVE_UT_UT_ID) */ … … 498 499 static bool sys_utmp_fill(struct utmp *u, 499 500 const char *username, const char *hostname, 500 const char *ip_addr_str,501 501 const char *id_str, int id_num) 502 502 { … … 519 519 * If size limit proves troublesome, then perhaps use "ut_id_encode()". 520 520 */ 521 if (strlen(id_str) > sizeof(u->ut_line)) {522 DEBUG(1,("id_str [%s] is too long for %lu char utmp field\n",523 id_str, (unsigned long)sizeof(u->ut_line)));524 return False;525 }526 521 utmp_strcpy(u->ut_line, id_str, sizeof(u->ut_line)); 527 522 528 523 #if defined(HAVE_UT_UT_PID) 529 u->ut_pid = sys_getpid();524 u->ut_pid = getpid(); 530 525 #endif 531 526 … … 549 544 utmp_strcpy(u->ut_host, hostname, sizeof(u->ut_host)); 550 545 #endif 551 #if defined(HAVE_IPV6) && defined(HAVE_UT_UT_ADDR_V6)552 memset(&u->ut_addr_v6, '\0', sizeof(u->ut_addr_v6));553 if (ip_addr_str) {554 struct in6_addr addr;555 if (inet_pton(AF_INET6, ip_addr_str, &addr) > 0) {556 memcpy(&u->ut_addr_v6, &addr, sizeof(addr));557 }558 }559 #elif defined(HAVE_UT_UT_ADDR)560 memset(&u->ut_addr, '\0', sizeof(u->ut_addr));561 if (ip_addr_str) {562 struct in_addr addr;563 if (inet_pton(AF_INET, ip_addr_str, &addr) > 0) {564 memcpy(&u->ut_addr, &addr, sizeof(addr));565 }566 }567 /*568 * "(unsigned long) ut_addr" apparently exists on at least HP-UX 10.20.569 * Volunteer to implement, please ...570 */571 #endif572 546 573 547 #if defined(HAVE_UT_UT_ID) … … 586 560 587 561 void sys_utmp_yield(const char *username, const char *hostname, 588 const char *ip_addr_str, 589 const char *id_str, int id_num) 562 const char *id_str, int id_num) 590 563 { 591 564 struct utmp u; … … 602 575 #endif 603 576 604 if (!sys_utmp_fill(&u, username, hostname, i p_addr_str, id_str, id_num))577 if (!sys_utmp_fill(&u, username, hostname, id_str, id_num)) 605 578 return; 606 579 … … 613 586 614 587 void sys_utmp_claim(const char *username, const char *hostname, 615 const char *ip_addr_str, 616 const char *id_str, int id_num) 588 const char *id_str, int id_num) 617 589 { 618 590 struct utmp u; … … 624 596 #endif 625 597 626 if (!sys_utmp_fill(&u, username, hostname, i p_addr_str, id_str, id_num))598 if (!sys_utmp_fill(&u, username, hostname, id_str, id_num)) 627 599 return; 628 600
Note:
See TracChangeset
for help on using the changeset viewer.