From: Greg Hudson Date: Sun, 13 Nov 2011 00:38:23 +0000 (+0000) Subject: Add consistency check for plugin interface names X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9b21c05fec7cc9e06c7c8d00dd750ee8a32cfe44;p=krb5.git Add consistency check for plugin interface names Add an assertion to ensure that the interface_names table in plugin.c is updated when a new pluggable interface is added. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25471 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/include/k5-int.h b/src/include/k5-int.h index b82fe5b6f..21519b096 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -1382,7 +1382,8 @@ struct plugin_interface { }; /* A list of plugin interface IDs. Make sure to increment - * PLUGIN_NUM_INTERFACES when a new interface is added. */ + * PLUGIN_NUM_INTERFACES when a new interface is added, and add an entry to the + * interface_names table in lib/krb5/krb/plugin.c. */ #define PLUGIN_INTERFACE_PWQUAL 0 #define PLUGIN_INTERFACE_KADM5_HOOK 1 #define PLUGIN_INTERFACE_CLPREAUTH 2 diff --git a/src/lib/krb5/krb/plugin.c b/src/lib/krb5/krb/plugin.c index 575b8efa7..9b2328ba2 100644 --- a/src/lib/krb5/krb/plugin.c +++ b/src/lib/krb5/krb/plugin.c @@ -26,7 +26,7 @@ #include "k5-int.h" -const char *interface_names[PLUGIN_NUM_INTERFACES] = { +const char *interface_names[] = { "pwqual", "kadm5_hook", "clpreauth", @@ -250,6 +250,10 @@ configure_interface(krb5_context context, int id) if (interface->configured) return 0; + /* Detect consistency errors when plugin interfaces are added. */ + assert(sizeof(interface_names) / sizeof(*interface_names) == + PLUGIN_NUM_INTERFACES); + /* Read the configuration variables for this interface. */ path[0] = KRB5_CONF_PLUGINS; path[1] = iname;