[SSSD] [PATCH] Add ldap_autofs_map_master_name option
C. S.
csleclish at gmail.com
Tue May 28 23:32:00 UTC 2013
(Including once more as an attachment, it looks like something may have
wrapped the lines when I had the patch in the body of the message.)
On Tue, May 28, 2013 at 4:29 PM, C. S. <csleclish at gmail.com> wrote:
> Hi Jakub,
>
> Thanks for the feedback! Very helpful. Looks like I dropped the LDAP map
> changes during a merge, that is now included. And I've removed the
> strdup(), whoops! ;-)
>
> cs
>
> From 33689c2565ec71d10eefe081fb3c502d1944d89e Mon Sep 17 00:00:00 2001
> From: Cove Schneider <cove at ilm.com>
> Date: Tue, 28 May 2013 16:15:11 -0700
> Subject: [PATCH] Add ldap_autofs_map_master_name option
>
> ---
> src/config/etc/sssd.api.d/sssd-ipa.conf | 1 +
> src/config/etc/sssd.api.d/sssd-ldap.conf | 1 +
> src/db/sysdb_autofs.h | 5 +++--
> src/man/sssd-ldap.5.xml | 13 +++++++++++++
> src/providers/ad/ad_opts.h | 1 +
> src/providers/data_provider_be.c | 7 -------
> src/providers/ipa/ipa_opts.h | 3 +++
> src/providers/ldap/ldap_common.c | 15 +++++++++++++++
> src/providers/ldap/ldap_common.h | 2 ++
> src/providers/ldap/ldap_opts.h | 5 +++++
> src/providers/ldap/sdap.h | 3 +++
> src/providers/ldap/sdap_autofs.c | 12 ++++++++++++
> 12 files changed, 59 insertions(+), 9 deletions(-)
>
> diff --git a/src/config/etc/sssd.api.d/sssd-ipa.conf
> b/src/config/etc/sssd.api.d/sssd-ipa.conf
> index
> e6f1bb0a88dd72a5f7bfcb269fa4736e7efd947c..5105a40a629d87a62a21cb6933a758943c1688cc
> 100644
> --- a/src/config/etc/sssd.api.d/sssd-ipa.conf
> +++ b/src/config/etc/sssd.api.d/sssd-ipa.conf
> @@ -162,6 +162,7 @@ ipa_hostgroup_uuid = str, None, false
>
> [provider/ipa/autofs]
> ipa_automount_location = str, None, false
> +ldap_autofs_map_master_name = str, None, false
> ldap_autofs_map_object_class = str, None, false
> ldap_autofs_map_name = str, None, false
> ldap_autofs_entry_object_class = str, None, false
> diff --git a/src/config/etc/sssd.api.d/sssd-ldap.conf
> b/src/config/etc/sssd.api.d/sssd-ldap.conf
> index
> 14e979da3413fe575e83b9a508c6cd8029d2bfba..aa521567f3f657885ba8978fdd118174b0ff9b4f
> 100644
> --- a/src/config/etc/sssd.api.d/sssd-ldap.conf
> +++ b/src/config/etc/sssd.api.d/sssd-ldap.conf
> @@ -153,6 +153,7 @@ ldap_sudorule_notafter = str, None, false
> ldap_sudorule_order = str, None, false
>
> [provider/ldap/autofs]
> +ldap_autofs_map_master_name = str, None, false
> ldap_autofs_map_object_class = str, None, false
> ldap_autofs_map_name = str, None, false
> ldap_autofs_entry_object_class = str, None, false
> diff --git a/src/db/sysdb_autofs.h b/src/db/sysdb_autofs.h
> index
> e3528ce4e6bd2c8b594c80828cfb02a9a7ce7923..97edaea03179d89d37073df41ca95cd544a53a29
> 100644
> --- a/src/db/sysdb_autofs.h
> +++ b/src/db/sysdb_autofs.h
> @@ -28,8 +28,9 @@
> #define AUTOFS_MAP_SUBDIR "autofsmaps"
> #define AUTOFS_ENTRY_SUBDIR "autofsentries"
>
> -#define SYSDB_AUTOFS_MAP_OC "automountMap"
> -#define SYSDB_AUTOFS_MAP_NAME "automountMapName"
> +#define SYSDB_AUTOFS_MAP_MASTER_NAME "automountMapMasterName"
> +#define SYSDB_AUTOFS_MAP_OC "automountMap"
> +#define SYSDB_AUTOFS_MAP_NAME "automountMapName"
>
> #define SYSDB_AUTOFS_ENTRY_OC "automount"
> #define SYSDB_AUTOFS_ENTRY_KEY "automountKey"
> diff --git a/src/man/sssd-ldap.5.xml b/src/man/sssd-ldap.5.xml
> index
> 37df5ec1b2e0b150b407f5e3e39db21860055580..b06286742577b84c347701ab0cd56c4e661a44c8
> 100644
> --- a/src/man/sssd-ldap.5.xml
> +++ b/src/man/sssd-ldap.5.xml
> @@ -2169,6 +2169,19 @@ ldap_access_filter =
> memberOf=cn=allowedusers,ou=Groups,dc=example,dc=com
> <para>
> <variablelist>
> <varlistentry>
> + <term>ldap_autofs_map_master_name (string)</term>
> + <listitem>
> + <para>
> + The name of the automount master map in LDAP.
> + </para>
> + <para>
> + Default: auto.master
> + </para>
> + </listitem>
> + </varlistentry>
> + </variablelist>
> + <variablelist>
> + <varlistentry>
> <term>ldap_autofs_map_object_class (string)</term>
> <listitem>
> <para>
> diff --git a/src/providers/ad/ad_opts.h b/src/providers/ad/ad_opts.h
> index
> 218614dca82ab1b5a2d54291ead3d9719a4c7e2a..8ce0c475265a8602edea72ecdff18f77f8ecab75
> 100644
> --- a/src/providers/ad/ad_opts.h
> +++ b/src/providers/ad/ad_opts.h
> @@ -65,6 +65,7 @@ struct dp_option ad_def_ldap_opts[] = {
> { "ldap_sudo_include_netgroups", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
> { "ldap_sudo_include_regexp", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
> { "ldap_autofs_search_base", DP_OPT_STRING, NULL_STRING, NULL_STRING
> },
> + { "ldap_autofs_map_master_name", DP_OPT_STRING, NULL_STRING,
> NULL_STRING },
> { "ldap_schema", DP_OPT_STRING, { "ad" }, NULL_STRING },
> { "ldap_offline_timeout", DP_OPT_NUMBER, { .number = 60 },
> NULL_NUMBER },
> { "ldap_force_upper_case_realm", DP_OPT_BOOL, BOOL_TRUE, BOOL_FALSE },
> diff --git a/src/providers/data_provider_be.c
> b/src/providers/data_provider_be.c
> index
> cd6715680eb4871806cc5148cecd2e118885a105..11e8979c2afe4bbcad19ef77b241843463e02c58
> 100644
> --- a/src/providers/data_provider_be.c
> +++ b/src/providers/data_provider_be.c
> @@ -1643,13 +1643,6 @@ static int be_autofs_handler(DBusMessage *message,
> struct sbus_connection *conn)
> goto done;
> }
>
> - /* If a request for auto.master comes in, the automounter deamon
> - * has been reloaded. Expire all autofs maps to force reload
> - */
> - if (strcmp(be_autofs_req->mapname, "auto.master") == 0) {
> - be_autofs_req->invalidate = true;
> - }
> -
> be_req->req_data = be_autofs_req;
>
> if (!be_cli->bectx->bet_info[BET_AUTOFS].bet_ops) {
> diff --git a/src/providers/ipa/ipa_opts.h b/src/providers/ipa/ipa_opts.h
> index
> 4dfa72db430b1d3dfb528cc425c7156baf5ebe47..9a99dcdb782ea3cb070f877362a0ab2b7d80be5c
> 100644
> --- a/src/providers/ipa/ipa_opts.h
> +++ b/src/providers/ipa/ipa_opts.h
> @@ -89,6 +89,7 @@ struct dp_option ipa_def_ldap_opts[] = {
> { "ldap_sudo_include_netgroups", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
> { "ldap_sudo_include_regexp", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
> { "ldap_autofs_search_base", DP_OPT_STRING, NULL_STRING, NULL_STRING
> },
> + { "ldap_autofs_map_master_name", DP_OPT_STRING, NULL_STRING,
> NULL_STRING },
> { "ldap_schema", DP_OPT_STRING, { "ipa_v1" }, NULL_STRING },
> { "ldap_offline_timeout", DP_OPT_NUMBER, { .number = 60 },
> NULL_NUMBER },
> { "ldap_force_upper_case_realm", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
> @@ -287,12 +288,14 @@ struct sdap_attr_map ipa_service_map[] = {
> };
>
> struct sdap_attr_map ipa_autofs_mobject_map[] = {
> + { "ldap_autofs_map_master_name", "automountMapMasterName",
> SYSDB_AUTOFS_MAP_MASTER_NAME, NULL },
> { "ldap_autofs_map_object_class", "automountMap",
> SYSDB_AUTOFS_MAP_OC, NULL },
> { "ldap_autofs_map_name", "automountMapName", SYSDB_AUTOFS_MAP_NAME,
> NULL },
> SDAP_ATTR_MAP_TERMINATOR
> };
>
> struct sdap_attr_map ipa_autofs_entry_map[] = {
> + { "ldap_autofs_map_master_name", "automountMapMasterName",
> SYSDB_AUTOFS_MAP_MASTER_NAME, NULL },
> { "ldap_autofs_entry_object_class", "automount",
> SYSDB_AUTOFS_ENTRY_OC, NULL },
> { "ldap_autofs_entry_key", "automountKey", SYSDB_AUTOFS_ENTRY_KEY,
> NULL },
> { "ldap_autofs_entry_value", "automountInformation",
> SYSDB_AUTOFS_ENTRY_VALUE, NULL },
> diff --git a/src/providers/ldap/ldap_common.c
> b/src/providers/ldap/ldap_common.c
> index
> acb24b190157efe06967963ad05014cf9017db7f..0c70d44b78eaa45f27e6ae0ee29c96404ca6df0b
> 100644
> --- a/src/providers/ldap/ldap_common.c
> +++ b/src/providers/ldap/ldap_common.c
> @@ -407,10 +407,25 @@ int ldap_get_autofs_options(TALLOC_CTX *memctx,
> struct sdap_options *opts)
> {
> const char *search_base;
> + const char *master_map;
> struct sdap_attr_map *default_entry_map;
> struct sdap_attr_map *default_mobject_map;
> int ret;
>
> + /* automount master map name */
> + master_map = dp_opt_get_string(opts->basic,
> SDAP_AUTOFS_MAP_MASTER_NAME);
> + if (master_map == NULL) {
> + ret = dp_opt_set_string(opts->basic, SDAP_AUTOFS_MAP_MASTER_NAME,
> + AUTOFS_MAP_MASTER_NAME);
> + if (ret != EOK) {
> + DEBUG(SSSDBG_OP_FAILURE, ("Could not set autofs master map
> name"
> + " to default value\n"));
> + return ret;
> + }
> + master_map = dp_opt_get_string(opts->basic,
> SDAP_AUTOFS_MAP_MASTER_NAME);
> + }
> + DEBUG(SSSDBG_FUNC_DATA, ("Option ldap_autofs_map_master_name set to
> %s\n", master_map));
> +
> /* search base */
> search_base = dp_opt_get_string(opts->basic, SDAP_SEARCH_BASE);
> if (search_base != NULL) {
> diff --git a/src/providers/ldap/ldap_common.h
> b/src/providers/ldap/ldap_common.h
> index
> 2d17b755808e58831b458bcc86a50eb74b1f1057..ec48db68a457b9cf4e490b649eaefd0573ad8e71
> 100644
> --- a/src/providers/ldap/ldap_common.h
> +++ b/src/providers/ldap/ldap_common.h
> @@ -39,6 +39,8 @@
> #define LDAP_SSL_URI "ldaps://"
> #define LDAP_LDAPI_URI "ldapi://"
>
> +#define AUTOFS_MAP_MASTER_NAME "auto.master"
> +
> /* a fd the child process would log into */
> extern int ldap_child_debug_fd;
>
> diff --git a/src/providers/ldap/ldap_opts.h
> b/src/providers/ldap/ldap_opts.h
> index
> 807716c18244ae70759d9b2eff7e40fd3c634fb2..f4b572e687ce0227f124217f9f2b43b1c801e227
> 100644
> --- a/src/providers/ldap/ldap_opts.h
> +++ b/src/providers/ldap/ldap_opts.h
> @@ -56,6 +56,7 @@ struct dp_option default_basic_opts[] = {
> { "ldap_sudo_include_netgroups", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
> { "ldap_sudo_include_regexp", DP_OPT_BOOL, BOOL_TRUE, BOOL_TRUE },
> { "ldap_autofs_search_base", DP_OPT_STRING, NULL_STRING, NULL_STRING
> },
> + { "ldap_autofs_map_master_name", DP_OPT_STRING, NULL_STRING,
> NULL_STRING },
> { "ldap_schema", DP_OPT_STRING, { "rfc2307" }, NULL_STRING },
> { "ldap_offline_timeout", DP_OPT_NUMBER, { .number = 60 },
> NULL_NUMBER },
> { "ldap_force_upper_case_realm", DP_OPT_BOOL, BOOL_FALSE, BOOL_FALSE
> },
> @@ -330,12 +331,14 @@ struct sdap_attr_map service_map[] = {
> };
>
> struct sdap_attr_map rfc2307_autofs_mobject_map[] = {
> + { "ldap_autofs_map_master_name", "automountMapMasterName",
> SYSDB_AUTOFS_MAP_MASTER_NAME, NULL },
> { "ldap_autofs_map_object_class", "automountMap",
> SYSDB_AUTOFS_MAP_OC, NULL },
> { "ldap_autofs_map_name", "ou", SYSDB_AUTOFS_MAP_NAME, NULL },
> SDAP_ATTR_MAP_TERMINATOR
> };
>
> struct sdap_attr_map rfc2307_autofs_entry_map[] = {
> + { "ldap_autofs_map_master_name", "automountMapMasterName",
> SYSDB_AUTOFS_MAP_MASTER_NAME, NULL },
> { "ldap_autofs_entry_object_class", "automount",
> SYSDB_AUTOFS_ENTRY_OC, NULL },
> { "ldap_autofs_entry_key", "cn", SYSDB_AUTOFS_ENTRY_KEY, NULL },
> { "ldap_autofs_entry_value", "automountInformation",
> SYSDB_AUTOFS_ENTRY_VALUE, NULL },
> @@ -343,12 +346,14 @@ struct sdap_attr_map rfc2307_autofs_entry_map[] = {
> };
>
> struct sdap_attr_map rfc2307bis_autofs_mobject_map[] = {
> + { "ldap_autofs_map_master_name", "automountMapMasterName",
> SYSDB_AUTOFS_MAP_MASTER_NAME, NULL },
> { "ldap_autofs_map_object_class", "automountMap",
> SYSDB_AUTOFS_MAP_OC, NULL },
> { "ldap_autofs_map_name", "automountMapName", SYSDB_AUTOFS_MAP_NAME,
> NULL },
> SDAP_ATTR_MAP_TERMINATOR
> };
>
> struct sdap_attr_map rfc2307bis_autofs_entry_map[] = {
> + { "ldap_autofs_map_master_name", "automountMapMasterName",
> SYSDB_AUTOFS_MAP_MASTER_NAME, NULL },
> { "ldap_autofs_entry_object_class", "automount",
> SYSDB_AUTOFS_ENTRY_OC, NULL },
> { "ldap_autofs_entry_key", "automountKey", SYSDB_AUTOFS_ENTRY_KEY,
> NULL },
> { "ldap_autofs_entry_value", "automountInformation",
> SYSDB_AUTOFS_ENTRY_VALUE, NULL },
> diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
> index
> 162250fff76295807cce0779bebdf88577ed755c..e56690a10907ede5205ddb463ff6d4fc226145b3
> 100644
> --- a/src/providers/ldap/sdap.h
> +++ b/src/providers/ldap/sdap.h
> @@ -164,6 +164,7 @@ enum sdap_basic_opt {
> SDAP_SUDO_INCLUDE_NETGROUPS,
> SDAP_SUDO_INCLUDE_REGEXP,
> SDAP_AUTOFS_SEARCH_BASE,
> + SDAP_AUTOFS_MAP_MASTER_NAME,
> SDAP_SCHEMA,
> SDAP_OFFLINE_TIMEOUT,
> SDAP_FORCE_UPPER_CASE_REALM,
> @@ -327,6 +328,7 @@ enum sdap_service_attrs {
> };
>
> enum sdap_autofs_map_attrs {
> + SDAP_AT_AUTOFS_MAP_MASTER_NAME,
> SDAP_OC_AUTOFS_MAP,
> SDAP_AT_AUTOFS_MAP_NAME,
>
> @@ -334,6 +336,7 @@ enum sdap_autofs_map_attrs {
> };
>
> enum sdap_autofs_entry_attrs {
> + _SDAP_AT_AUTOFS_MAP_MASTER_NAME,
> SDAP_OC_AUTOFS_ENTRY,
> SDAP_AT_AUTOFS_ENTRY_KEY,
> SDAP_AT_AUTOFS_ENTRY_VALUE,
> diff --git a/src/providers/ldap/sdap_autofs.c
> b/src/providers/ldap/sdap_autofs.c
> index
> 0bb211aa3e3ae9ec822e117f8febf8378bb09f79..e4ef7257bd251fdf7cc672c7f96bb67e3bc4ff32
> 100644
> --- a/src/providers/ldap/sdap_autofs.c
> +++ b/src/providers/ldap/sdap_autofs.c
> @@ -30,6 +30,7 @@
> #include "providers/ldap/sdap.h"
> #include "providers/ldap/sdap_async.h"
> #include "providers/dp_backend.h"
> +#include "providers/data_provider.h"
> #include "db/sysdb_autofs.h"
> #include "util/util.h"
>
> @@ -82,6 +83,7 @@ void sdap_autofs_handler(struct be_req *be_req)
> struct sdap_id_ctx *id_ctx;
> struct be_autofs_req *autofs_req;
> struct tevent_req *req;
> + const char *master_map;
> int ret = EOK;
>
> DEBUG(SSSDBG_TRACE_INTERNAL, ("sdap autofs handler called\n"));
> @@ -98,6 +100,16 @@ void sdap_autofs_handler(struct be_req *be_req)
> DEBUG(SSSDBG_FUNC_DATA, ("Requested refresh for: %s\n",
> autofs_req->mapname ? autofs_req->mapname : "<ALL>\n"));
>
> + if (autofs_req->mapname != NULL) {
> + master_map = dp_opt_get_string(id_ctx->opts->basic,
> + SDAP_AUTOFS_MAP_MASTER_NAME);
> + if (strcmp(master_map, autofs_req->mapname) == 0) {
> + autofs_req->invalidate = true;
> + DEBUG(SSSDBG_FUNC_DATA, ("Refresh of automount master map
> triggered: %s\n",
> + autofs_req->mapname));
> + }
> + }
> +
> if (autofs_req->invalidate) {
> ret = sysdb_invalidate_autofs_maps(id_ctx->be->domain->sysdb,
> id_ctx->be->domain);
> --
> 1.8.1.4
>
>
>
>
>
> On Mon, May 27, 2013 at 8:28 AM, Jakub Hrozek <jhrozek at redhat.com> wrote:
> >
> > On Fri, May 24, 2013 at 04:41:13PM -0700, C. S. wrote:
> > > Add ldap_autofs_map_master_name option so that the auto master map name
> > > change be changed from the default auto.master.
> >
> > Hi Cove,
> >
> > this quite a good patch, thank you very much for the contribution.
> >
> > I haven't done much testing yet, but I only have a couple of small
> > suggestions before we can apply the patch to master.
> >
> > Here is a diff that summarizes them with comments inline:
> >
> > diff --git a/src/providers/ldap/ldap_common.c
> b/src/providers/ldap/ldap_common.c
> > index 3e019d9..201dcbe 100644
> > --- a/src/providers/ldap/ldap_common.c
> > +++ b/src/providers/ldap/ldap_common.c
> > @@ -415,7 +415,6 @@ int ldap_get_autofs_options(TALLOC_CTX *memctx,
> > /* automount master map name */
> > master_map = dp_opt_get_string(opts->basic,
> SDAP_AUTOFS_MAP_MASTER_NAME);
> > if (master_map == NULL) {
> > - master_map = strdup(AUTOFS_MAP_MASTER_NAME);
> >
> > You don't have to strdup the option value, the call to
> dp_opt_set_string()
> > duplicates the value itself and maintains the memory hierarchy as it
> > uses the talloc allocator.
> >
> > ret = dp_opt_set_string(opts->basic,
> SDAP_AUTOFS_MAP_MASTER_NAME,
> > master_map);
> > if (ret != EOK) {
> > diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
> > index e56690a..7d2d3f5 100644
> > --- a/src/providers/ldap/sdap.h
> > +++ b/src/providers/ldap/sdap.h
> >
> > In the LDAP maps it's OK to add the new option to the "enum
> > sdap_basic_opt". The reason is that SSSD maintains a couple of "option
> > maps" for both the LDAP provider as a whole and for the individual
> > object maps. The LDAP provider maps describe how to get the object from
> > LDAP (for instance it contains the search bases, timeouts, schema etc.)
> > and then the per-object maps describe how to get the individual objects
> > (what attribute name describes which attribute, for instance "cn"
> > usually stands for "name).
> >
> > I was wondering for a short while whether the new attribute belongs to
> > the generic LDAP map or the autofs map object map, but I think this
> > solution is OK. It describes a mean to get the master map, not any
> > master map attribute.
> >
> > @@ -328,7 +328,6 @@ enum sdap_service_attrs {
> > };
> >
> > enum sdap_autofs_map_attrs {
> > - SDAP_AT_AUTOFS_MAP_MASTER_NAME,
> > SDAP_OC_AUTOFS_MAP,
> > SDAP_AT_AUTOFS_MAP_NAME,
> >
> > @@ -336,7 +335,6 @@ enum sdap_autofs_map_attrs {
> > };
> >
> > enum sdap_autofs_entry_attrs {
> > - _SDAP_AT_AUTOFS_MAP_MASTER_NAME,
> > SDAP_OC_AUTOFS_ENTRY,
> > SDAP_AT_AUTOFS_ENTRY_KEY,
> > SDAP_AT_AUTOFS_ENTRY_VALUE,
> >
> >
> > Thank you again for the patch!
> > _______________________________________________
> > sssd-devel mailing list
> > sssd-devel at lists.fedorahosted.org
> > https://lists.fedorahosted.org/mailman/listinfo/sssd-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fedorahosted.org/pipermail/sssd-devel/attachments/20130528/e1a3f81a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-ldap_autofs_map_master_name-option.patch
Type: application/octet-stream
Size: 13783 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/sssd-devel/attachments/20130528/e1a3f81a/attachment.obj>
More information about the sssd-devel
mailing list