From cee0491feb7de68b3a38cc4d6c5149a8f44378f8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2014 15:25:43 +0100 Subject: wip --- src/include/osconf.hin | 1 + src/lib/gssapi/mechglue/g_initialize.c | 70 ++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/src/include/osconf.hin b/src/include/osconf.hin index 62aceeaa46..ba900df87a 100644 --- a/src/include/osconf.hin +++ b/src/include/osconf.hin @@ -129,6 +129,7 @@ * GSS mechglue */ #define MECH_CONF "@SYSCONFDIR/gss/mech" +#define MECH_CONF_DIR "@SYSCONFDIR/gss/mech.d" #define MECH_LIB_PREFIX "@GSSMODULEDIR/" #endif /* KRB5_OSCONF__ */ diff --git a/src/lib/gssapi/mechglue/g_initialize.c b/src/lib/gssapi/mechglue/g_initialize.c index 48a825e3bb..4004a8e6ad 100644 --- a/src/lib/gssapi/mechglue/g_initialize.c +++ b/src/lib/gssapi/mechglue/g_initialize.c @@ -41,6 +41,7 @@ #include #include #include +#include #define M_DEFAULT "default" @@ -59,6 +60,10 @@ #define MECH_CONF "/etc/gss/mech" #endif +#ifndef MECH_CONF_DIR +#define MECH_CONF_DIR "/etc/gss/mech.d" +#endif + /* Local functions */ static void addConfigEntry(const char *oidStr, const char *oid, const char *sharedLib, const char *kernMod, @@ -90,6 +95,7 @@ static gss_mech_info g_mechList = NULL; static gss_mech_info g_mechListTail = NULL; static k5_mutex_t g_mechListLock = K5_MUTEX_PARTIAL_INITIALIZER; static time_t g_confFileModTime = (time_t)0; +static time_t g_confDirectoryModTime = (time_t)0; static time_t g_mechSetTime = (time_t)0; static gss_OID_set_desc g_mechSet = { 0, NULL }; @@ -410,6 +416,70 @@ const gss_OID oid; return (modOptions); } /* gssint_get_modOptions */ +static int +loadConfigFiles(char *directoryName) +{ + glob_t globbuf; + char *pattern = NULL; + int ret; + size_t i; + time_t highest_mtime = 0; + + ret = asprintf(&pattern, "%s/*.conf", directoryName); + if (ret == -1 || pattern == NULL) + return ENOMEM; + + ret = glob(pattern, GLOB_ERR, NULL, &globbuf); + free(pattern); + + if (ret != 0) + return ENOENT; + + for (i = 0; i < globbuf.gl_pathc; i++) { + + struct stat fileInfo; + + if (stat(globbuf.gl_pathv[i], &fileInfo) != 0) + continue; + + if (g_confDirectoryModTime < fileInfo.st_mtime) + g_confDirectoryModTime = fileInfo.st_mtime; + + loadConfigFile(globbuf.gl_pathv[i]); + } + + globfree(&globbuf); + + return 0; +} + +static void +checkConfigFile(char *fileName) +{ + struct stat fileInfo; + + /* check if mechList needs updating */ + if (stat(fileName, &fileInfo) != 0 || + g_confFileModTime >= fileInfo.st_mtime) + return; + g_confFileModTime = fileInfo.st_mtime; + loadConfigFile(fileName); +} + +static void +checkConfigDirectory(char *directoryName) +{ + struct stat fileInfo; + + /* check if mechList needs updating */ + if (stat(directoryName, &fileInfo) != 0 || + fileInfo.st_mode != S_IFDIR) + return; + /* now glob to check for the highest mtime */ +} + + + /* * determines if the mechList needs to be updated from file * and performs the update. -- cgit