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

Location:
vendor/current/libcli/nbt
Files:
1 added
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/libcli/nbt/libnbt.h

    r740 r988  
    2525#include "librpc/gen_ndr/nbt.h"
    2626#include "librpc/ndr/libndr.h"
    27 #include "system/network.h"
     27#include "lib/util/xfile.h"
     28
    2829/*
    2930  possible states for pending requests
     
    335336
    336337
    337 NDR_SCALAR_PROTO(wrepl_nbt_name, const struct nbt_name *)
    338 NDR_SCALAR_PROTO(nbt_string, const char *)
     338NDR_SCALAR_PTR_PROTO(wrepl_nbt_name, struct nbt_name)
    339339NDR_BUFFER_PROTO(nbt_name, struct nbt_name)
    340340NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode);
     
    373373                                          int *return_count);
    374374
    375 NTSTATUS resolve_dns_hosts_file_as_sockaddr(const char *dns_hosts_file,
    376                                             const char *name, bool srv_lookup,
    377                                             TALLOC_CTX *mem_ctx,
    378                                             struct sockaddr_storage **return_iplist,
    379                                             int *return_count);
    380 
    381375#endif /* __LIBNBT_H__ */
  • vendor/current/libcli/nbt/namerefresh.c

    r740 r988  
    332332
    333333        if (!tevent_req_poll(subreq, ev)) {
    334                 status = map_nt_error_from_unix(errno);
     334                status = map_nt_error_from_unix_common(errno);
    335335                talloc_free(frame);
    336336                return status;
  • vendor/current/libcli/nbt/nameregister.c

    r740 r988  
    284284
    285285        if (!tevent_req_poll(subreq, ev)) {
    286                 status = map_nt_error_from_unix(errno);
     286                status = map_nt_error_from_unix_common(errno);
    287287                talloc_free(frame);
    288288                return status;
     
    499499
    500500        if (!tevent_req_poll(subreq, ev)) {
    501                 status = map_nt_error_from_unix(errno);
     501                status = map_nt_error_from_unix_common(errno);
    502502                talloc_free(frame);
    503503                return status;
  • vendor/current/libcli/nbt/nbtname.c

    r740 r988  
    2929#include "system/locale.h"
    3030#include "lib/util/util_net.h"
    31 
    32 /* don't allow an unlimited number of name components */
    33 #define MAX_COMPONENTS 10
    34 
    35 /**
    36   print a nbt string
    37 */
    38 _PUBLIC_ void ndr_print_nbt_string(struct ndr_print *ndr, const char *name, const char *s)
    39 {
    40         ndr_print_string(ndr, name, s);
    41 }
    42 
    43 /*
    44   pull one component of a nbt_string
    45 */
    46 static enum ndr_err_code ndr_pull_component(struct ndr_pull *ndr,
    47                                             uint8_t **component,
    48                                             uint32_t *offset,
    49                                             uint32_t *max_offset)
    50 {
    51         uint8_t len;
    52         unsigned int loops = 0;
    53         while (loops < 5) {
    54                 if (*offset >= ndr->data_size) {
    55                         return ndr_pull_error(ndr, NDR_ERR_STRING,
    56                                               "BAD NBT NAME component");
    57                 }
    58                 len = ndr->data[*offset];
    59                 if (len == 0) {
    60                         *offset += 1;
    61                         *max_offset = MAX(*max_offset, *offset);
    62                         *component = NULL;
    63                         return NDR_ERR_SUCCESS;
    64                 }
    65                 if ((len & 0xC0) == 0xC0) {
    66                         /* its a label pointer */
    67                         if (1 + *offset >= ndr->data_size) {
    68                                 return ndr_pull_error(ndr, NDR_ERR_STRING,
    69                                                       "BAD NBT NAME component");
    70                         }
    71                         *max_offset = MAX(*max_offset, *offset + 2);
    72                         *offset = ((len&0x3F)<<8) | ndr->data[1 + *offset];
    73                         *max_offset = MAX(*max_offset, *offset);
    74                         loops++;
    75                         continue;
    76                 }
    77                 if ((len & 0xC0) != 0) {
    78                         /* its a reserved length field */
    79                         return ndr_pull_error(ndr, NDR_ERR_STRING,
    80                                               "BAD NBT NAME component");
    81                 }
    82                 if (*offset + len + 2 > ndr->data_size) {
    83                         return ndr_pull_error(ndr, NDR_ERR_STRING,
    84                                               "BAD NBT NAME component");
    85                 }
    86                 *component = (uint8_t*)talloc_strndup(
    87                         ndr->current_mem_ctx,
    88                         (const char *)&ndr->data[1 + *offset], len);
    89                 NDR_ERR_HAVE_NO_MEMORY(*component);
    90                 *offset += len + 1;
    91                 *max_offset = MAX(*max_offset, *offset);
    92                 return NDR_ERR_SUCCESS;
    93         }
    94 
    95         /* too many pointers */
    96         return ndr_pull_error(ndr, NDR_ERR_STRING, "BAD NBT NAME component");
    97 }
    98 
    99 /**
    100   pull a nbt_string from the wire
    101 */
    102 _PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
    103 {
    104         uint32_t offset = ndr->offset;
    105         uint32_t max_offset = offset;
    106         unsigned num_components;
    107         char *name;
    108 
    109         if (!(ndr_flags & NDR_SCALARS)) {
    110                 return NDR_ERR_SUCCESS;
    111         }
    112 
    113         name = NULL;
    114 
    115         /* break up name into a list of components */
    116         for (num_components=0;num_components<MAX_COMPONENTS;num_components++) {
    117                 uint8_t *component = NULL;
    118                 NDR_CHECK(ndr_pull_component(ndr, &component, &offset, &max_offset));
    119                 if (component == NULL) break;
    120                 if (name) {
    121                         name = talloc_asprintf_append_buffer(name, ".%s", component);
    122                         NDR_ERR_HAVE_NO_MEMORY(name);
    123                 } else {
    124                         name = (char *)component;
    125                 }
    126         }
    127         if (num_components == MAX_COMPONENTS) {
    128                 return ndr_pull_error(ndr, NDR_ERR_STRING,
    129                                       "BAD NBT NAME too many components");
    130         }
    131         if (num_components == 0) {
    132                 name = talloc_strdup(ndr->current_mem_ctx, "");
    133                 NDR_ERR_HAVE_NO_MEMORY(name);
    134         }
    135 
    136         (*s) = name;
    137         ndr->offset = max_offset;
    138 
    139         return NDR_ERR_SUCCESS;
    140 }
    141 
    142 /**
    143   push a nbt string to the wire
    144 */
    145 _PUBLIC_ enum ndr_err_code ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s)
    146 {
    147         if (!(ndr_flags & NDR_SCALARS)) {
    148                 return NDR_ERR_SUCCESS;
    149         }
    150 
    151         while (s && *s) {
    152                 enum ndr_err_code ndr_err;
    153                 char *compname;
    154                 size_t complen;
    155                 uint32_t offset;
    156 
    157                 /* see if we have pushed the remaing string allready,
    158                  * if so we use a label pointer to this string
    159                  */
    160                 ndr_err = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false);
    161                 if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    162                         uint8_t b[2];
    163 
    164                         if (offset > 0x3FFF) {
    165                                 return ndr_push_error(ndr, NDR_ERR_STRING,
    166                                                       "offset for nbt string label pointer %u[%08X] > 0x00003FFF",
    167                                                       offset, offset);
    168                         }
    169 
    170                         b[0] = 0xC0 | (offset>>8);
    171                         b[1] = (offset & 0xFF);
    172 
    173                         return ndr_push_bytes(ndr, b, 2);
    174                 }
    175 
    176                 complen = strcspn(s, ".");
    177 
    178                 /* we need to make sure the length fits into 6 bytes */
    179                 if (complen > 0x3F) {
    180                         return ndr_push_error(ndr, NDR_ERR_STRING,
    181                                               "component length %u[%08X] > 0x0000003F",
    182                                               (unsigned)complen, (unsigned)complen);
    183                 }
    184 
    185                 compname = talloc_asprintf(ndr, "%c%*.*s",
    186                                                 (unsigned char)complen,
    187                                                 (unsigned char)complen,
    188                                                 (unsigned char)complen, s);
    189                 NDR_ERR_HAVE_NO_MEMORY(compname);
    190 
    191                 /* remember the current componemt + the rest of the string
    192                  * so it can be reused later
    193                  */
    194                 NDR_CHECK(ndr_token_store(ndr, &ndr->nbt_string_list, s, ndr->offset));
    195 
    196                 /* push just this component into the blob */
    197                 NDR_CHECK(ndr_push_bytes(ndr, (const uint8_t *)compname, complen+1));
    198                 talloc_free(compname);
    199 
    200                 s += complen;
    201                 if (*s == '.') s++;
    202         }
    203 
    204         /* if we reach the end of the string and have pushed the last component
    205          * without using a label pointer, we need to terminate the string
    206          */
    207         return ndr_push_bytes(ndr, (const uint8_t *)"", 1);
    208 }
    209 
     31#include "libcli/nbt/libnbt.h"
    21032
    21133/*
     
    503325  pull a nbt name, WINS Replication uses another on wire format for nbt name
    504326*/
    505 _PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, const struct nbt_name **_r)
     327_PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name **_r)
    506328{
    507329        struct nbt_name *r;
  • vendor/current/libcli/nbt/nbtsocket.c

    r740 r988  
    5151        }
    5252        if (req->nbtsock->send_queue == NULL) {
    53                 EVENT_FD_NOT_WRITEABLE(req->nbtsock->fde);
     53                TEVENT_FD_NOT_WRITEABLE(req->nbtsock->fde);
    5454        }
    5555        if (req->nbtsock->num_pending == 0 &&
    5656            req->nbtsock->incoming.handler == NULL) {
    57                 EVENT_FD_NOT_READABLE(req->nbtsock->fde);
     57                TEVENT_FD_NOT_READABLE(req->nbtsock->fde);
    5858        }
    5959        return 0;
     
    8888                        talloc_free(req);
    8989                } else {
    90                         EVENT_FD_READABLE(nbtsock->fde);
     90                        TEVENT_FD_READABLE(nbtsock->fde);
    9191                        nbtsock->num_pending++;
    9292                }
    9393        }
    9494
    95         EVENT_FD_NOT_WRITEABLE(nbtsock->fde);
     95        TEVENT_FD_NOT_WRITEABLE(nbtsock->fde);
    9696        talloc_free(tmp_ctx);
    9797        return;
     
    123123        if (req->num_retries != 0) {
    124124                req->num_retries--;
    125                 req->te = event_add_timed(req->nbtsock->event_ctx, req,
    126                                           timeval_add(&t, req->timeout, 0),
    127                                           nbt_name_socket_timeout, req);
     125                req->te = tevent_add_timer(req->nbtsock->event_ctx, req,
     126                                           timeval_add(&t, req->timeout, 0),
     127                                           nbt_name_socket_timeout, req);
    128128                if (req->state != NBT_REQUEST_SEND) {
    129129                        req->state = NBT_REQUEST_SEND;
    130                         DLIST_ADD_END(req->nbtsock->send_queue, req,
    131                                       struct nbt_name_request *);
    132                 }
    133                 EVENT_FD_WRITEABLE(req->nbtsock->fde);
     130                        DLIST_ADD_END(req->nbtsock->send_queue, req);
     131                }
     132                TEVENT_FD_WRITEABLE(req->nbtsock->fde);
    134133                return;
    135134        }
     
    274273                }
    275274                req->timeout = ttl;
    276                 req->te = event_add_timed(req->nbtsock->event_ctx, req,
    277                                           timeval_current_ofs(req->timeout, 0),
    278                                           nbt_name_socket_timeout, req);
     275                req->te = tevent_add_timer(req->nbtsock->event_ctx, req,
     276                                           timeval_current_ofs(req->timeout, 0),
     277                                           nbt_name_socket_timeout, req);
    279278                return;
    280279        }
     
    319318        struct nbt_name_socket *nbtsock = talloc_get_type(private_data,
    320319                                                          struct nbt_name_socket);
    321         if (flags & EVENT_FD_WRITE) {
     320        if (flags & TEVENT_FD_WRITE) {
    322321                nbt_name_socket_send(nbtsock);
    323322        }
    324         if (flags & EVENT_FD_READ) {
     323        if (flags & TEVENT_FD_READ) {
    325324                nbt_name_socket_recv(nbtsock);
    326325        }
     
    359358        nbtsock->unexpected.handler = NULL;
    360359
    361         nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock,
    362                                     socket_get_fd(nbtsock->sock), 0,
    363                                     nbt_name_socket_handler, nbtsock);
     360        nbtsock->fde = tevent_add_fd(nbtsock->event_ctx, nbtsock,
     361                                     socket_get_fd(nbtsock->sock), 0,
     362                                     nbt_name_socket_handler, nbtsock);
    364363
    365364        return nbtsock;
     
    408407        req->name_trn_id     = id;
    409408
    410         req->te = event_add_timed(nbtsock->event_ctx, req,
    411                                   timeval_current_ofs(req->timeout, 0),
    412                                   nbt_name_socket_timeout, req);
     409        req->te = tevent_add_timer(nbtsock->event_ctx, req,
     410                                   timeval_current_ofs(req->timeout, 0),
     411                                   nbt_name_socket_timeout, req);
    413412
    414413        talloc_set_destructor(req, nbt_name_request_destructor);
     
    419418        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) goto failed;
    420419
    421         DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *);
     420        DLIST_ADD_END(nbtsock->send_queue, req);
    422421
    423422        if (DEBUGLVL(10)) {
     
    427426        }
    428427
    429         EVENT_FD_WRITEABLE(nbtsock->fde);
     428        TEVENT_FD_WRITEABLE(nbtsock->fde);
    430429
    431430        return req;
     
    470469        }
    471470
    472         DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *);
    473 
    474         EVENT_FD_WRITEABLE(nbtsock->fde);
     471        DLIST_ADD_END(nbtsock->send_queue, req);
     472
     473        TEVENT_FD_WRITEABLE(nbtsock->fde);
    475474
    476475        return NT_STATUS_OK;
     
    489488
    490489        while (req->state < NBT_REQUEST_DONE) {
    491                 if (event_loop_once(req->nbtsock->event_ctx) != 0) {
     490                if (tevent_loop_once(req->nbtsock->event_ctx) != 0) {
    492491                        req->state = NBT_REQUEST_ERROR;
    493492                        req->status = NT_STATUS_UNEXPECTED_NETWORK_ERROR;
     
    509508        nbtsock->incoming.handler = handler;
    510509        nbtsock->incoming.private_data = private_data;
    511         EVENT_FD_READABLE(nbtsock->fde);
     510        TEVENT_FD_READABLE(nbtsock->fde);
    512511        return NT_STATUS_OK;
    513512}
     
    523522        nbtsock->unexpected.handler = handler;
    524523        nbtsock->unexpected.private_data = private_data;
    525         EVENT_FD_READABLE(nbtsock->fde);
     524        TEVENT_FD_READABLE(nbtsock->fde);
    526525        return NT_STATUS_OK;
    527526}
  • vendor/current/libcli/nbt/pynbt.c

    r740 r988  
    2121#include "includes.h"
    2222#include "libcli/util/pyerrors.h"
    23 #include "scripting/python/modules.h"
     23#include "python/modules.h"
    2424#include "../libcli/nbt/libnbt.h"
    2525#include "lib/events/events.h"
    2626
    2727void initnetbios(void);
    28 
    29 #ifndef Py_RETURN_NONE
    30 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
    31 #endif
    3228
    3329extern PyTypeObject nbt_node_Type;
  • vendor/current/libcli/nbt/tools/nmblookup.c

    r740 r988  
    3333#include "param/param.h"
    3434
     35#include <string.h>
     36
     37#define MAX_NETBIOSNAME_LEN 16
     38
    3539/* command line options */
    3640static struct {
     
    191195        struct nbt_name_socket *nbtsock;
    192196        NTSTATUS status = NT_STATUS_OK;
     197        size_t nbt_len;
    193198        bool ret = true;
    194199
     
    211216        } else {
    212217                node_name = talloc_strdup(tmp_ctx, name);
     218        }
     219
     220        nbt_len = strlen(node_name);
     221        if (nbt_len > MAX_NETBIOSNAME_LEN - 1) {
     222                printf("The specified netbios name [%s] is too long.\n",
     223                       node_name);
     224                talloc_free(tmp_ctx);
     225                return false;
    213226        }
    214227
     
    247260                int i, num_interfaces;
    248261
    249                 num_interfaces = iface_count(ifaces);
     262                num_interfaces = iface_list_count(ifaces);
    250263                for (i=0;i<num_interfaces;i++) {
    251                         const char *bcast = iface_n_bcast(ifaces, i);
     264                        const char *bcast = iface_list_n_bcast(ifaces, i);
    252265                        if (bcast == NULL) continue;
    253266                        status = do_node_query(nbtsock, bcast, nbt_port,
     
    358371        }
    359372
    360         load_interfaces(NULL, lpcfg_interfaces(cmdline_lp_ctx), &ifaces);
     373        load_interface_list(NULL, cmdline_lp_ctx, &ifaces);
    361374
    362375        ev = s4_event_context_init(talloc_autofree_context());
  • vendor/current/libcli/nbt/wscript_build

    r740 r988  
    1212                    )
    1313
    14 if bld.env._SAMBA_BUILD_ == 4:
    15     bld.SAMBA_LIBRARY('cli-nbt',
    16                       source='nbtsocket.c namequery.c nameregister.c namerefresh.c namerelease.c dns_hosts_file.c',
    17                       public_deps='ndr NDR_NBT tevent UTIL_TEVENT NDR_SECURITY samba_socket samba-util lmhosts',
    18                       private_library=True
    19                       )
     14bld.SAMBA_LIBRARY('cli-nbt',
     15                  source='nbtsocket.c namequery.c nameregister.c namerefresh.c namerelease.c',
     16                  public_deps='ndr ndr_nbt tevent tevent-util NDR_SECURITY samba_socket samba-util lmhosts',
     17                  private_library=True
     18                  )
    2019
    21     bld.SAMBA_BINARY('nmblookup',
    22                      source='tools/nmblookup.c',
    23                      manpages='man/nmblookup.1',
    24                      deps='samba-hostconfig samba-util cli-nbt popt POPT_SAMBA netif LIBCLI_RESOLVE'
    25                      )
     20bld.SAMBA_BINARY('nmblookup' + bld.env.suffix4,
     21                 source='tools/nmblookup.c',
     22                 manpages='man/nmblookup4.1',
     23                 deps='samba-hostconfig samba-util cli-nbt popt POPT_SAMBA netif LIBCLI_RESOLVE',
     24                 install=False
     25                 )
    2626
    27     bld.SAMBA_PYTHON('python_netbios',
    28                      source='pynbt.c',
    29                      public_deps='cli-nbt DYNCONFIG samba-hostconfig',
    30                      realname='samba/netbios.so'
    31                      )
     27bld.SAMBA_PYTHON('python_netbios',
     28                 source='pynbt.c',
     29                 public_deps='cli-nbt DYNCONFIG samba-hostconfig',
     30                 realname='samba/netbios.so'
     31                 )
    3232
Note: See TracChangeset for help on using the changeset viewer.