Changeset 745 for trunk/server/source4/lib/ldb/include
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/lib/ldb/include/dlinklist.h
r414 r745 2 2 Unix SMB/CIFS implementation. 3 3 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 5 10 6 This program is free software; you can redistribute it and/or modify7 it under the terms of the GNU General Public License as published by8 the Free Software Foundation; either version 3 of the License, or9 (at your option) any later version.10 11 This programis 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, 12 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNUGeneral Public License for more details.15 16 You should have received a copy of the GNU General Public License17 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/>. 18 23 */ 19 24 … … 24 29 #define _DLINKLIST_H 25 30 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. 26 35 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 */ 28 70 #define DLIST_ADD(list, p) \ 29 71 do { \ 30 72 if (!(list)) { \ 31 ( list) = (p);\32 (p)->next = (p)->prev =NULL; \73 (p)->prev = (list) = (p); \ 74 (p)->next = NULL; \ 33 75 } else { \ 76 (p)->prev = (list)->prev; \ 34 77 (list)->prev = (p); \ 35 78 (p)->next = (list); \ 36 (p)->prev = NULL; \37 79 (list) = (p); \ 38 } \80 } \ 39 81 } while (0) 40 82 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 */ 42 88 #define DLIST_REMOVE(list, p) \ 43 89 do { \ 44 90 if ((p) == (list)) { \ 91 if ((p)->next) (p)->next->prev = (p)->prev; \ 45 92 (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; \ 47 96 } else { \ 48 97 if ((p)->prev) (p)->prev->next = (p)->next; \ 49 98 if ((p)->next) (p)->next->prev = (p)->prev; \ 50 99 } \ 51 if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL;\100 if ((p) != (list)) (p)->next = (p)->prev = NULL; \ 52 101 } while (0) 53 102 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) \ 56 109 do { \ 57 DLIST_REMOVE(list,p); \58 DLIST_ADD(list, p); \59 } while 110 (result_head) = (p); \ 111 while (DLIST_PREV(result_head)) (result_head) = (result_head)->prev; \ 112 } while(0) 60 113 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) 75 119 76 120 /* insert 'p' after the given element 'el' in a list. If el is NULL then … … 81 125 DLIST_ADD(list, p); \ 82 126 } 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); \ 87 132 }\ 88 133 } while (0) 89 134 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) \ 92 141 do { \ 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 } \ 95 147 } while (0) 96 148 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) \ 100 151 do { \ 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) \ 161 do { \ 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) \ 172 do { \ 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; \ 110 181 } \ 182 } \ 111 183 } while (0) 112 184 -
trunk/server/source4/lib/ldb/include/ldb.h
r414 r745 48 48 49 49 #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> 53 54 54 55 /* … … 86 87 #ifndef PRINTF_ATTRIBUTE 87 88 #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 88 97 #endif 89 98 /*! \endcond */ … … 103 112 104 113 /** 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 /** 105 119 Flag value used in ldap_modify() to indicate that attributes are 106 120 being added. … … 125 139 */ 126 140 #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 127 146 128 147 /** … … 297 316 298 317 struct 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);318 char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, const struct ldb_parse_tree *tree); 300 319 301 320 /** … … 336 355 typedef int (*ldb_attr_handler_t)(struct ldb_context *, TALLOC_CTX *mem_ctx, const struct ldb_val *, struct ldb_val *); 337 356 typedef int (*ldb_attr_comparison_t)(struct ldb_context *, TALLOC_CTX *mem_ctx, const struct ldb_val *, const struct ldb_val *); 357 struct ldb_schema_attribute; 358 typedef 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); 338 361 339 362 /* … … 353 376 ldb_attr_handler_t canonicalise_fn; 354 377 ldb_attr_comparison_t comparison_fn; 378 ldb_attr_operator_t operator_fn; 355 379 }; 356 380 … … 457 481 typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); 458 482 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 459 526 /** 460 527 OID for the paged results control. This control is included in the … … 466 533 */ 467 534 #define LDB_CONTROL_PAGED_RESULTS_OID "1.2.840.113556.1.4.319" 535 #define LDB_CONTROL_PAGED_RESULTS_NAME "paged_result" 468 536 469 537 /** … … 473 541 */ 474 542 #define LDB_CONTROL_SD_FLAGS_OID "1.2.840.113556.1.4.801" 543 #define LDB_CONTROL_SD_FLAGS_NAME "sd_flags" 475 544 476 545 /** … … 480 549 */ 481 550 #define LDB_CONTROL_DOMAIN_SCOPE_OID "1.2.840.113556.1.4.1339" 551 #define LDB_CONTROL_DOMAIN_SCOPE_NAME "domain_scope" 482 552 483 553 /** … … 487 557 */ 488 558 #define LDB_CONTROL_SEARCH_OPTIONS_OID "1.2.840.113556.1.4.1340" 559 #define LDB_CONTROL_SEARCH_OPTIONS_NAME "search_options" 489 560 490 561 /** … … 494 565 */ 495 566 #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" 496 576 497 577 /** … … 501 581 */ 502 582 #define LDB_CONTROL_SHOW_DELETED_OID "1.2.840.113556.1.4.417" 583 #define LDB_CONTROL_SHOW_DELETED_NAME "show_deleted" 503 584 504 585 /** … … 508 589 */ 509 590 #define LDB_CONTROL_SHOW_RECYCLED_OID "1.2.840.113556.1.4.2064" 591 #define LDB_CONTROL_SHOW_RECYCLED_NAME "show_recycled" 510 592 511 593 /** … … 515 597 */ 516 598 #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" 517 600 518 601 /** … … 522 605 */ 523 606 #define LDB_CONTROL_EXTENDED_DN_OID "1.2.840.113556.1.4.529" 607 #define LDB_CONTROL_EXTENDED_DN_NAME "extended_dn" 524 608 525 609 /** … … 536 620 */ 537 621 #define LDB_CONTROL_SERVER_SORT_OID "1.2.840.113556.1.4.473" 622 #define LDB_CONTROL_SERVER_SORT_NAME "server_sort" 538 623 539 624 /** … … 547 632 */ 548 633 #define LDB_CONTROL_SORT_RESP_OID "1.2.840.113556.1.4.474" 634 #define LDB_CONTROL_SORT_RESP_NAME "server_sort_resp" 549 635 550 636 /** … … 555 641 */ 556 642 #define LDB_CONTROL_ASQ_OID "1.2.840.113556.1.4.1504" 643 #define LDB_CONTROL_ASQ_NAME "asq" 557 644 558 645 /** … … 563 650 */ 564 651 #define LDB_CONTROL_DIRSYNC_OID "1.2.840.113556.1.4.841" 652 #define LDB_CONTROL_DIRSYNC_NAME "dirsync" 565 653 566 654 … … 572 660 */ 573 661 #define LDB_CONTROL_VLV_REQ_OID "2.16.840.1.113730.3.4.9" 662 #define LDB_CONTROL_VLV_REQ_NAME "vlv" 574 663 575 664 /** … … 580 669 */ 581 670 #define LDB_CONTROL_VLV_RESP_OID "2.16.840.1.113730.3.4.10" 671 #define LDB_CONTROL_VLV_RESP_NAME "vlv_resp" 582 672 583 673 /** … … 588 678 */ 589 679 #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" 590 734 591 735 /** 592 736 OID for LDAP Extended Operation START_TLS. 593 737 594 This Extended operation is used to start a new TLS 595 channel on top of a cleartext channel.738 This Extended operation is used to start a new TLS channel on top of a clear 739 text channel. 596 740 */ 597 741 #define LDB_EXTENDED_START_TLS_OID "1.3.6.1.4.1.1466.20037" 598 742 599 743 /** 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. 600 750 */ 601 751 #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"606 752 607 753 struct ldb_sd_flags_control { … … 736 882 }; 737 883 738 #define LDB_EXTENDED_SEQUENCE_NUMBER "1.3.6.1.4.1.7165.4.4.3"739 740 884 enum ldb_sequence_type { 741 885 LDB_SEQ_HIGHEST_SEQ, … … 964 1108 int ldb_op_default_callback(struct ldb_request *req, struct ldb_reply *ares); 965 1109 1110 int ldb_modify_default_callback(struct ldb_request *req, struct ldb_reply *ares); 966 1111 967 1112 /** … … 1118 1263 1119 1264 /** 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 */ 1274 int ldb_request_replace_control(struct ldb_request *req, const char *oid, bool critical, void *data); 1275 1276 /** 1120 1277 check if a control with the specified "oid" exist and return it 1121 1278 \param req the request struct where to add the control … … 1309 1466 int ldb_transaction_cancel(struct ldb_context *ldb); 1310 1467 1468 /* 1469 cancel a transaction with no error if no transaction is pending 1470 used when we fork() to clear any parent transactions 1471 */ 1472 int ldb_transaction_cancel_noerr(struct ldb_context *ldb); 1473 1311 1474 1312 1475 /** … … 1551 1714 \param mode Style of extended DN to return (0 is HEX representation of binary form, 1 is a string form) 1552 1715 */ 1553 char *ldb_dn_get_extended_linearized( void*mem_ctx, struct ldb_dn *dn, int mode);1716 char *ldb_dn_get_extended_linearized(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, int mode); 1554 1717 const struct ldb_val *ldb_dn_get_extended_component(struct ldb_dn *dn, const char *name); 1555 1718 int ldb_dn_set_extended_component(struct ldb_dn *dn, const char *name, const struct ldb_val *val); 1556 1719 void ldb_dn_extended_filter(struct ldb_dn *dn, const char * const *accept_list); 1557 1720 void ldb_dn_remove_extended_components(struct ldb_dn *dn); 1558 1721 bool ldb_dn_has_extended(struct ldb_dn *dn); … … 1591 1754 */ 1592 1755 1593 struct ldb_dn *ldb_dn_from_ldb_val( void*mem_ctx, struct ldb_context *ldb, const struct ldb_val *strdn);1756 struct ldb_dn *ldb_dn_from_ldb_val(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const struct ldb_val *strdn); 1594 1757 1595 1758 /** … … 1620 1783 char *ldb_dn_canonical_ex_string(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); 1621 1784 int ldb_dn_get_comp_num(struct ldb_dn *dn); 1785 int ldb_dn_get_extended_comp_num(struct ldb_dn *dn); 1622 1786 const char *ldb_dn_get_component_name(struct ldb_dn *dn, unsigned int num); 1623 1787 const struct ldb_val *ldb_dn_get_component_val(struct ldb_dn *dn, unsigned int num); … … 1630 1794 bool ldb_dn_check_special(struct ldb_dn *dn, const char *check); 1631 1795 bool ldb_dn_is_null(struct ldb_dn *dn); 1796 int ldb_dn_update_components(struct ldb_dn *dn, const struct ldb_dn *ref_dn); 1632 1797 1633 1798 … … 1713 1878 int ldb_msg_add_string(struct ldb_message *msg, 1714 1879 const char *attr_name, const char *str); 1880 int ldb_msg_add_linearized_dn(struct ldb_message *msg, const char *attr_name, 1881 struct ldb_dn *dn); 1715 1882 int ldb_msg_add_fmt(struct ldb_message *msg, 1716 1883 const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); … … 1766 1933 const struct ldb_message *msg); 1767 1934 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 */ 1768 1944 struct 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 1947 int 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 */ 1772 1962 struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, 1773 1963 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 */ 1980 int 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 */ 1776 1995 int ldb_msg_check_string_attribute(const struct ldb_message *msg, 1777 1996 const char *name, … … 1880 2099 1881 2100 /** 2101 convert a LDAP GeneralizedTime string in ldb_val format to a 2102 time_t. 2103 */ 2104 int ldb_val_to_time(const struct ldb_val *v, time_t *t); 2105 2106 /** 1882 2107 Convert a time structure to a string 1883 2108 … … 1908 2133 void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque, ldb_qsort_cmp_fn_t cmp); 1909 2134 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) \ 2145 do { \ 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) \ 2155 do { \ 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 */ 2173 char* 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 */ 2183 struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *control_strings); 1911 2184 /** 1912 2185 Convert an array of string represention of a control into an array of ldb_control structures … … 1929 2202 1930 2203 2204 struct ldb_dn *ldb_dn_binary_from_ldb_val(TALLOC_CTX *mem_ctx, 2205 struct ldb_context *ldb, 2206 const struct ldb_val *strdn); 2207 2208 int ldb_dn_get_binary(struct ldb_dn *dn, struct ldb_val *val); 2209 int ldb_dn_set_binary(struct ldb_dn *dn, struct ldb_val *val); 2210 2211 /* debugging functions for ldb requests */ 2212 void ldb_req_set_location(struct ldb_request *req, const char *location); 2213 const 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 */ 2226 bool ldb_dn_minimise(struct ldb_dn *dn); 2227 1931 2228 #endif -
trunk/server/source4/lib/ldb/include/ldb_errors.h
r414 r745 198 198 199 199 /** 200 The function referred to an alias which points to a non-exist ant200 The function referred to an alias which points to a non-existent 201 201 object in the database. 202 202 */ -
trunk/server/source4/lib/ldb/include/ldb_handlers.h
r414 r745 36 36 int ldb_comparison_binary( struct ldb_context *ldb, void *mem_ctx, 37 37 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);40 38 int ldb_comparison_fold( struct ldb_context *ldb, void *mem_ctx, 41 39 const struct ldb_val *v1, const struct ldb_val *v2); -
trunk/server/source4/lib/ldb/include/ldb_module.h
r414 r745 34 34 #define _LDB_MODULE_H_ 35 35 36 #include "ldb.h"36 #include <ldb.h> 37 37 38 38 struct ldb_context; 39 39 struct 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 40 55 41 56 /* … … 68 83 void ldb_debug_end(struct ldb_context *ldb, enum ldb_debug_level level); 69 84 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") 71 90 72 91 /* The following definitions come from lib/ldb/common/ldb.c */ … … 99 118 void *private_data); 100 119 120 /* A useful function to build comparison functions with */ 121 int 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 101 126 /* 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); 127 int 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 */ 131 struct ldb_control **ldb_controls_except_specified(struct ldb_control **controls_in, 132 TALLOC_CTX *mem_ctx, 133 struct ldb_control *exclude); 134 int ldb_check_critical_controls(struct ldb_control **controls); 105 135 106 136 /* The following definitions come from lib/ldb/common/ldb_ldif.c */ … … 114 144 enum ldb_scope scope); 115 145 146 int 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 153 int ldb_match_msg_objectclass(const struct ldb_message *msg, 154 const char *objectclass); 155 116 156 /* The following definitions come from lib/ldb/common/ldb_modules.c */ 117 157 … … 125 165 void *ldb_module_get_private(struct ldb_module *module); 126 166 void ldb_module_set_private(struct ldb_module *module, void *private_data); 167 const struct ldb_module_ops *ldb_module_get_ops(struct ldb_module *module); 127 168 128 169 int ldb_next_request(struct ldb_module *module, struct ldb_request *request); … … 136 177 void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3); 137 178 void ldb_reset_err_string(struct ldb_context *ldb); 179 int ldb_error_at(struct ldb_context *ldb, int ecode, const char *reason, const char *file, int line); 138 180 139 181 const char *ldb_default_modules_dir(void); … … 152 194 const char *ldb_default_modules_dir(void); 153 195 154 int ldb_register_backend(const char *url_prefix, ldb_connect_fn );196 int ldb_register_backend(const char *url_prefix, ldb_connect_fn, bool); 155 197 156 198 struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb); … … 171 213 172 214 void 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 */ 225 int 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 */ 231 void ldb_req_mark_untrusted(struct ldb_request *req); 232 233 /** 234 mark a request as trusted. 235 */ 236 void ldb_req_mark_trusted(struct ldb_request *req); 237 238 /** 239 return true is a request is untrusted 240 */ 241 bool ldb_req_is_untrusted(struct ldb_request *req); 242 243 /* load all modules from the given directory */ 244 int ldb_modules_load(const char *modules_path, const char *version); 245 246 /* init functions prototype */ 247 typedef int (*ldb_module_init_fn)(const char *); 248 249 /* 250 general ldb hook function 251 */ 252 enum 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 256 typedef int (*ldb_hook_fn)(struct ldb_context *, enum ldb_module_hook_type ); 257 258 /* 259 register a ldb hook function 260 */ 261 int ldb_register_hook(ldb_hook_fn hook_fn); 262 263 /* 264 call ldb hooks of a given type 265 */ 266 int 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 */ 280 char *ldb_module_call_chain(struct ldb_request *req, TALLOC_CTX *mem_ctx); 281 282 /* 283 return the next module in the chain 284 */ 285 struct ldb_module *ldb_module_next(struct ldb_module *module); 286 287 /* 288 set the next module in the module chain 289 */ 290 void ldb_module_set_next(struct ldb_module *module, struct ldb_module *next); 291 292 /* 293 load a list of modules 294 */ 295 int 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 */ 302 struct 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 */ 307 const 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 */ 312 uint32_t ldb_module_flags(struct ldb_context *ldb); 313 314 int 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 */ 322 int 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 */ 327 int ldb_init_module(const char *version); 328 173 329 174 330 #endif -
trunk/server/source4/lib/ldb/include/ldb_private.h
r414 r745 38 38 #define _LDB_PRIVATE_H_ 1 39 39 40 #include "ldb_includes.h" 40 #include "replace.h" 41 #include "system/filesys.h" 42 #include "system/time.h" 41 43 #include "ldb.h" 42 44 #include "ldb_module.h" … … 49 51 50 52 #define LDB_HANDLE_FLAG_DONE_CALLED 1 53 /* call is from an untrusted source - eg. over ldap:// */ 54 #define LDB_HANDLE_FLAG_UNTRUSTED 2 51 55 52 56 struct ldb_handle { … … 56 60 unsigned flags; 57 61 unsigned nesting; 62 63 /* used for debugging */ 64 struct ldb_request *parent; 65 const char *location; 58 66 }; 59 67 … … 113 121 unsigned int create_perms; 114 122 115 char *modules_dir;116 117 123 struct tevent_context *ev_ctx; 118 124 … … 120 126 121 127 char *partial_debug; 128 129 struct poptOption *popt_options; 122 130 }; 123 131 124 132 /* 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 129 133 130 134 extern const struct ldb_module_ops ldb_objectclass_module_ops; … … 158 162 159 163 /* 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);164 char *ldb_casefold_default(void *context, TALLOC_CTX *mem_ctx, const char *s, size_t n); 161 165 162 166 void ldb_dump_results(struct ldb_context *ldb, struct ldb_result *result, FILE *f); … … 166 170 167 171 const 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);169 172 int ldb_load_modules(struct ldb_context *ldb, const char *options[]); 170 int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module);171 173 172 struct ldb_val ldb_binary_decode(void *mem_ctx, const char *str); 174 struct 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 179 const char *ldb_options_find(struct ldb_context *ldb, const char *options[], 180 const char *option_name); 173 181 174 182 #endif
Note:
See TracChangeset
for help on using the changeset viewer.