3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #include <stdio.h>
28 #include <string.h>
29 #include <stdlib.h>
30 #include <ctype.h>
31 #include <fcntl.h>
32 #include <errno.h>
33 #include <syslog.h>
34
35 #include "ldap_parse.h"
36 #include "nis_parse_ldap_conf.h"
37 #include "nis_parse_ldap_err.h"
38 #include "ldap_util.h"
39
40 extern __nis_mapping_rule_t **dup_mapping_rules(
41 __nis_mapping_rule_t **rules, int n_rules);
42 extern __nis_mapping_rule_t *dup_mapping_rule(
43 __nis_mapping_rule_t *in);
44
45 static int merge_table_mapping(__nis_table_mapping_t *in,
46 __nis_table_mapping_t *out);
47 __nis_table_mapping_t *new_merged_mapping(const char *,
48 __nis_table_mapping_t *intbl);
49 static int append_mapping_rule(__nis_mapping_rule_t *src_rule,
50 __nis_table_mapping_t *tbl, int flag);
51
52
53 static int copy_object_dn(__nis_object_dn_t *in,
54 __nis_object_dn_t *newdn);
55
56 /*
57 * FUNCTION: initialize_table_mapping
58 *
59 * Initialize the __nis_table_mapping_t structure.
60 *
61 * INPUT: __nis_table_mapping_t
62 *
63 */
121 ypDomains->numYppasswdd = 0;
122 ypDomains->yppasswddDomainLabels = NULL;
123 }
124
125 /*
126 * FUNCTION: merge_table_mapping
127 *
128 * Merges information from one table_mapping struct
129 * into another
130 *
131 * INPUT: Source and Destination table_mapping structs.
132 * RETURN: 0 on success and > 0 on error.
133 */
134
135 static int
136 merge_table_mapping(
137 __nis_table_mapping_t *in,
138 __nis_table_mapping_t *out)
139 {
140 int i;
141 int len;
142 int orig_num_rules;
143 int append;
144
145 if (in == NULL)
146 return (1);
147
148 if (in->dbId == NULL)
149 return (1);
150
151 /*
152 * If 'in' is generic (non-expanded) and 'out' is domain-specific,
153 * then rules from 'in' should not be appended to those in 'out'.
154 */
155 if (!strchr(in->dbId, COMMA_CHAR) && strchr(out->dbId, COMMA_CHAR))
156 append = 0;
157 else
158 append = 1;
159
160
161 if (!out->index.numIndexes && in->index.numIndexes > 0) {
417 domains->numDomains = 0;
418 domains = NULL;
419 }
420 }
421
422 /*
423 * FUNCTION: second_parser_pass
424 *
425 * Prepares the linked list of table_mappings for processing
426 * by finish_parse(), adding, merging and deleting structures
427 * as necessary. Also adds dummy objectDN info. for splitField's.
428 *
429 * RETURN VALUE: 0 on success, > 0 on failure.
430 */
431 int
432 second_parser_pass(__nis_table_mapping_t **table_mapping)
433 {
434 __nis_table_mapping_t *t, *t2;
435 __nis_table_mapping_t *t_new = NULL, *tg;
436 __nis_table_mapping_t *prev = NULL;
437 __nis_object_dn_t *objectDN;
438 char *objs, *dom;
439 char *objName = NULL;
440 char *lasts;
441 char *tobj, *alias, *dupalias, *tmp;
442 char *myself = "second_parser_pass";
443 int i = 0, len;
444 int remove_t = 0;
445 int add_t = 0;
446
447 prev = NULL;
448 for (t = *table_mapping; t != NULL; ) {
449 /*
450 * Temporarily using this field to flag deletion.
451 * 0 : don't delete
452 * 1 : delete
453 * The mapping structure will be deleted in final_parser_pass
454 */
455 t->isMaster = 0;
456
457 if (!t->dbId) {
458 p_error = parse_bad_map_error;
459 logmsg(MSG_NOTIMECHECK, LOG_ERR,
460 "%s: no dbId field", myself);
461 return (1);
462 }
463 tg = NULL;
464 dom = strchr(t->dbId, COMMA_CHAR);
465 if (t->objName != NULL) {
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2015 Gary Mills
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28 #include <stdio.h>
29 #include <string.h>
30 #include <stdlib.h>
31 #include <ctype.h>
32 #include <fcntl.h>
33 #include <errno.h>
34 #include <syslog.h>
35
36 #include "ldap_parse.h"
37 #include "nis_parse_ldap_conf.h"
38 #include "nis_parse_ldap_util.h"
39 #include "ldap_util.h"
40
41 /* Forward declarations */
42 int getfullmapname(char **, const char *);
43 int checkfullmapname(const char *, const char *, __nis_table_mapping_t **,
44 __nis_table_mapping_t **);
45 int append_domainContext(__nis_table_mapping_t **, char *, char *);
46
47 static int merge_table_mapping(__nis_table_mapping_t *in,
48 __nis_table_mapping_t *out);
49 __nis_table_mapping_t *new_merged_mapping(const char *,
50 __nis_table_mapping_t *intbl);
51 static int append_mapping_rule(__nis_mapping_rule_t *src_rule,
52 __nis_table_mapping_t *tbl, int flag);
53
54
55 static int copy_object_dn(__nis_object_dn_t *in,
56 __nis_object_dn_t *newdn);
57
58 /*
59 * FUNCTION: initialize_table_mapping
60 *
61 * Initialize the __nis_table_mapping_t structure.
62 *
63 * INPUT: __nis_table_mapping_t
64 *
65 */
123 ypDomains->numYppasswdd = 0;
124 ypDomains->yppasswddDomainLabels = NULL;
125 }
126
127 /*
128 * FUNCTION: merge_table_mapping
129 *
130 * Merges information from one table_mapping struct
131 * into another
132 *
133 * INPUT: Source and Destination table_mapping structs.
134 * RETURN: 0 on success and > 0 on error.
135 */
136
137 static int
138 merge_table_mapping(
139 __nis_table_mapping_t *in,
140 __nis_table_mapping_t *out)
141 {
142 int i;
143 int orig_num_rules;
144 int append;
145
146 if (in == NULL)
147 return (1);
148
149 if (in->dbId == NULL)
150 return (1);
151
152 /*
153 * If 'in' is generic (non-expanded) and 'out' is domain-specific,
154 * then rules from 'in' should not be appended to those in 'out'.
155 */
156 if (!strchr(in->dbId, COMMA_CHAR) && strchr(out->dbId, COMMA_CHAR))
157 append = 0;
158 else
159 append = 1;
160
161
162 if (!out->index.numIndexes && in->index.numIndexes > 0) {
418 domains->numDomains = 0;
419 domains = NULL;
420 }
421 }
422
423 /*
424 * FUNCTION: second_parser_pass
425 *
426 * Prepares the linked list of table_mappings for processing
427 * by finish_parse(), adding, merging and deleting structures
428 * as necessary. Also adds dummy objectDN info. for splitField's.
429 *
430 * RETURN VALUE: 0 on success, > 0 on failure.
431 */
432 int
433 second_parser_pass(__nis_table_mapping_t **table_mapping)
434 {
435 __nis_table_mapping_t *t, *t2;
436 __nis_table_mapping_t *t_new = NULL, *tg;
437 __nis_table_mapping_t *prev = NULL;
438 char *objs, *dom;
439 char *objName = NULL;
440 char *lasts;
441 char *tobj, *alias, *dupalias, *tmp;
442 char *myself = "second_parser_pass";
443 int i = 0, len;
444
445 prev = NULL;
446 for (t = *table_mapping; t != NULL; ) {
447 /*
448 * Temporarily using this field to flag deletion.
449 * 0 : don't delete
450 * 1 : delete
451 * The mapping structure will be deleted in final_parser_pass
452 */
453 t->isMaster = 0;
454
455 if (!t->dbId) {
456 p_error = parse_bad_map_error;
457 logmsg(MSG_NOTIMECHECK, LOG_ERR,
458 "%s: no dbId field", myself);
459 return (1);
460 }
461 tg = NULL;
462 dom = strchr(t->dbId, COMMA_CHAR);
463 if (t->objName != NULL) {
|