public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: Lon Hohberger <lon@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: cluster: STABLE3 - config: Add 'cn' to LDIF when needed Date: Thu, 10 Sep 2009 17:49:00 -0000 [thread overview] Message-ID: <20090910174917.397381201EF@lists.fedorahosted.org> (raw) Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=85bc3dd69ce5dfac07bc90e85619fa3123813f29 Commit: 85bc3dd69ce5dfac07bc90e85619fa3123813f29 Parent: 631ec23c7baf7fc4ff6cad16fba7f8a02ebe0dcc Author: Lon Hohberger <lhh@redhat.com> AuthorDate: Thu Sep 10 13:29:56 2009 -0400 Committer: Lon Hohberger <lhh@redhat.com> CommitterDate: Thu Sep 10 13:29:56 2009 -0400 config: Add 'cn' to LDIF when needed Adds 'MUST ( cn )' to LDIF output when no 'name' or 'cn' attribute is present already. Signed-off-by: Lon Hohberger <lhh@redhat.com> --- config/tools/ldap/rng2ldif/rng2ldif.c | 10 ++++++++ config/tools/ldap/rng2ldif/tree.c | 39 ++++++++++++++++++++++++++++---- config/tools/ldap/rng2ldif/tree.h | 2 + 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/config/tools/ldap/rng2ldif/rng2ldif.c b/config/tools/ldap/rng2ldif/rng2ldif.c index ea99e8b..33e795c 100644 --- a/config/tools/ldap/rng2ldif/rng2ldif.c +++ b/config/tools/ldap/rng2ldif/rng2ldif.c @@ -81,10 +81,20 @@ print_obj_node(FILE *fp, struct ldap_object_node *node) if (node->required_attrs) { fprintf(fp, "%s MUST ( ", cmt); + + if (node->need_cn) { + fprintf(fp, "cn $ "); + } + for (n = node->required_attrs; n->next != NULL; n = n->next) fprintf(fp, "%s $ ", n->node->name); fprintf(fp, "%s )\n", n->node->name); + } else { + if (node->need_cn) { + fprintf(fp, "%s MUST ( cn )\n", cmt); + } } + if (node->optional_attrs) { fprintf(fp, "%s MAY ( ", cmt); for (n = node->optional_attrs; n->next != NULL; n = n->next) diff --git a/config/tools/ldap/rng2ldif/tree.c b/config/tools/ldap/rng2ldif/tree.c index a6e0b46..61acc5b 100644 --- a/config/tools/ldap/rng2ldif/tree.c +++ b/config/tools/ldap/rng2ldif/tree.c @@ -13,7 +13,7 @@ static struct ldap_attr_node * -find_attr(struct ldap_attr_node *attrs, const char *name) +find_attr_byname(struct ldap_attr_node *attrs, const char *name) { struct ldap_attr_node *n; @@ -38,6 +38,19 @@ find_meta_attr(struct ldap_attr_meta_node *metas, struct ldap_attr_node *attr) } +static struct ldap_attr_meta_node * +find_meta_attr_byname(struct ldap_attr_meta_node *metas, const char *name) +{ + struct ldap_attr_meta_node *n; + + for (n = metas; n; n = n->next) { + if (!strcmp(n->node->name, name)) + return n; + } + return NULL; +} + + static int find_data_match_fn(xmlNodePtr curr_node, char **match_fn, char **ldap_syntax) { @@ -82,7 +95,7 @@ get_attr(xmlNodePtr curr_node, struct ldap_attr_node **attrs, name = (char *)xmlGetProp(curr_node, (xmlChar *)"name"); normalized = normalize_name((const char *)name); - n = find_attr(*attrs, normalized); + n = find_attr_byname(*attrs, normalized); if (n) { free(normalized); return n; @@ -249,8 +262,10 @@ parse_element_tag(xmlNodePtr curr_node, struct idinfo *ids) { struct ldap_object_node *obj; + struct ldap_attr_meta_node *attrm; char *n, *normalized; struct idval *v; + int need_cn = 1; dbg_printf("Trying to parse element tag\n"); n = (char *)xmlGetProp(curr_node, (xmlChar *)"name"); @@ -273,13 +288,29 @@ parse_element_tag(xmlNodePtr curr_node, obj->idval = v; obj->next = *objs; *objs = obj; - dbg_printf("New object class %s \n",obj->name); + printf("New object class %s \n",obj->name); } find_optional_attributes(curr_node->xmlChildrenNode, 0, obj, attrs, ids); find_required_attributes(curr_node->xmlChildrenNode, obj, attrs, ids); + + if (find_meta_attr_byname(obj->required_attrs, "name") || + find_meta_attr_byname(obj->required_attrs, "cn")) { + need_cn = 0; + } + + if (need_cn && + (find_meta_attr_byname(obj->optional_attrs, "name") || + find_meta_attr_byname(obj->optional_attrs, "cn"))) { + need_cn = 0; + } + + if (need_cn) { + dbg_printf("Object class might %s need 'MUST ( cn )' for proper LDIF\n", obj->name); + obj->need_cn = 1; + } } @@ -289,8 +320,6 @@ find_objects(xmlNodePtr curr_node, struct ldap_attr_node **attrs, struct idinfo *ids) { - //xmlNodePtr node; - if (!curr_node) return 0; diff --git a/config/tools/ldap/rng2ldif/tree.h b/config/tools/ldap/rng2ldif/tree.h index 098f4b6..f55c556 100644 --- a/config/tools/ldap/rng2ldif/tree.h +++ b/config/tools/ldap/rng2ldif/tree.h @@ -26,6 +26,8 @@ struct ldap_object_node { struct idval *idval; struct ldap_attr_meta_node *optional_attrs; struct ldap_attr_meta_node *required_attrs; + int need_cn; /* If we don't have a 'name' or a 'cn' attribute, + add one when we output the LDIF */ }; int
reply other threads:[~2009-09-10 17:49 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090910174917.397381201EF@lists.fedorahosted.org \ --to=lon@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).