From 8fa5947ae62aafa46c6b327df69a483cfde7bd2d Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Wed, 28 Mar 2012 11:58:36 -0400
Subject: [PATCH 4/6] Add terminator for sdap_attr_map

---
 src/providers/ipa/ipa_opts.h   |   26 ++++++++++++++++-------
 src/providers/ldap/ldap_opts.h |   44 +++++++++++++++++++++++++++------------
 src/providers/ldap/sdap.h      |    1 +
 3 files changed, 49 insertions(+), 22 deletions(-)

diff --git a/src/providers/ipa/ipa_opts.h b/src/providers/ipa/ipa_opts.h
index 7f858e2f51971e46a6c90dc16ffd7a6ac4f6a583..2cdb8dbb1d25b5cc2afbe1d31cd295e05b3ae6b4 100644
--- a/src/providers/ipa/ipa_opts.h
+++ b/src/providers/ipa/ipa_opts.h
@@ -117,7 +117,8 @@ struct dp_option ipa_def_ldap_opts[] = {
 
 struct sdap_attr_map ipa_attr_map[] = {
     { "ldap_entry_usn", "entryUSN", SYSDB_USN, NULL },
-    { "ldap_rootdse_last_usn", "lastUSN", SYSDB_HIGH_USN, NULL }
+    { "ldap_rootdse_last_usn", "lastUSN", SYSDB_HIGH_USN, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map ipa_user_map[] = {
@@ -153,7 +154,8 @@ struct sdap_attr_map ipa_user_map[] = {
     { "ldap_user_nds_login_disabled", "loginDisabled", SYSDB_NDS_LOGIN_DISABLED, NULL },
     { "ldap_user_nds_login_expiration_time", "loginExpirationTime", SYSDB_NDS_LOGIN_EXPIRATION_TIME, NULL },
     { "ldap_user_nds_login_allowed_time_map", "loginAllowedTimeMap", SYSDB_NDS_LOGIN_ALLOWED_TIME_MAP, NULL },
-    { "ldap_user_ssh_public_key", "ipaSshPubKey", SYSDB_SSH_PUBKEY, NULL }
+    { "ldap_user_ssh_public_key", "ipaSshPubKey", SYSDB_SSH_PUBKEY, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map ipa_group_map[] = {
@@ -164,7 +166,8 @@ struct sdap_attr_map ipa_group_map[] = {
     { "ldap_group_member", "member", SYSDB_MEMBER, NULL },
     { "ldap_group_uuid", "nsUniqueId", SYSDB_UUID, NULL },
     { "ldap_group_modify_timestamp", "modifyTimestamp", SYSDB_ORIG_MODSTAMP, NULL },
-    { "ldap_group_entry_usn", NULL, SYSDB_USN, NULL }
+    { "ldap_group_entry_usn", NULL, SYSDB_USN, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map ipa_netgroup_map[] = {
@@ -177,6 +180,7 @@ struct sdap_attr_map ipa_netgroup_map[] = {
     { "ipa_netgroup_member_ext_host", "externalHost", SYSDB_ORIG_NETGROUP_EXTERNAL_HOST, NULL },
     { "ipa_netgroup_domain", "nisDomainName", SYSDB_NETGROUP_DOMAIN, NULL },
     { "ipa_netgroup_uuid", "ipaUniqueID", SYSDB_UUID, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map ipa_host_map[] = {
@@ -186,7 +190,8 @@ struct sdap_attr_map ipa_host_map[] = {
     { "ipa_host_serverhostname", "serverHostname", SYSDB_SERVERHOSTNAME, NULL },
     { "ipa_host_member_of", "memberOf", SYSDB_ORIG_MEMBEROF, NULL },
     { "ipa_host_ssh_public_key", "ipaSshPubKey", SYSDB_SSH_PUBKEY, NULL },
-    { "ipa_host_uuid", "ipaUniqueID", SYSDB_UUID, NULL}
+    { "ipa_host_uuid", "ipaUniqueID", SYSDB_UUID, NULL},
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map ipa_hostgroup_map[] = {
@@ -194,7 +199,8 @@ struct sdap_attr_map ipa_hostgroup_map[] = {
     { "ipa_hostgroup_name", "cn", SYSDB_NAME, NULL},
     { "ipa_hostgroup_member", "member", SYSDB_MEMBER, NULL},
     { "ipa_hostgroup_memberof", "memberOf", SYSDB_ORIG_MEMBEROF, NULL},
-    { "ipa_hostgroup_uuid", "ipaUniqueID", SYSDB_UUID, NULL}
+    { "ipa_hostgroup_uuid", "ipaUniqueID", SYSDB_UUID, NULL},
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map ipa_selinux_user_map[] = {
@@ -207,7 +213,8 @@ struct sdap_attr_map ipa_selinux_user_map[] = {
     { "ipa_selinux_usermap_enabled", "ipaEnabledFlag", SYSDB_SELINUX_ENABLED, NULL},
     { "ipa_selinux_usermap_user_category", "userCategory", SYSDB_USER_CATEGORY, NULL},
     { "ipa_selinux_usermap_host_category", "hostCategory", SYSDB_HOST_CATEGORY, NULL},
-    { "ipa_selinux_usermap_uuid", "ipaUniqueID", SYSDB_UUID, NULL}
+    { "ipa_selinux_usermap_uuid", "ipaUniqueID", SYSDB_UUID, NULL},
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct dp_option ipa_def_krb5_opts[] = {
@@ -234,18 +241,21 @@ struct sdap_attr_map ipa_service_map[] = {
     { "ldap_service_name", "cn", SYSDB_NAME, NULL },
     { "ldap_service_port", "ipServicePort", SYSDB_SVC_PORT, NULL },
     { "ldap_service_proto", "ipServiceProtocol", SYSDB_SVC_PROTO, NULL },
-    { "ldap_service_entry_usn", NULL, SYSDB_USN, NULL }
+    { "ldap_service_entry_usn", NULL, SYSDB_USN, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map ipa_autofs_mobject_map[] = {
     { "ldap_autofs_map_object_class", "automountMap", SYSDB_AUTOFS_MAP_OC, NULL },
-    { "ldap_autofs_map_name", "automountMapName", SYSDB_AUTOFS_MAP_NAME, 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_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 },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 #endif /* IPA_OPTS_H_ */
diff --git a/src/providers/ldap/ldap_opts.h b/src/providers/ldap/ldap_opts.h
index b10155346fe9f356b24ca900bf7356e2553df843..f1a7326ac977d9f3c099e5c30b7598801e97d189 100644
--- a/src/providers/ldap/ldap_opts.h
+++ b/src/providers/ldap/ldap_opts.h
@@ -100,17 +100,20 @@ struct dp_option default_basic_opts[] = {
 
 struct sdap_attr_map generic_attr_map[] = {
     { "ldap_entry_usn", NULL, SYSDB_USN, NULL },
-    { "ldap_rootdse_last_usn", NULL, SYSDB_HIGH_USN, NULL }
+    { "ldap_rootdse_last_usn", NULL, SYSDB_HIGH_USN, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map gen_ipa_attr_map[] = {
     { "ldap_entry_usn", SDAP_IPA_USN, SYSDB_USN, NULL },
-    { "ldap_rootdse_last_usn", SDAP_IPA_LAST_USN, SYSDB_HIGH_USN, NULL }
+    { "ldap_rootdse_last_usn", SDAP_IPA_LAST_USN, SYSDB_HIGH_USN, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map gen_ad_attr_map[] = {
     { "ldap_entry_usn", SDAP_AD_USN, SYSDB_USN, NULL },
-    { "ldap_rootdse_last_usn", SDAP_AD_LAST_USN, SYSDB_HIGH_USN, NULL }
+    { "ldap_rootdse_last_usn", SDAP_AD_LAST_USN, SYSDB_HIGH_USN, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map rfc2307_user_map[] = {
@@ -146,7 +149,8 @@ struct sdap_attr_map rfc2307_user_map[] = {
     { "ldap_user_nds_login_disabled", "loginDisabled", SYSDB_NDS_LOGIN_DISABLED, NULL },
     { "ldap_user_nds_login_expiration_time", "loginExpirationTime", SYSDB_NDS_LOGIN_EXPIRATION_TIME, NULL },
     { "ldap_user_nds_login_allowed_time_map", "loginAllowedTimeMap", SYSDB_NDS_LOGIN_ALLOWED_TIME_MAP, NULL },
-    { "ldap_user_ssh_public_key", NULL, SYSDB_SSH_PUBKEY, NULL }
+    { "ldap_user_ssh_public_key", NULL, SYSDB_SSH_PUBKEY, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map rfc2307_group_map[] = {
@@ -157,7 +161,8 @@ struct sdap_attr_map rfc2307_group_map[] = {
     { "ldap_group_member", "memberuid", SYSDB_MEMBER, NULL },
     { "ldap_group_uuid", NULL, SYSDB_UUID, NULL },
     { "ldap_group_modify_timestamp", "modifyTimestamp", SYSDB_ORIG_MODSTAMP, NULL },
-    { "ldap_group_entry_usn", NULL, SYSDB_USN, NULL }
+    { "ldap_group_entry_usn", NULL, SYSDB_USN, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map rfc2307bis_user_map[] = {
@@ -194,7 +199,8 @@ struct sdap_attr_map rfc2307bis_user_map[] = {
     { "ldap_user_nds_login_disabled", "loginDisabled", SYSDB_NDS_LOGIN_DISABLED, NULL },
     { "ldap_user_nds_login_expiration_time", "loginExpirationTime", SYSDB_NDS_LOGIN_EXPIRATION_TIME, NULL },
     { "ldap_user_nds_login_allowed_time_map", "loginAllowedTimeMap", SYSDB_NDS_LOGIN_ALLOWED_TIME_MAP, NULL },
-    { "ldap_user_ssh_public_key", NULL, SYSDB_SSH_PUBKEY, NULL }
+    { "ldap_user_ssh_public_key", NULL, SYSDB_SSH_PUBKEY, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map rfc2307bis_group_map[] = {
@@ -206,7 +212,8 @@ struct sdap_attr_map rfc2307bis_group_map[] = {
     /* FIXME: this is 389ds specific */
     { "ldap_group_uuid", "nsUniqueId", SYSDB_UUID, NULL },
     { "ldap_group_modify_timestamp", "modifyTimestamp", SYSDB_ORIG_MODSTAMP, NULL },
-    { "ldap_group_entry_usn", NULL, SYSDB_USN, NULL }
+    { "ldap_group_entry_usn", NULL, SYSDB_USN, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map ad2008r2_user_map[] = {
@@ -242,7 +249,8 @@ struct sdap_attr_map ad2008r2_user_map[] = {
     { "ldap_user_nds_login_disabled", NULL, SYSDB_NDS_LOGIN_DISABLED, NULL },
     { "ldap_user_nds_login_expiration_time", NULL, SYSDB_NDS_LOGIN_EXPIRATION_TIME, NULL },
     { "ldap_user_nds_login_allowed_time_map", NULL, SYSDB_NDS_LOGIN_ALLOWED_TIME_MAP, NULL },
-    { "ldap_user_ssh_public_key", NULL, SYSDB_SSH_PUBKEY, NULL }
+    { "ldap_user_ssh_public_key", NULL, SYSDB_SSH_PUBKEY, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map ad2008r2_group_map[] = {
@@ -253,7 +261,8 @@ struct sdap_attr_map ad2008r2_group_map[] = {
     { "ldap_group_member", "member", SYSDB_MEMBER, NULL },
     { "ldap_group_uuid", "objectGUID", SYSDB_UUID, NULL },
     { "ldap_group_modify_timestamp", "whenChanged", SYSDB_ORIG_MODSTAMP, NULL },
-    { "ldap_group_entry_usn", SDAP_AD_USN, SYSDB_USN, NULL }
+    { "ldap_group_entry_usn", SDAP_AD_USN, SYSDB_USN, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map netgroup_map[] = {
@@ -263,7 +272,8 @@ struct sdap_attr_map netgroup_map[] = {
     { "ldap_netgroup_triple", "nisNetgroupTriple", SYSDB_NETGROUP_TRIPLE, NULL },
     /* FIXME: this is 389ds specific */
     { "ldap_netgroup_uuid", "nsUniqueId", SYSDB_UUID, NULL },
-    { "ldap_netgroup_modify_timestamp", "modifyTimestamp", SYSDB_ORIG_MODSTAMP, NULL }
+    { "ldap_netgroup_modify_timestamp", "modifyTimestamp", SYSDB_ORIG_MODSTAMP, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map native_sudorule_map[] = {
@@ -277,7 +287,8 @@ struct sdap_attr_map native_sudorule_map[] = {
     { "ldap_sudorule_runasgroup", "sudoRunAsGroup", SYSDB_SUDO_CACHE_AT_RUNASGROUP, NULL },
     { "ldap_sudorule_notbefore", "sudoNotBefore", SYSDB_SUDO_CACHE_AT_NOTBEFORE, NULL },
     { "ldap_sudorule_notafter", "sudoNotAfter", SYSDB_SUDO_CACHE_AT_NOTAFTER, NULL },
-    { "ldap_sudorule_order", "sudoOrder", SYSDB_SUDO_CACHE_AT_ORDER, NULL }
+    { "ldap_sudorule_order", "sudoOrder", SYSDB_SUDO_CACHE_AT_ORDER, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map service_map[] = {
@@ -285,29 +296,34 @@ struct sdap_attr_map service_map[] = {
     { "ldap_service_name", "cn", SYSDB_NAME, NULL },
     { "ldap_service_port", "ipServicePort", SYSDB_SVC_PORT, NULL },
     { "ldap_service_proto", "ipServiceProtocol", SYSDB_SVC_PROTO, NULL },
-    { "ldap_service_entry_usn", NULL, SYSDB_USN, NULL }
+    { "ldap_service_entry_usn", NULL, SYSDB_USN, NULL },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map rfc2307_autofs_mobject_map[] = {
     { "ldap_autofs_map_object_class", "automountMap", SYSDB_AUTOFS_MAP_OC, NULL },
-    { "ldap_autofs_map_name", "ou", SYSDB_AUTOFS_MAP_NAME, 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_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 },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 struct sdap_attr_map rfc2307bis_autofs_mobject_map[] = {
     { "ldap_autofs_map_object_class", "automountMap", SYSDB_AUTOFS_MAP_OC, NULL },
-    { "ldap_autofs_map_name", "automountMapName", SYSDB_AUTOFS_MAP_NAME, 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_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 },
+    SDAP_ATTR_MAP_TERMINATOR
 };
 
 #endif /* LDAP_OPTS_H_ */
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
index 941c27918c015b3005f5ff05db02264c871244ff..18ec37bbe8a8e7c581bda642bdc82a0e03813c80 100644
--- a/src/providers/ldap/sdap.h
+++ b/src/providers/ldap/sdap.h
@@ -335,6 +335,7 @@ struct sdap_attr_map {
     const char *sys_name;
     char *name;
 };
+#define SDAP_ATTR_MAP_TERMINATOR { NULL, NULL, NULL, NULL }
 
 struct sdap_search_base {
     const char *basedn;
-- 
1.7.7.6

