Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/nsswitch/wins.c

    r427 r740  
    2020
    2121#include "includes.h"
     22#include "nsswitch/winbind_nss.h"
     23
    2224#ifdef HAVE_NS_API_H
    2325
     
    3840
    3941static int initialised;
    40 
    41 extern bool AllowDebugChange;
    4242
    4343NSS_STATUS _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
     
    4646                           char *buffer, size_t buflen, int *h_errnop);
    4747
    48 /* Use our own create socket code so we don't recurse.... */
    49 
    50 static int wins_lookup_open_socket_in(void)
    51 {
    52         struct sockaddr_in sock;
    53         int val=1;
    54         int res;
    55 
    56         memset((char *)&sock,'\0',sizeof(sock));
    57 
    58 #ifdef HAVE_SOCK_SIN_LEN
    59         sock.sin_len = sizeof(sock);
    60 #endif
    61         sock.sin_port = 0;
    62         sock.sin_family = AF_INET;
    63         sock.sin_addr.s_addr = interpret_addr("0.0.0.0");
    64         res = socket(AF_INET, SOCK_DGRAM, 0);
    65         if (res == -1)
    66                 return -1;
    67 
    68         if (setsockopt(res,SOL_SOCKET,SO_REUSEADDR,(char *)&val,sizeof(val)) != 0) {
    69                 close(res);
    70                 return -1;
    71         }
    72 #ifdef SO_REUSEPORT
    73         if (setsockopt(res,SOL_SOCKET,SO_REUSEPORT,(char *)&val,sizeof(val)) != 0) {
    74                 close(res);
    75                 return -1;
    76         }
    77 #endif /* SO_REUSEPORT */
    78 
    79         /* now we've got a socket - we need to bind it */
    80 
    81         if (bind(res, (struct sockaddr * ) &sock,sizeof(sock)) < 0) {
    82                 close(res);
    83                 return(-1);
    84         }
    85 
    86         set_socket_options(res,"SO_BROADCAST");
    87 
    88         return res;
    89 }
    90 
    91 
    9248static void nss_wins_init(void)
    9349{
    9450        initialised = 1;
    95         DEBUGLEVEL = 0;
    96         AllowDebugChange = False;
     51        load_case_tables_library();
     52        lp_set_cmdline("log level", "0");
    9753
    9854        TimeInit();
    9955        setup_logging("nss_wins",False);
    100         load_case_tables();
    10156        lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
    10257        load_interfaces();
     
    10560static struct in_addr *lookup_byname_backend(const char *name, int *count)
    10661{
    107         int fd = -1;
    10862        struct ip_service *address = NULL;
    10963        struct in_addr *ret = NULL;
    110         int j, flags = 0;
     64        int j;
    11165
    11266        if (!initialised) {
     
    12781                        return NULL;
    12882                }
    129                 *ret = ((struct sockaddr_in *)&address[0].ss)->sin_addr;
     83                *ret = ((struct sockaddr_in *)(void *)&address[0].ss)
     84                        ->sin_addr;
    13085                free( address );
    13186                return ret;
    132         }
    133 
    134         fd = wins_lookup_open_socket_in();
    135         if (fd == -1) {
    136                 return NULL;
    13787        }
    13888
     
    14292                struct sockaddr_storage ss;
    14393                struct sockaddr_storage *pss;
     94                NTSTATUS status;
     95
    14496                if (!bcast) {
    14597                        continue;
    14698                }
    14799                in_addr_to_sockaddr_storage(&ss, *bcast);
    148                 pss = name_query(fd,name,0x00,True,True,&ss,count, &flags, NULL);
    149                 if (pss) {
     100                status = name_query(name, 0x00, True, True, &ss,
     101                                    NULL, &pss, count, NULL);
     102                if (NT_STATUS_IS_OK(status) && (*count > 0)) {
    150103                        if ((ret = SMB_MALLOC_P(struct in_addr)) == NULL) {
    151104                                return NULL;
    152105                        }
    153106                        *ret = ((struct sockaddr_in *)pss)->sin_addr;
     107                        TALLOC_FREE(pss);
    154108                        break;
    155109                }
    156110        }
    157111
    158         close(fd);
    159112        return ret;
    160113}
     
    162115#ifdef HAVE_NS_API_H
    163116
    164 static NODE_STATUS_STRUCT *lookup_byaddr_backend(char *addr, int *count)
    165 {
    166         int fd;
     117static struct node_status *lookup_byaddr_backend(char *addr, int *count)
     118{
    167119        struct sockaddr_storage ss;
    168120        struct nmb_name nname;
    169         NODE_STATUS_STRUCT *status;
     121        struct node_status *result;
     122        NTSTATUS status;
    170123
    171124        if (!initialised) {
    172125                nss_wins_init();
    173126        }
    174 
    175         fd = wins_lookup_open_socket_in();
    176         if (fd == -1)
    177                 return NULL;
    178127
    179128        make_nmb_name(&nname, "*", 0);
     
    181130                return NULL;
    182131        }
    183         status = node_status_query(fd, &nname, &ss, count, NULL);
    184 
    185         close(fd);
    186         return status;
     132        status = node_status_query(NULL, &nname, &ss, &result, count, NULL);
     133        if (!NT_STATUS_IS_OK(status)) {
     134                return NULL;
     135        }
     136
     137        return result;
    187138}
    188139
     
    202153        char *addr;
    203154        struct in_addr *ip_list;
    204         NODE_STATUS_STRUCT *status;
     155        struct node_status *status;
    205156        int i, count, len, size;
    206157        char response[1024];
     
    234185                    size = strlen(key) + 1;
    235186                    if (size > len) {
    236                         free(status);
     187                        talloc_free(status);
    237188                        return NSD_ERROR;
    238189                    }
     
    246197                                size = sizeof(status[i].name) + 1;
    247198                                if (size > len) {
    248                                     free(status);
     199                                    talloc_free(status);
    249200                                    return NSD_ERROR;
    250201                                }
     
    256207                    }
    257208                    response[strlen(response)-1] = '\n';
    258                     free(status);
     209                    talloc_free(status);
    259210                }
    260211        } else if (StrCaseCmp(map,"hosts.byname") == 0) {
Note: See TracChangeset for help on using the changeset viewer.