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/source3/libads/ldap.c

    r581 r740  
    2323
    2424#include "includes.h"
    25 #include "lib/ldb/include/ldb.h"
     25#include "ads.h"
     26#include "libads/sitename_cache.h"
     27#include "libads/cldap.h"
     28#include "libads/dns.h"
     29#include "../libds/common/flags.h"
     30#include "smbldap.h"
     31#include "../libcli/security/security.h"
    2632
    2733#ifdef HAVE_LDAP
     
    4955****************************************************************/
    5056
    51 static void gotalarm_sig(void)
     57static void gotalarm_sig(int signum)
    5258{
    5359        gotalarm = 1;
     
    6470        /* Setup timeout */
    6571        gotalarm = 0;
    66         CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
     72        CatchSignal(SIGALRM, gotalarm_sig);
    6773        alarm(to);
    6874        /* End setup timeout. */
     
    7884
    7985        /* Teardown timeout. */
    80         CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
     86        CatchSignal(SIGALRM, SIG_IGN);
    8187        alarm(0);
    8288
     
    104110        /* Setup alarm timeout.... Do we need both of these ? JRA. */
    105111        gotalarm = 0;
    106         CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
     112        CatchSignal(SIGALRM, gotalarm_sig);
    107113        alarm(lp_ldap_timeout());
    108114        /* End setup timeout. */
     
    113119
    114120        /* Teardown timeout. */
    115         CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN);
     121        CatchSignal(SIGALRM, SIG_IGN);
    116122        alarm(0);
    117123
     
    265271                        SMB_STRDUP(cldap_reply.client_site);
    266272        }
    267         ads->server.workgroup          = SMB_STRDUP(cldap_reply.domain);
     273        ads->server.workgroup          = SMB_STRDUP(cldap_reply.domain_name);
    268274
    269275        ads->ldap.port = gc ? LDAP_GC_PORT : LDAP_PORT;
     
    277283
    278284        /* Store our site name. */
    279         sitename_store( cldap_reply.domain, cldap_reply.client_site);
     285        sitename_store( cldap_reply.domain_name, cldap_reply.client_site);
    280286        sitename_store( cldap_reply.dns_domain, cldap_reply.client_site);
    281287
     
    593599
    594600        ZERO_STRUCT(ads->ldap);
    595         ads->ldap.last_attempt  = time(NULL);
     601        ads->ldap.last_attempt  = time_mono(NULL);
    596602        ads->ldap.wrap_type     = ADS_SASLWRAP_TYPE_PLAIN;
    597603
     
    16021608        if (!org_unit || !*org_unit) {
    16031609
    1604                 ret = ads_default_ou_string(ads, WELL_KNOWN_GUID_COMPUTERS);
     1610                ret = ads_default_ou_string(ads, DS_GUID_COMPUTERS_CONTAINER);
    16051611
    16061612                /* samba4 might not yet respond to a wellknownobject-query */
     
    21232129        int i;
    21242130        for (i=0; values[i]; i++) {
    2125 
    2126                 UUID_FLAT guid;
    2127                 struct GUID tmp;
    2128 
    2129                 memcpy(guid.info, values[i]->bv_val, sizeof(guid.info));
    2130                 smb_uuid_unpack(guid, &tmp);
    2131                 printf("%s: %s\n", field, GUID_string(talloc_tos(), &tmp));
     2131                NTSTATUS status;
     2132                DATA_BLOB in = data_blob_const(values[i]->bv_val, values[i]->bv_len);
     2133                struct GUID guid;
     2134
     2135                status = GUID_from_ndr_blob(&in, &guid);
     2136                if (NT_STATUS_IS_OK(status)) {
     2137                        printf("%s: %s\n", field, GUID_string(talloc_tos(), &guid));
     2138                } else {
     2139                        printf("%s: INVALID GUID\n", field);
     2140                }
    21322141        }
    21332142}
     
    21402149        int i;
    21412150        for (i=0; values[i]; i++) {
    2142                 DOM_SID sid;
     2151                struct dom_sid sid;
    21432152                fstring tmp;
    21442153                if (!sid_parse(values[i]->bv_val, values[i]->bv_len, &sid)) {
    2145                         continue;
     2154                        return;
    21462155                }
    21472156                printf("%s: %s\n", field, sid_to_fstring(tmp, &sid));
     
    26052614 bool ads_pull_guid(ADS_STRUCT *ads, LDAPMessage *msg, struct GUID *guid)
    26062615{
    2607         char **values;
    2608         UUID_FLAT flat_guid;
    2609 
    2610         values = ldap_get_values(ads->ldap.ld, msg, "objectGUID");
    2611         if (!values)
    2612                 return False;
    2613 
    2614         if (values[0]) {
    2615                 memcpy(&flat_guid.info, values[0], sizeof(UUID_FLAT));
    2616                 smb_uuid_unpack(flat_guid, guid);
    2617                 ldap_value_free(values);
    2618                 return True;
    2619         }
    2620         ldap_value_free(values);
    2621         return False;
    2622 
    2623 }
    2624 
    2625 
    2626 /**
    2627  * pull a single DOM_SID from a ADS result
     2616        DATA_BLOB blob;
     2617        NTSTATUS status;
     2618
     2619        if (!smbldap_talloc_single_blob(talloc_tos(), ads->ldap.ld, msg, "objectGUID",
     2620                                        &blob)) {
     2621                return false;
     2622        }
     2623
     2624        status = GUID_from_ndr_blob(&blob, guid);
     2625        talloc_free(blob.data);
     2626        return NT_STATUS_IS_OK(status);
     2627}
     2628
     2629
     2630/**
     2631 * pull a single struct dom_sid from a ADS result
    26282632 * @param ads connection to ads server
    26292633 * @param msg Results of search
     
    26332637*/
    26342638 bool ads_pull_sid(ADS_STRUCT *ads, LDAPMessage *msg, const char *field,
    2635                    DOM_SID *sid)
     2639                   struct dom_sid *sid)
    26362640{
    26372641        return smbldap_pull_sid(ads->ldap.ld, msg, field, sid);
     
    26392643
    26402644/**
    2641  * pull an array of DOM_SIDs from a ADS result
     2645 * pull an array of struct dom_sids from a ADS result
    26422646 * @param ads connection to ads server
    26432647 * @param mem_ctx TALLOC_CTX for allocating sid array
     
    26482652 **/
    26492653 int ads_pull_sids(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx,
    2650                    LDAPMessage *msg, const char *field, DOM_SID **sids)
     2654                   LDAPMessage *msg, const char *field, struct dom_sid **sids)
    26512655{
    26522656        struct berval **values;
     
    26632667
    26642668        if (i) {
    2665                 (*sids) = TALLOC_ARRAY(mem_ctx, DOM_SID, i);
     2669                (*sids) = TALLOC_ARRAY(mem_ctx, struct dom_sid, i);
    26662670                if (!(*sids)) {
    26672671                        ldap_value_free_len(values);
     
    26872691
    26882692/**
    2689  * pull a SEC_DESC from a ADS result
     2693 * pull a struct security_descriptor from a ADS result
    26902694 * @param ads connection to ads server
    26912695 * @param mem_ctx TALLOC_CTX for allocating sid array
    26922696 * @param msg Results of search
    26932697 * @param field Attribute to retrieve
    2694  * @param sd Pointer to *SEC_DESC to store result (talloc()ed)
     2698 * @param sd Pointer to *struct security_descriptor to store result (talloc()ed)
    26952699 * @return boolean inidicating success
    26962700*/
    26972701 bool ads_pull_sd(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx,
    2698                   LDAPMessage *msg, const char *field, SEC_DESC **sd)
     2702                  LDAPMessage *msg, const char *field,
     2703                  struct security_descriptor **sd)
    26992704{
    27002705        struct berval **values;
     
    29282933 * @return status of search
    29292934 **/
    2930 ADS_STATUS ads_domain_sid(ADS_STRUCT *ads, DOM_SID *sid)
     2935ADS_STATUS ads_domain_sid(ADS_STRUCT *ads, struct dom_sid *sid)
    29312936{
    29322937        const char *attrs[] = {"objectSid", NULL};
     
    31673172
    31683173/**
    3169  * pull a DOM_SID from an extended dn string
     3174 * pull a struct dom_sid from an extended dn string
    31703175 * @param mem_ctx TALLOC_CTX
    31713176 * @param extended_dn string
    31723177 * @param flags string type of extended_dn
    3173  * @param sid pointer to a DOM_SID
     3178 * @param sid pointer to a struct dom_sid
    31743179 * @return NT_STATUS_OK on success,
    31753180 *         NT_INVALID_PARAMETER on error,
     
    31793184                                        const char *extended_dn,
    31803185                                        enum ads_extended_dn_flags flags,
    3181                                         DOM_SID *sid)
     3186                                        struct dom_sid *sid)
    31823187{
    31833188        char *p, *q, *dn;
     
    32543259
    32553260/**
    3256  * pull an array of DOM_SIDs from a ADS result
     3261 * pull an array of struct dom_sids from a ADS result
    32573262 * @param ads connection to ads server
    32583263 * @param mem_ctx TALLOC_CTX for allocating sid array
     
    32683273                                   const char *field,
    32693274                                   enum ads_extended_dn_flags flags,
    3270                                    DOM_SID **sids)
     3275                                   struct dom_sid **sids)
    32713276{
    32723277        int i;
     
    32803285        }
    32813286
    3282         (*sids) = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, dn_count + 1);
     3287        (*sids) = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, dn_count + 1);
    32833288        if (!(*sids)) {
    32843289                TALLOC_FREE(dn_strings);
     
    34983503
    34993504        hostnameDN = ads_get_dn(ads, talloc_tos(), (LDAPMessage *)msg);
     3505        if (hostnameDN == NULL) {
     3506                SAFE_FREE(host);
     3507                return ADS_ERROR_SYSTEM(ENOENT);
     3508        }
    35003509
    35013510        rc = ldap_delete_ext_s(ads->ldap.ld, hostnameDN, pldap_control, NULL);
     
    35853594 * @param mem_ctx TALLOC_CTX for allocating sid array
    35863595 * @param dn of LDAP object
    3587  * @param user_sid pointer to DOM_SID (objectSid)
    3588  * @param primary_group_sid pointer to DOM_SID (self composed)
     3596 * @param user_sid pointer to struct dom_sid (objectSid)
     3597 * @param primary_group_sid pointer to struct dom_sid (self composed)
    35893598 * @param sids pointer to sid array to allocate
    35903599 * @param num_sids counter of SIDs pulled
     
    35943603                              TALLOC_CTX *mem_ctx,
    35953604                              const char *dn,
    3596                               DOM_SID *user_sid,
    3597                               DOM_SID *primary_group_sid,
    3598                               DOM_SID **sids,
     3605                              struct dom_sid *user_sid,
     3606                              struct dom_sid *primary_group_sid,
     3607                              struct dom_sid **sids,
    35993608                              size_t *num_sids)
    36003609{
     
    36033612        int count = 0;
    36043613        size_t tmp_num_sids;
    3605         DOM_SID *tmp_sids;
    3606         DOM_SID tmp_user_sid;
    3607         DOM_SID tmp_primary_group_sid;
     3614        struct dom_sid *tmp_sids;
     3615        struct dom_sid tmp_user_sid;
     3616        struct dom_sid tmp_primary_group_sid;
    36083617        uint32 pgid;
    36093618        const char *attrs[] = {
     
    36393648                 * domsid */
    36403649
    3641                 DOM_SID domsid;
    3642                 uint32 dummy_rid;
     3650                struct dom_sid domsid;
    36433651
    36443652                sid_copy(&domsid, &tmp_user_sid);
    36453653
    3646                 if (!sid_split_rid(&domsid, &dummy_rid)) {
     3654                if (!sid_split_rid(&domsid, NULL)) {
    36473655                        ads_msgfree(ads, res);
    36483656                        return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
Note: See TracChangeset for help on using the changeset viewer.