diff options
| author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-05-30 17:37:53 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-05-30 17:37:53 -0400 |
| commit | 111b605d8259c0385216aac4a2d50bd504ec37ce (patch) | |
| tree | e9bfc398b944710d6f12407811078b935b9cf283 /src | |
| parent | 124e4ad90094d5fd7361e2fefed4c46aa840302a (diff) | |
- make functions that take separators for constructing lists take them first
- have groups use both posix and groupofuniquenames user lists
Diffstat (limited to 'src')
| -rw-r--r-- | src/defaults.c | 4 | ||||
| -rw-r--r-- | src/format.c | 35 |
2 files changed, 25 insertions, 14 deletions
diff --git a/src/defaults.c b/src/defaults.c index 52a3b60..617cb77 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -43,11 +43,11 @@ static struct configuration { {"group.byname", "(objectClass=posixGroup)", "%{cn}", - "%{cn}:%regmatch(\"userPassword\",\"^{CRYPT}.............*\",\"*\"):%{gidNumber}:%list(\",\",\"memberUid\")"}, + "%{cn}:%regmatch(\"userPassword\",\"^{CRYPT}.............*\",\"*\"):%{gidNumber}:%merge(\",\",\"%list(\\\",\\\",\\\"memberUid\\\")\",\"%deref(\\\",\\\",\\\"uniqueMember\\\",\\\"uid\\\")\")"}, {"group.bynumber", "(objectClass=posixGroup)", "%{gidNumber}", - "%{cn}:%regmatch(\"userPassword\",\"^{CRYPT}.............*\",\"*\"):%{gidNumber}:%list(\",\",\"memberUid\")"}, + "%{cn}:%regmatch(\"userPassword\",\"^{CRYPT}.............*\",\"*\"):%{gidNumber}:%merge(\",\",\"%list(\\\",\\\",\\\"memberUid\\\")\",\"%deref(\\\",\\\",\\\"uniqueMember\\\",\\\"uid\\\")\")"}, }; void diff --git a/src/format.c b/src/format.c index 72c915e..f738c44 100644 --- a/src/format.c +++ b/src/format.c @@ -141,6 +141,12 @@ format_echo(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, "echo: error parsing arguments\n"); return -1; } + if (argc < 1) { + slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + "echo: requires at least one argument\n"); + format_free_parsed_args(argv); + return -1; + } for (i = 0, ret = 0; i < argc; i++) { /* Get the length of this argument. */ len = strlen(argv[i]); @@ -236,10 +242,9 @@ format_list(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, return ret; } -/* Look up the entry matching a DN stored in the attribute named by the first - * argument, pull out the values for the attribute named by the second - * argument, and create a list separated by either "," or the third argument, - * if a third argument is given. */ +/* Look up the entry matching a DN stored in the attribute named by the second + * argument, pull out the values for the attribute named by the thirdd + * argument, and create a list separated by the first argument. */ static int format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, const char *args, char *outbuf, int outbuf_len, @@ -259,14 +264,14 @@ format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, "deref: error parsing arguments\n"); return -1; } - if (argc < 2) { + if (argc < 3) { slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, - "deref: requires 2 arguments\n"); + "deref: requires 3 arguments\n"); format_free_parsed_args(argv); return -1; } - /* Get the names of the references. */ - if (slapi_vattr_values_get(e, argv[0], &ref_values, + /* Get the names of the reference attribute. */ + if (slapi_vattr_values_get(e, argv[1], &ref_values, &ref_disposition, &actual_ref_attr, 0, &ref_buffer_flags) != 0) { /* No references. */ @@ -274,8 +279,8 @@ format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, return 0; } /* Retrieve these attributes from the referred-to entries. */ - attrs[0] = argv[0]; - attrs[1] = argv[1]; + attrs[0] = argv[1]; + attrs[1] = argv[2]; attrs[2] = NULL; /* Iterate through the names of the referred-to entries. */ count = 0; @@ -308,7 +313,7 @@ format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } slapi_sdn_free(&refdn); /* Pull out the attribute from the referred-to entry. */ - if (slapi_vattr_values_get(ref, argv[1], &values, + if (slapi_vattr_values_get(ref, argv[2], &values, &disposition, &actual_attr, 0, &buffer_flags) != 0) { slapi_entry_free(ref); @@ -342,7 +347,7 @@ format_deref(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* If we need to, add the separator. */ if (count > 0) { /* Get the length of the separator. */ - sep = (argc > 2) ? argv[2] : ","; + sep = argv[0]; slen = strlen(sep); /* Check if there's space for the separator. */ if (ret + len + slen > outbuf_len) { @@ -394,6 +399,12 @@ format_merge(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, "merge: error parsing arguments\n"); return -1; } + if (argc < 1) { + slapi_log_error(SLAPI_LOG_PLUGIN, state->plugin_desc->spd_id, + "merge: requires at least one argument\n"); + format_free_parsed_args(argv); + return -1; + } for (i = 1, ret = 0, count = 0; i < argc; i++) { /* Expand this argument. */ slapi_log_error(SLAPI_LOG_PLUGIN, |
