Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/smbd/utmp.c

    r740 r988  
    116116
    117117void 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)
    120119{}
    121120
    122121void 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)
    125123{}
    126124
    127125#else /* WITH_UTMP */
    128126
     127#ifdef HAVE_UTMP_H
    129128#include <utmp.h>
     129#endif
    130130
    131131#ifdef HAVE_UTMPX_H
     
    219219        /* For w-files, first look for explicit "wtmp dir" */
    220220        if (uw_name[0] == 'w') {
    221                 dirname = talloc_strdup(ctx, lp_wtmpdir());
     221                dirname = talloc_strdup(ctx, lp_wtmp_directory());
    222222                if (!dirname) {
    223223                        return NULL;
     
    228228        /* For u-files and non-explicit w-dir, look for "utmp dir" */
    229229        if ((dirname == NULL) || (strlen(dirname) == 0)) {
    230                 dirname = talloc_strdup(ctx, lp_utmpdir());
     230                dirname = talloc_strdup(ctx, lp_utmp_directory());
    231231                if (!dirname) {
    232232                        return NULL;
     
    473473        const char *ut_id_encstr = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    474474
    475         fourbyte[0] = 'S';
    476         fourbyte[1] = 'M';
    477 
    478475/*
    479  * Encode remaining 2 bytes from 'i'.
    480476 * 'ut_id_encstr' is the character set on which modulo arithmetic is done.
    481477 * Example: digits would produce the base-10 numbers from '001'.
     
    483479        nbase = strlen(ut_id_encstr);
    484480
     481        fourbyte[0] = ut_id_encstr[i % nbase];
     482        i /= nbase;
     483        fourbyte[1] = ut_id_encstr[i % nbase];
     484        i /= nbase;
    485485        fourbyte[3] = ut_id_encstr[i % nbase];
    486486        i /= nbase;
     
    488488        i /= nbase;
    489489
    490         return(i);      /* 0: good; else overflow */
     490        /* we do not care about overflows as i is a random number */
     491        return 0;
    491492}
    492493#endif /* defined(HAVE_UT_UT_ID) */
     
    498499static bool sys_utmp_fill(struct utmp *u,
    499500                        const char *username, const char *hostname,
    500                         const char *ip_addr_str,
    501501                        const char *id_str, int id_num)
    502502{
     
    519519         *      If size limit proves troublesome, then perhaps use "ut_id_encode()".
    520520         */
    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         }
    526521        utmp_strcpy(u->ut_line, id_str, sizeof(u->ut_line));
    527522
    528523#if defined(HAVE_UT_UT_PID)
    529         u->ut_pid = sys_getpid();
     524        u->ut_pid = getpid();
    530525#endif
    531526
     
    549544        utmp_strcpy(u->ut_host, hostname, sizeof(u->ut_host));
    550545#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 #endif
    572546
    573547#if defined(HAVE_UT_UT_ID)
     
    586560
    587561void 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)
    590563{
    591564        struct utmp u;
     
    602575#endif
    603576
    604         if (!sys_utmp_fill(&u, username, hostname, ip_addr_str, id_str, id_num))
     577        if (!sys_utmp_fill(&u, username, hostname, id_str, id_num))
    605578                return;
    606579
     
    613586
    614587void 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)
    617589{
    618590        struct utmp u;
     
    624596#endif
    625597
    626         if (!sys_utmp_fill(&u, username, hostname, ip_addr_str, id_str, id_num))
     598        if (!sys_utmp_fill(&u, username, hostname, id_str, id_num))
    627599                return;
    628600
Note: See TracChangeset for help on using the changeset viewer.