Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source4/lib/ldb/include/dlinklist.h

    r414 r745  
    22   Unix SMB/CIFS implementation.
    33   some simple double linked list macros
    4    Copyright (C) Andrew Tridgell 1998
     4
     5   Copyright (C) Andrew Tridgell 1998-2010
     6
     7     ** NOTE! The following LGPL license applies to the ldb
     8     ** library. This does NOT imply that all of Samba is released
     9     ** under the LGPL
    510   
    6    This program is free software; you can redistribute it and/or modify
    7    it under the terms of the GNU General Public License as published by
    8    the Free Software Foundation; either version 3 of the License, or
    9    (at your option) any later version.
    10    
    11    This program is distributed in the hope that it will be useful,
     11   This library is free software; you can redistribute it and/or
     12   modify it under the terms of the GNU Lesser General Public
     13   License as published by the Free Software Foundation; either
     14   version 3 of the License, or (at your option) any later version.
     15
     16   This library is distributed in the hope that it will be useful,
    1217   but WITHOUT ANY WARRANTY; without even the implied warranty of
    13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14    GNU General Public License for more details.
    15    
    16    You should have received a copy of the GNU General Public License
    17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     19   Lesser General Public License for more details.
     20
     21   You should have received a copy of the GNU Lesser General Public
     22   License along with this library; if not, see <http://www.gnu.org/licenses/>.
    1823*/
    1924
     
    2429#define _DLINKLIST_H
    2530
     31/*
     32  February 2010 - changed list format to have a prev pointer from the
     33  list head. This makes DLIST_ADD_END() O(1) even though we only have
     34  one list pointer.
    2635
    27 /* hook into the front of the list */
     36  The scheme is as follows:
     37
     38     1) with no entries in the list:
     39          list_head == NULL
     40
     41     2) with 1 entry in the list:
     42          list_head->next == NULL
     43          list_head->prev == list_head
     44
     45     3) with 2 entries in the list:
     46          list_head->next == element2
     47          list_head->prev == element2
     48          element2->prev == list_head
     49          element2->next == NULL
     50
     51     4) with N entries in the list:
     52          list_head->next == element2
     53          list_head->prev == elementN
     54          elementN->prev == element{N-1}
     55          elementN->next == NULL
     56
     57  This allows us to find the tail of the list by using
     58  list_head->prev, which means we can add to the end of the list in
     59  O(1) time
     60
     61
     62  Note that the 'type' arguments below are no longer needed, but
     63  are kept for now to prevent an incompatible argument change
     64 */
     65
     66
     67/*
     68   add an element at the front of a list
     69*/
    2870#define DLIST_ADD(list, p) \
    2971do { \
    3072        if (!(list)) { \
    31                 (list) = (p); \
    32                 (p)->next = (p)->prev = NULL; \
     73                (p)->prev = (list) = (p); \
     74                (p)->next = NULL; \
    3375        } else { \
     76                (p)->prev = (list)->prev; \
    3477                (list)->prev = (p); \
    3578                (p)->next = (list); \
    36                 (p)->prev = NULL; \
    3779                (list) = (p); \
    38         }\
     80        } \
    3981} while (0)
    4082
    41 /* remove an element from a list - element doesn't have to be in list. */
     83/*
     84   remove an element from a list
     85   Note that the element doesn't have to be in the list. If it
     86   isn't then this is a no-op
     87*/
    4288#define DLIST_REMOVE(list, p) \
    4389do { \
    4490        if ((p) == (list)) { \
     91                if ((p)->next) (p)->next->prev = (p)->prev; \
    4592                (list) = (p)->next; \
    46                 if (list) (list)->prev = NULL; \
     93        } else if ((list) && (p) == (list)->prev) {     \
     94                (p)->prev->next = NULL; \
     95                (list)->prev = (p)->prev; \
    4796        } else { \
    4897                if ((p)->prev) (p)->prev->next = (p)->next; \
    4998                if ((p)->next) (p)->next->prev = (p)->prev; \
    5099        } \
    51         if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \
     100        if ((p) != (list)) (p)->next = (p)->prev = NULL;        \
    52101} while (0)
    53102
    54 /* promote an element to the top of the list */
    55 #define DLIST_PROMOTE(list, p) \
     103/*
     104   find the head of the list given any element in it.
     105   Note that this costs O(N), so you should avoid this macro
     106   if at all possible!
     107*/
     108#define DLIST_HEAD(p, result_head) \
    56109do { \
    57           DLIST_REMOVE(list, p); \
    58           DLIST_ADD(list, p); \
    59 } while (0)
     110       (result_head) = (p); \
     111       while (DLIST_PREV(result_head)) (result_head) = (result_head)->prev; \
     112} while(0)
    60113
    61 /* hook into the end of the list - needs the entry type */
    62 #define DLIST_ADD_END(list, p, type) \
    63 do { \
    64                 if (!(list)) { \
    65                         (list) = (p); \
    66                         (p)->next = (p)->prev = NULL; \
    67                 } else { \
    68                         type tmp; \
    69                         for (tmp = (list); tmp->next; tmp = tmp->next) ; \
    70                         tmp->next = (p); \
    71                         (p)->next = NULL; \
    72                         (p)->prev = tmp; \
    73                 } \
    74 } while (0)
     114/* return the last element in the list */
     115#define DLIST_TAIL(list) ((list)?(list)->prev:NULL)
     116
     117/* return the previous element in the list. */
     118#define DLIST_PREV(p) (((p)->prev && (p)->prev->next != NULL)?(p)->prev:NULL)
    75119
    76120/* insert 'p' after the given element 'el' in a list. If el is NULL then
     
    81125                DLIST_ADD(list, p); \
    82126        } else { \
    83                 p->prev = el; \
    84                 p->next = el->next; \
    85                 el->next = p; \
    86                 if (p->next) p->next->prev = p; \
     127                (p)->prev = (el);   \
     128                (p)->next = (el)->next;         \
     129                (el)->next = (p);               \
     130                if ((p)->next) (p)->next->prev = (p);   \
     131                if ((list)->prev == (el)) (list)->prev = (p); \
    87132        }\
    88133} while (0)
    89134
    90 /* demote an element to the end of the list, needs the entry type */
    91 #define DLIST_DEMOTE(list, p, type) \
     135
     136/*
     137   add to the end of a list.
     138   Note that 'type' is ignored
     139*/
     140#define DLIST_ADD_END(list, p, type)                    \
    92141do { \
    93                 DLIST_REMOVE(list, p); \
    94                 DLIST_ADD_END(list, p, type); \
     142        if (!(list)) { \
     143                DLIST_ADD(list, p); \
     144        } else { \
     145                DLIST_ADD_AFTER(list, p, (list)->prev); \
     146        } \
    95147} while (0)
    96148
    97 /* concatenate two lists - putting all elements of the 2nd list at the
    98    end of the first list */
    99 #define DLIST_CONCATENATE(list1, list2, type) \
     149/* promote an element to the from of a list */
     150#define DLIST_PROMOTE(list, p) \
    100151do { \
    101                 if (!(list1)) { \
    102                         (list1) = (list2); \
    103                 } else { \
    104                         type tmp; \
    105                         for (tmp = (list1); tmp->next; tmp = tmp->next) ; \
    106                         tmp->next = (list2); \
    107                         if (list2) { \
    108                                 (list2)->prev = tmp;    \
    109                         } \
     152          DLIST_REMOVE(list, p); \
     153          DLIST_ADD(list, p); \
     154} while (0)
     155
     156/*
     157   demote an element to the end of a list.
     158   Note that 'type' is ignored
     159*/
     160#define DLIST_DEMOTE(list, p, type)                     \
     161do { \
     162        DLIST_REMOVE(list, p); \
     163        DLIST_ADD_END(list, p, NULL);           \
     164} while (0)
     165
     166/*
     167   concatenate two lists - putting all elements of the 2nd list at the
     168   end of the first list.
     169   Note that 'type' is ignored
     170*/
     171#define DLIST_CONCATENATE(list1, list2, type)   \
     172do { \
     173        if (!(list1)) { \
     174                (list1) = (list2); \
     175        } else { \
     176                (list1)->prev->next = (list2); \
     177                if (list2) { \
     178                        void *_tmplist = (void *)(list1)->prev; \
     179                        (list1)->prev = (list2)->prev; \
     180                        (list2)->prev = _tmplist; \
    110181                } \
     182        } \
    111183} while (0)
    112184
  • trunk/server/source4/lib/ldb/include/ldb.h

    r414 r745  
    4848
    4949#include <stdbool.h>
    50 #include "talloc.h"
    51 #include "tevent.h"
    52 #include "ldb_errors.h"
     50#include <talloc.h>
     51#include <tevent.h>
     52#include <ldb_version.h>
     53#include <ldb_errors.h>
    5354
    5455/*
     
    8687#ifndef PRINTF_ATTRIBUTE
    8788#define PRINTF_ATTRIBUTE(a,b)
     89#endif
     90
     91#ifndef _DEPRECATED_
     92#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
     93#define _DEPRECATED_ __attribute__ ((deprecated))
     94#else
     95#define _DEPRECATED_
     96#endif
    8897#endif
    8998/*! \endcond */
     
    103112
    104113/**
     114  use this to extract the mod type from the operation
     115 */
     116#define LDB_FLAG_MOD_TYPE(flags) ((flags) & LDB_FLAG_MOD_MASK)
     117
     118/**
    105119   Flag value used in ldap_modify() to indicate that attributes are
    106120   being added.
     
    125139*/
    126140#define LDB_FLAG_MOD_DELETE  3
     141
     142/**
     143    flag bits on an element usable only by the internal implementation
     144*/
     145#define LDB_FLAG_INTERNAL_MASK 0xFFFFFFF0
    127146
    128147/**
     
    297316
    298317struct ldb_parse_tree *ldb_parse_tree(TALLOC_CTX *mem_ctx, const char *s);
    299 char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, struct ldb_parse_tree *tree);
     318char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, const struct ldb_parse_tree *tree);
    300319
    301320/**
     
    336355typedef int (*ldb_attr_handler_t)(struct ldb_context *, TALLOC_CTX *mem_ctx, const struct ldb_val *, struct ldb_val *);
    337356typedef int (*ldb_attr_comparison_t)(struct ldb_context *, TALLOC_CTX *mem_ctx, const struct ldb_val *, const struct ldb_val *);
     357struct ldb_schema_attribute;
     358typedef int (*ldb_attr_operator_t)(struct ldb_context *, enum ldb_parse_op operation,
     359                                   const struct ldb_schema_attribute *a,
     360                                   const struct ldb_val *, const struct ldb_val *, bool *matched);
    338361
    339362/*
     
    353376        ldb_attr_handler_t canonicalise_fn;
    354377        ldb_attr_comparison_t comparison_fn;
     378        ldb_attr_operator_t operator_fn;
    355379};
    356380
     
    457481typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque);
    458482
     483/* Individual controls */
     484
     485/**
     486  OID for getting and manipulating attributes from the ldb
     487  without interception in the operational module.
     488  It can be used to access attribute that used to be stored in the sam
     489  and that are now calculated.
     490*/
     491#define LDB_CONTROL_BYPASS_OPERATIONAL_OID "1.3.6.1.4.1.7165.4.3.13"
     492#define LDB_CONTROL_BYPASS_OPERATIONAL_NAME "bypassoperational"
     493
     494/**
     495  OID for recalculate SD control. This control force the
     496  dsdb code to recalculate the SD of the object as if the
     497  object was just created.
     498
     499*/
     500#define LDB_CONTROL_RECALCULATE_SD_OID "1.3.6.1.4.1.7165.4.3.5"
     501#define LDB_CONTROL_RECALCULATE_SD_NAME "recalculate_sd"
     502
     503/**
     504   REVEAL_INTERNALS is used to reveal internal attributes and DN
     505   components which are not normally shown to the user
     506*/
     507#define LDB_CONTROL_REVEAL_INTERNALS "1.3.6.1.4.1.7165.4.3.6"
     508#define LDB_CONTROL_REVEAL_INTERNALS_NAME       "reveal_internals"
     509
     510/**
     511   LDB_CONTROL_AS_SYSTEM is used to skip access checks on operations
     512   that are performed by the system, but with a user's credentials, e.g.
     513   updating prefix map
     514*/
     515#define LDB_CONTROL_AS_SYSTEM_OID "1.3.6.1.4.1.7165.4.3.7"
     516
     517/**
     518   LDB_CONTROL_PROVISION_OID is used to skip some constraint checks. It's is
     519   mainly thought to be used for the provisioning.
     520*/
     521#define LDB_CONTROL_PROVISION_OID "1.3.6.1.4.1.7165.4.3.16"
     522#define LDB_CONTROL_PROVISION_NAME      "provision"
     523
     524/* AD controls */
     525
    459526/**
    460527   OID for the paged results control. This control is included in the
     
    466533*/
    467534#define LDB_CONTROL_PAGED_RESULTS_OID   "1.2.840.113556.1.4.319"
     535#define LDB_CONTROL_PAGED_RESULTS_NAME  "paged_result"
    468536
    469537/**
     
    473541*/
    474542#define LDB_CONTROL_SD_FLAGS_OID        "1.2.840.113556.1.4.801"
     543#define LDB_CONTROL_SD_FLAGS_NAME       "sd_flags"
    475544
    476545/**
     
    480549*/
    481550#define LDB_CONTROL_DOMAIN_SCOPE_OID    "1.2.840.113556.1.4.1339"
     551#define LDB_CONTROL_DOMAIN_SCOPE_NAME   "domain_scope"
    482552
    483553/**
     
    487557*/
    488558#define LDB_CONTROL_SEARCH_OPTIONS_OID  "1.2.840.113556.1.4.1340"
     559#define LDB_CONTROL_SEARCH_OPTIONS_NAME "search_options"
    489560
    490561/**
     
    494565*/
    495566#define LDB_CONTROL_NOTIFICATION_OID    "1.2.840.113556.1.4.528"
     567#define LDB_CONTROL_NOTIFICATION_NAME   "notification"
     568
     569/**
     570   OID for performing subtree deletes
     571
     572   \sa <a href="http://msdn.microsoft.com/en-us/library/aa366991(v=VS.85).aspx">Microsoft documentation of this OID</a>
     573*/
     574#define LDB_CONTROL_TREE_DELETE_OID     "1.2.840.113556.1.4.805"
     575#define LDB_CONTROL_TREE_DELETE_NAME    "tree_delete"
    496576
    497577/**
     
    501581*/
    502582#define LDB_CONTROL_SHOW_DELETED_OID    "1.2.840.113556.1.4.417"
     583#define LDB_CONTROL_SHOW_DELETED_NAME   "show_deleted"
    503584
    504585/**
     
    508589*/
    509590#define LDB_CONTROL_SHOW_RECYCLED_OID         "1.2.840.113556.1.4.2064"
     591#define LDB_CONTROL_SHOW_RECYCLED_NAME  "show_recycled"
    510592
    511593/**
     
    515597*/
    516598#define LDB_CONTROL_SHOW_DEACTIVATED_LINK_OID "1.2.840.113556.1.4.2065"
     599#define LDB_CONTROL_SHOW_DEACTIVATED_LINK_NAME  "show_deactivated_link"
    517600
    518601/**
     
    522605*/
    523606#define LDB_CONTROL_EXTENDED_DN_OID     "1.2.840.113556.1.4.529"
     607#define LDB_CONTROL_EXTENDED_DN_NAME    "extended_dn"
    524608
    525609/**
     
    536620*/
    537621#define LDB_CONTROL_SERVER_SORT_OID     "1.2.840.113556.1.4.473"
     622#define LDB_CONTROL_SERVER_SORT_NAME    "server_sort"
    538623
    539624/**
     
    547632*/
    548633#define LDB_CONTROL_SORT_RESP_OID       "1.2.840.113556.1.4.474"
     634#define LDB_CONTROL_SORT_RESP_NAME      "server_sort_resp"
    549635
    550636/**
     
    555641*/
    556642#define LDB_CONTROL_ASQ_OID             "1.2.840.113556.1.4.1504"
     643#define LDB_CONTROL_ASQ_NAME    "asq"
    557644
    558645/**
     
    563650*/
    564651#define LDB_CONTROL_DIRSYNC_OID         "1.2.840.113556.1.4.841"
     652#define LDB_CONTROL_DIRSYNC_NAME        "dirsync"
    565653
    566654
     
    572660*/
    573661#define LDB_CONTROL_VLV_REQ_OID         "2.16.840.1.113730.3.4.9"
     662#define LDB_CONTROL_VLV_REQ_NAME        "vlv"
    574663
    575664/**
     
    580669*/
    581670#define LDB_CONTROL_VLV_RESP_OID        "2.16.840.1.113730.3.4.10"
     671#define LDB_CONTROL_VLV_RESP_NAME       "vlv_resp"
    582672
    583673/**
     
    588678*/
    589679#define LDB_CONTROL_PERMISSIVE_MODIFY_OID       "1.2.840.113556.1.4.1413"
     680#define LDB_CONTROL_PERMISSIVE_MODIFY_NAME      "permissive_modify"
     681
     682/**
     683    OID to allow the server to be more 'fast and loose' with the data being added. 
     684
     685    \sa <a href="http://msdn.microsoft.com/en-us/library/aa366982(v=VS.85).aspx">Microsoft documentation of this OID</a>
     686*/
     687#define LDB_CONTROL_SERVER_LAZY_COMMIT   "1.2.840.113556.1.4.619"
     688
     689/**
     690   Control for RODC join -see [MS-ADTS] section 3.1.1.3.4.1.23
     691
     692   \sa <a href="">Microsoft documentation of this OID</a>
     693*/
     694#define LDB_CONTROL_RODC_DCPROMO_OID "1.2.840.113556.1.4.1341"
     695#define LDB_CONTROL_RODC_DCPROMO_NAME   "rodc_join"
     696
     697/* Other standardised controls */
     698
     699/**
     700   OID for the allowing client to request temporary relaxed
     701   enforcement of constraints of the x.500 model.
     702
     703   Mainly used for the OpenLDAP backend.
     704
     705   \sa <a href="http://opends.dev.java.net/public/standards/draft-zeilenga-ldap-managedit.txt">draft managedit</a>.
     706*/
     707#define LDB_CONTROL_RELAX_OID "1.3.6.1.4.1.4203.666.5.12"
     708#define LDB_CONTROL_RELAX_NAME  "relax"
     709
     710/* Extended operations */
     711
     712/**
     713   OID for LDAP Extended Operation SEQUENCE_NUMBER
     714
     715   This extended operation is used to retrieve the extended sequence number.
     716*/
     717#define LDB_EXTENDED_SEQUENCE_NUMBER    "1.3.6.1.4.1.7165.4.4.3"
     718
     719/**
     720   OID for LDAP Extended Operation PASSWORD_CHANGE.
     721
     722   This Extended operation is used to allow user password changes by the user
     723   itself.
     724*/
     725#define LDB_EXTENDED_PASSWORD_CHANGE_OID        "1.3.6.1.4.1.4203.1.11.1"
     726
     727
     728/**
     729   OID for LDAP Extended Operation FAST_BIND
     730
     731   This Extended operations is used to perform a fast bind.
     732*/
     733#define LDB_EXTENDED_FAST_BIND_OID      "1.2.840.113556.1.4.1781"
    590734
    591735/**
    592736   OID for LDAP Extended Operation START_TLS.
    593737
    594    This Extended operation is used to start a new TLS
    595    channel on top of a clear text channel.
     738   This Extended operation is used to start a new TLS channel on top of a clear
     739   text channel.
    596740*/
    597741#define LDB_EXTENDED_START_TLS_OID      "1.3.6.1.4.1.1466.20037"
    598742
    599743/**
     744   OID for LDAP Extended Operation DYNAMIC_REFRESH.
     745
     746   This Extended operation is used to create and maintain objects which exist
     747   only a specific time, e.g. when a certain client or a certain person is
     748   logged in. Data refreshes have to be periodically sent in a specific
     749   interval. Otherwise the entry is going to be removed.
    600750*/
    601751#define LDB_EXTENDED_DYNAMIC_OID        "1.3.6.1.4.1.1466.101.119.1"
    602 
    603 /**
    604 */
    605 #define LDB_EXTENDED_FAST_BIND_OID      "1.2.840.113556.1.4.1781"
    606752
    607753struct ldb_sd_flags_control {
     
    736882};
    737883
    738 #define LDB_EXTENDED_SEQUENCE_NUMBER    "1.3.6.1.4.1.7165.4.4.3"
    739 
    740884enum ldb_sequence_type {
    741885        LDB_SEQ_HIGHEST_SEQ,
     
    9641108int ldb_op_default_callback(struct ldb_request *req, struct ldb_reply *ares);
    9651109
     1110int ldb_modify_default_callback(struct ldb_request *req, struct ldb_reply *ares);
    9661111
    9671112/**
     
    11181263
    11191264/**
     1265  replace a ldb_control in a ldb_request
     1266
     1267  \param req the request struct where to add the control
     1268  \param oid the object identifier of the control as string
     1269  \param critical whether the control should be critical or not
     1270  \param data a talloc pointer to the control specific data
     1271
     1272  \return result code (LDB_SUCCESS on success, or a failure code)
     1273*/
     1274int ldb_request_replace_control(struct ldb_request *req, const char *oid, bool critical, void *data);
     1275
     1276/**
    11201277   check if a control with the specified "oid" exist and return it
    11211278  \param req the request struct where to add the control
     
    13091466int ldb_transaction_cancel(struct ldb_context *ldb);
    13101467
     1468/*
     1469  cancel a transaction with no error if no transaction is pending
     1470  used when we fork() to clear any parent transactions
     1471*/
     1472int ldb_transaction_cancel_noerr(struct ldb_context *ldb);
     1473
    13111474
    13121475/**
     
    15511714  \param mode Style of extended DN to return (0 is HEX representation of binary form, 1 is a string form)
    15521715*/
    1553 char *ldb_dn_get_extended_linearized(void *mem_ctx, struct ldb_dn *dn, int mode);
     1716char *ldb_dn_get_extended_linearized(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, int mode);
    15541717const struct ldb_val *ldb_dn_get_extended_component(struct ldb_dn *dn, const char *name);
    15551718int ldb_dn_set_extended_component(struct ldb_dn *dn, const char *name, const struct ldb_val *val);
    1556 
     1719void ldb_dn_extended_filter(struct ldb_dn *dn, const char * const *accept_list);
    15571720void ldb_dn_remove_extended_components(struct ldb_dn *dn);
    15581721bool ldb_dn_has_extended(struct ldb_dn *dn);
     
    15911754*/
    15921755
    1593 struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx, struct ldb_context *ldb, const struct ldb_val *strdn);
     1756struct ldb_dn *ldb_dn_from_ldb_val(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const struct ldb_val *strdn);
    15941757
    15951758/**
     
    16201783char *ldb_dn_canonical_ex_string(TALLOC_CTX *mem_ctx, struct ldb_dn *dn);
    16211784int ldb_dn_get_comp_num(struct ldb_dn *dn);
     1785int ldb_dn_get_extended_comp_num(struct ldb_dn *dn);
    16221786const char *ldb_dn_get_component_name(struct ldb_dn *dn, unsigned int num);
    16231787const struct ldb_val *ldb_dn_get_component_val(struct ldb_dn *dn, unsigned int num);
     
    16301794bool ldb_dn_check_special(struct ldb_dn *dn, const char *check);
    16311795bool ldb_dn_is_null(struct ldb_dn *dn);
     1796int ldb_dn_update_components(struct ldb_dn *dn, const struct ldb_dn *ref_dn);
    16321797
    16331798
     
    17131878int ldb_msg_add_string(struct ldb_message *msg,
    17141879                       const char *attr_name, const char *str);
     1880int ldb_msg_add_linearized_dn(struct ldb_message *msg, const char *attr_name,
     1881                              struct ldb_dn *dn);
    17151882int ldb_msg_add_fmt(struct ldb_message *msg,
    17161883                    const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
     
    17661933                                 const struct ldb_message *msg);
    17671934
     1935/*
     1936 * ldb_msg_canonicalize() is now depreciated
     1937 * Please use ldb_msg_normalize() instead
     1938 *
     1939 * NOTE: Returned ldb_message object is allocated
     1940 * into *ldb's context. Callers are recommended
     1941 * to steal the returned object into a TALLOC_CTX
     1942 * with short lifetime.
     1943 */
    17681944struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb,
    1769                                          const struct ldb_message *msg);
    1770 
    1771 
     1945                                         const struct ldb_message *msg) _DEPRECATED_;
     1946
     1947int ldb_msg_normalize(struct ldb_context *ldb,
     1948                      TALLOC_CTX *mem_ctx,
     1949                      const struct ldb_message *msg,
     1950                      struct ldb_message **_msg_out);
     1951
     1952
     1953/*
     1954 * ldb_msg_diff() is now depreciated
     1955 * Please use ldb_msg_difference() instead
     1956 *
     1957 * NOTE: Returned ldb_message object is allocated
     1958 * into *ldb's context. Callers are recommended
     1959 * to steal the returned object into a TALLOC_CTX
     1960 * with short lifetime.
     1961 */
    17721962struct ldb_message *ldb_msg_diff(struct ldb_context *ldb,
    17731963                                 struct ldb_message *msg1,
    1774                                  struct ldb_message *msg2);
    1775 
     1964                                 struct ldb_message *msg2) _DEPRECATED_;
     1965
     1966/**
     1967 * return a ldb_message representing the differences between msg1 and msg2.
     1968 * If you then use this in a ldb_modify() call,
     1969 * it can be used to save edits to a message
     1970 *
     1971 * Result message is constructed as follows:
     1972 * - LDB_FLAG_MOD_ADD     - elements found only in msg2
     1973 * - LDB_FLAG_MOD_REPLACE - elements in msg2 that have
     1974 *                          different value in msg1
     1975 *                          Value for msg2 element is used
     1976 * - LDB_FLAG_MOD_DELETE  - elements found only in msg2
     1977 *
     1978 * @return LDB_SUCCESS or LDB_ERR_OPERATIONS_ERROR
     1979 */
     1980int ldb_msg_difference(struct ldb_context *ldb,
     1981                       TALLOC_CTX *mem_ctx,
     1982                       struct ldb_message *msg1,
     1983                       struct ldb_message *msg2,
     1984                       struct ldb_message **_msg_out);
     1985
     1986/**
     1987   Tries to find a certain string attribute in a message
     1988
     1989   \param msg the message to check
     1990   \param name attribute name
     1991   \param value attribute value
     1992
     1993   \return 1 on match and 0 otherwise.
     1994*/
    17761995int ldb_msg_check_string_attribute(const struct ldb_message *msg,
    17771996                                   const char *name,
     
    18802099
    18812100/**
     2101  convert a LDAP GeneralizedTime string in ldb_val format to a
     2102  time_t.
     2103*/
     2104int ldb_val_to_time(const struct ldb_val *v, time_t *t);
     2105
     2106/**
    18822107   Convert a time structure to a string
    18832108
     
    19082133void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque, ldb_qsort_cmp_fn_t cmp);
    19092134
    1910 
     2135#ifndef discard_const
     2136#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
     2137#endif
     2138
     2139/*
     2140  a wrapper around ldb_qsort() that ensures the comparison function is
     2141  type safe. This will produce a compilation warning if the types
     2142  don't match
     2143 */
     2144#define LDB_TYPESAFE_QSORT(base, numel, opaque, comparison)     \
     2145do { \
     2146        if (numel > 1) { \
     2147                ldb_qsort(base, numel, sizeof((base)[0]), discard_const(opaque), (ldb_qsort_cmp_fn_t)comparison); \
     2148                comparison(&((base)[0]), &((base)[1]), opaque);         \
     2149        } \
     2150} while (0)
     2151
     2152/* allow ldb to also call TYPESAFE_QSORT() */
     2153#ifndef TYPESAFE_QSORT
     2154#define TYPESAFE_QSORT(base, numel, comparison) \
     2155do { \
     2156        if (numel > 1) { \
     2157                qsort(base, numel, sizeof((base)[0]), (int (*)(const void *, const void *))comparison); \
     2158                comparison(&((base)[0]), &((base)[1])); \
     2159        } \
     2160} while (0)
     2161#endif
     2162
     2163
     2164
     2165/**
     2166   Convert a control into its string representation.
     2167   
     2168   \param mem_ctx TALLOC context to return result on, and to allocate error_string on
     2169   \param control A struct ldb_control to convert
     2170
     2171   \return string representation of the control
     2172*/
     2173char* ldb_control_to_string(TALLOC_CTX *mem_ctx, const struct ldb_control *control);
     2174/**
     2175   Convert a string representing a control into a ldb_control structure
     2176   
     2177   \param ldb LDB context
     2178   \param mem_ctx TALLOC context to return result on, and to allocate error_string on
     2179   \param control_strings A string-formatted control
     2180
     2181   \return a ldb_control element
     2182*/
     2183struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *control_strings);
    19112184/**
    19122185   Convert an array of string represention of a control into an array of ldb_control structures
     
    19292202
    19302203
     2204struct ldb_dn *ldb_dn_binary_from_ldb_val(TALLOC_CTX *mem_ctx,
     2205                                          struct ldb_context *ldb,
     2206                                          const struct ldb_val *strdn);
     2207
     2208int ldb_dn_get_binary(struct ldb_dn *dn, struct ldb_val *val);
     2209int ldb_dn_set_binary(struct ldb_dn *dn, struct ldb_val *val);
     2210
     2211/* debugging functions for ldb requests */
     2212void ldb_req_set_location(struct ldb_request *req, const char *location);
     2213const char *ldb_req_location(struct ldb_request *req);
     2214
     2215/* set the location marker on a request handle - used for debugging */
     2216#define LDB_REQ_SET_LOCATION(req) ldb_req_set_location(req, __location__)
     2217
     2218/*
     2219  minimise a DN. The caller must pass in a validated DN.
     2220
     2221  If the DN has an extended component then only the first extended
     2222  component is kept, the DN string is stripped.
     2223
     2224  The existing dn is modified
     2225 */
     2226bool ldb_dn_minimise(struct ldb_dn *dn);
     2227
    19312228#endif
  • trunk/server/source4/lib/ldb/include/ldb_errors.h

    r414 r745  
    198198
    199199/**
    200    The function referred to an alias which points to a non-existant
     200   The function referred to an alias which points to a non-existent
    201201   object in the database.
    202202*/
  • trunk/server/source4/lib/ldb/include/ldb_handlers.h

    r414 r745  
    3636int ldb_comparison_binary(      struct ldb_context *ldb, void *mem_ctx,
    3737                                const struct ldb_val *v1, const struct ldb_val *v2);
    38 int db_handler_fold(            struct ldb_context *ldb, void *mem_ctx,
    39                                 const struct ldb_val *in, struct ldb_val *out);
    4038int ldb_comparison_fold(        struct ldb_context *ldb, void *mem_ctx,
    4139                                const struct ldb_val *v1, const struct ldb_val *v2);
  • trunk/server/source4/lib/ldb/include/ldb_module.h

    r414 r745  
    3434#define _LDB_MODULE_H_
    3535
    36 #include "ldb.h"
     36#include <ldb.h>
    3737
    3838struct ldb_context;
    3939struct ldb_module;
     40
     41/**
     42   internal flag bits on message elements. Must be within LDB_FLAG_INTERNAL_MASK
     43 */
     44#define LDB_FLAG_INTERNAL_DISABLE_VALIDATION 0x10
     45
     46/* disable any single value checking on this attribute */
     47#define LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK 0x20
     48
     49/* attribute has failed access check and must not be exposed */
     50#define LDB_FLAG_INTERNAL_INACCESSIBLE_ATTRIBUTE 0x40
     51
     52/* force single value checking on this attribute */
     53#define LDB_FLAG_INTERNAL_FORCE_SINGLE_VALUE_CHECK 0x80
     54
    4055
    4156/*
     
    6883void ldb_debug_end(struct ldb_context *ldb, enum ldb_debug_level level);
    6984
    70 #define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__)
     85#define ldb_error(ldb, ecode, reason) ldb_error_at(ldb, ecode, reason, __FILE__, __LINE__)
     86
     87#define ldb_oom(ldb) ldb_error(ldb, LDB_ERR_OPERATIONS_ERROR, "ldb out of memory")
     88#define ldb_module_oom(module) ldb_oom(ldb_module_get_ctx(module))
     89#define ldb_operr(ldb) ldb_error(ldb, LDB_ERR_OPERATIONS_ERROR, "operations error")
    7190
    7291/* The following definitions come from lib/ldb/common/ldb.c  */
     
    99118                                               void *private_data);
    100119
     120/* A useful function to build comparison functions with */
     121int ldb_any_comparison(struct ldb_context *ldb, void *mem_ctx,
     122                       ldb_attr_handler_t canonicalise_fn,
     123                       const struct ldb_val *v1,
     124                       const struct ldb_val *v2);
     125
    101126/* The following definitions come from lib/ldb/common/ldb_controls.c  */
    102 struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid);
    103 int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver);
    104 int check_critical_controls(struct ldb_control **controls);
     127int ldb_save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver);
     128/* Returns a list of controls, except the one specified.  Included
     129 * controls become a child of returned list if they were children of
     130 * controls_in */
     131struct ldb_control **ldb_controls_except_specified(struct ldb_control **controls_in,
     132                                               TALLOC_CTX *mem_ctx,
     133                                               struct ldb_control *exclude);
     134int ldb_check_critical_controls(struct ldb_control **controls);
    105135
    106136/* The following definitions come from lib/ldb/common/ldb_ldif.c  */
     
    114144                  enum ldb_scope scope);
    115145
     146int ldb_match_msg_error(struct ldb_context *ldb,
     147                        const struct ldb_message *msg,
     148                        const struct ldb_parse_tree *tree,
     149                        struct ldb_dn *base,
     150                        enum ldb_scope scope,
     151                        bool *matched);
     152
     153int ldb_match_msg_objectclass(const struct ldb_message *msg,
     154                              const char *objectclass);
     155
    116156/* The following definitions come from lib/ldb/common/ldb_modules.c  */
    117157
     
    125165void *ldb_module_get_private(struct ldb_module *module);
    126166void ldb_module_set_private(struct ldb_module *module, void *private_data);
     167const struct ldb_module_ops *ldb_module_get_ops(struct ldb_module *module);
    127168
    128169int ldb_next_request(struct ldb_module *module, struct ldb_request *request);
     
    136177void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
    137178void ldb_reset_err_string(struct ldb_context *ldb);
     179int ldb_error_at(struct ldb_context *ldb, int ecode, const char *reason, const char *file, int line);
    138180
    139181const char *ldb_default_modules_dir(void);
     
    152194const char *ldb_default_modules_dir(void);
    153195
    154 int ldb_register_backend(const char *url_prefix, ldb_connect_fn);
     196int ldb_register_backend(const char *url_prefix, ldb_connect_fn, bool);
    155197
    156198struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb);
     
    171213
    172214void ldb_set_default_dns(struct ldb_context *ldb);
     215/**
     216  Add a ldb_control to a ldb_reply
     217
     218  \param ares the reply struct where to add the control
     219  \param oid the object identifier of the control as string
     220  \param critical whether the control should be critical or not
     221  \param data a talloc pointer to the control specific data
     222
     223  \return result code (LDB_SUCCESS on success, or a failure code)
     224*/
     225int ldb_reply_add_control(struct ldb_reply *ares, const char *oid, bool critical, void *data);
     226
     227/**
     228  mark a request as untrusted. This tells the rootdse module to remove
     229  unregistered controls
     230 */
     231void ldb_req_mark_untrusted(struct ldb_request *req);
     232
     233/**
     234  mark a request as trusted.
     235 */
     236void ldb_req_mark_trusted(struct ldb_request *req);
     237
     238/**
     239   return true is a request is untrusted
     240 */
     241bool ldb_req_is_untrusted(struct ldb_request *req);
     242
     243/* load all modules from the given directory */
     244int ldb_modules_load(const char *modules_path, const char *version);
     245
     246/* init functions prototype */
     247typedef int (*ldb_module_init_fn)(const char *);
     248
     249/*
     250  general ldb hook function
     251 */
     252enum ldb_module_hook_type { LDB_MODULE_HOOK_CMDLINE_OPTIONS     = 1,
     253                            LDB_MODULE_HOOK_CMDLINE_PRECONNECT  = 2,
     254                            LDB_MODULE_HOOK_CMDLINE_POSTCONNECT = 3 };
     255
     256typedef int (*ldb_hook_fn)(struct ldb_context *, enum ldb_module_hook_type );
     257
     258/*
     259  register a ldb hook function
     260 */
     261int ldb_register_hook(ldb_hook_fn hook_fn);
     262
     263/*
     264  call ldb hooks of a given type
     265 */
     266int ldb_modules_hook(struct ldb_context *ldb, enum ldb_module_hook_type t);
     267
     268#define LDB_MODULE_CHECK_VERSION(version) do { \
     269 if (strcmp(version, LDB_VERSION) != 0) { \
     270        fprintf(stderr, "ldb: module version mismatch in %s : ldb_version=%s module_version=%s\n", \
     271                        __FILE__, version, LDB_VERSION); \
     272        return LDB_ERR_UNAVAILABLE; \
     273 }} while (0)
     274
     275
     276/*
     277  return a string representation of the calling chain for the given
     278  ldb request
     279 */
     280char *ldb_module_call_chain(struct ldb_request *req, TALLOC_CTX *mem_ctx);
     281
     282/*
     283  return the next module in the chain
     284 */
     285struct ldb_module *ldb_module_next(struct ldb_module *module);
     286
     287/*
     288  set the next module in the module chain
     289 */
     290void ldb_module_set_next(struct ldb_module *module, struct ldb_module *next);
     291
     292/*
     293  load a list of modules
     294 */
     295int ldb_module_load_list(struct ldb_context *ldb, const char **module_list,
     296                         struct ldb_module *backend, struct ldb_module **out);
     297
     298/*
     299  get the popt_options pointer in the ldb structure. This allows a ldb
     300  module to change the command line parsing
     301 */
     302struct poptOption **ldb_module_popt_options(struct ldb_context *ldb);
     303
     304/* modules are called in inverse order on the stack.
     305   Lets place them as an admin would think the right order is.
     306   Modules order is important */
     307const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string);
     308
     309/*
     310  return the current ldb flags LDB_FLG_*
     311 */
     312uint32_t ldb_module_flags(struct ldb_context *ldb);
     313
     314int ldb_module_connect_backend(struct ldb_context *ldb,
     315                               const char *url,
     316                               const char *options[],
     317                               struct ldb_module **backend_module);
     318
     319/*
     320  initialise a chain of modules
     321 */
     322int ldb_module_init_chain(struct ldb_context *ldb, struct ldb_module *module);
     323
     324/*
     325 * prototype for the init function defined by dynamically loaded modules
     326 */
     327int ldb_init_module(const char *version);
     328
    173329
    174330#endif
  • trunk/server/source4/lib/ldb/include/ldb_private.h

    r414 r745  
    3838#define _LDB_PRIVATE_H_ 1
    3939
    40 #include "ldb_includes.h"
     40#include "replace.h"
     41#include "system/filesys.h"
     42#include "system/time.h"
    4143#include "ldb.h"
    4244#include "ldb_module.h"
     
    4951
    5052#define LDB_HANDLE_FLAG_DONE_CALLED 1
     53/* call is from an untrusted source - eg. over ldap:// */
     54#define LDB_HANDLE_FLAG_UNTRUSTED   2
    5155
    5256struct ldb_handle {
     
    5660        unsigned flags;
    5761        unsigned nesting;
     62
     63        /* used for debugging */
     64        struct ldb_request *parent;
     65        const char *location;
    5866};
    5967
     
    113121        unsigned int create_perms;
    114122
    115         char *modules_dir;
    116 
    117123        struct tevent_context *ev_ctx;
    118124
     
    120126
    121127        char *partial_debug;
     128
     129        struct poptOption *popt_options;
    122130};
    123131
    124132/* The following definitions come from lib/ldb/common/ldb.c  */
    125 
    126 int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *options[],
    127                         struct ldb_module **backend_module);
    128 
    129133
    130134extern const struct ldb_module_ops ldb_objectclass_module_ops;
     
    158162
    159163/* The following definitions come from lib/ldb/common/ldb_utf8.c */
    160 char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n);
     164char *ldb_casefold_default(void *context, TALLOC_CTX *mem_ctx, const char *s, size_t n);
    161165
    162166void ldb_dump_results(struct ldb_context *ldb, struct ldb_result *result, FILE *f);
     
    166170
    167171const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string);
    168 int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out);
    169172int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
    170 int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module);
    171173
    172 struct ldb_val ldb_binary_decode(void *mem_ctx, const char *str);
     174struct ldb_val ldb_binary_decode(TALLOC_CTX *mem_ctx, const char *str);
     175
     176
     177/* The following definitions come from lib/ldb/common/ldb_options.c  */
     178
     179const char *ldb_options_find(struct ldb_context *ldb, const char *options[],
     180                             const char *option_name);
    173181
    174182#endif
Note: See TracChangeset for help on using the changeset viewer.