]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Update internal plugin interface to add an errinfo structure to "open"
authorKen Raeburn <raeburn@mit.edu>
Tue, 25 Apr 2006 06:27:07 +0000 (06:27 +0000)
committerKen Raeburn <raeburn@mit.edu>
Tue, 25 Apr 2006 06:27:07 +0000 (06:27 +0000)
and "get" routines, so that more detailed error information (e.g.,
from dlerror()) may be returned to the caller.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17960 dc483132-0cff-0310-8789-dd5450dbe970

src/include/k5-plugin.h
src/lib/krb5/os/locate_kdc.c
src/util/support/plugins.c

index 0e3daa4f523bb3714f123e1b2f4775fc0e655767..c7fb1776ca32f2cb841687cf90c400a9a54dbace 100644 (file)
@@ -60,6 +60,8 @@
 # include <inttypes.h>
 #endif
 
+#include "k5-err.h"
+
 struct plugin_file_handle;     /* opaque */
 
 struct plugin_dir_handle {
@@ -69,24 +71,30 @@ struct plugin_dir_handle {
 #define PLUGIN_DIR_INIT(P) ((P)->files = NULL)
 #define PLUGIN_DIR_OPEN(P) ((P)->files != NULL)
 
-int32_t KRB5_CALLCONV
-krb5int_open_plugin (const char *, struct plugin_file_handle **);
+long KRB5_CALLCONV
+krb5int_open_plugin (const char *, struct plugin_file_handle **,
+                    struct errinfo *);
 
-int32_t KRB5_CALLCONV
-krb5int_get_plugin_data (struct plugin_file_handle *, const char *, void **);
+long KRB5_CALLCONV
+krb5int_get_plugin_data (struct plugin_file_handle *, const char *, void **,
+                        struct errinfo *);
 
-int32_t KRB5_CALLCONV
+long KRB5_CALLCONV
 krb5int_get_plugin_func (struct plugin_file_handle *, const char *,
-                        void (**)());
+                        void (**)(), struct errinfo *);
 
 void KRB5_CALLCONV
 krb5int_close_plugin (struct plugin_file_handle *);
 
-int32_t KRB5_CALLCONV krb5int_open_plugin_dir (const char *, struct plugin_dir_handle *);
+long KRB5_CALLCONV krb5int_open_plugin_dir (const char *,
+                                           struct plugin_dir_handle *,
+                                           struct errinfo *);
 void KRB5_CALLCONV krb5int_close_plugin_dir (struct plugin_dir_handle *);
 void KRB5_CALLCONV krb5int_free_plugin_dir_data (void **);
-int32_t KRB5_CALLCONV krb5int_get_plugin_dir_data (struct plugin_dir_handle *,
-                                                  const char *, void ***);
+long KRB5_CALLCONV krb5int_get_plugin_dir_data (struct plugin_dir_handle *,
+                                               const char *, void ***,
+                                               struct errinfo *);
 void KRB5_CALLCONV krb5int_free_plugin_dir_func (void (**)(void));
-int32_t KRB5_CALLCONV krb5int_get_plugin_dir_func (struct plugin_dir_handle *,
-                                                  const char *, void (***)(void));
+long KRB5_CALLCONV krb5int_get_plugin_dir_func (struct plugin_dir_handle *,
+                                               const char *, void (***)(void),
+                                               struct errinfo *);
index 47ac0eebe779ea67754910ceef1dabfeb1678808..83b0066340d8ff328cf4ea0ebf7f235bac96e963 100644 (file)
@@ -612,14 +612,17 @@ module_locate_server (krb5_context ctx, const krb5_data *realm,
     Tprintf("in module_locate_server\n");
     cbdata.lp = addrlist;
     if (!PLUGIN_DIR_OPEN (&ctx->libkrb5_plugins)) {
-       code = krb5int_open_plugin_dir (objdir, &ctx->libkrb5_plugins);
+       code = krb5int_open_plugin_dir (objdir, &ctx->libkrb5_plugins,
+                                       &ctx->err);
        if (code)
            return KRB5_PLUGIN_NO_HANDLE;
     }
 
-    code = krb5int_get_plugin_dir_data (&ctx->libkrb5_plugins, "service_locator", &ptrs);
+    code = krb5int_get_plugin_dir_data (&ctx->libkrb5_plugins,
+                                       "service_locator", &ptrs, &ctx->err);
     if (code) {
-       Tprintf("error looking up plugin symbols: %s\n", error_message(code));
+       Tprintf("error looking up plugin symbols: %s\n",
+               krb5_get_error_message(ctx, code));
        return KRB5_PLUGIN_NO_HANDLE;
     }
 
index 76e33ae3c14e90c3affd4fd06bd14c9d1f86e213..d134da4bbb15458303205bfb40c2762104981ad2 100644 (file)
@@ -72,21 +72,22 @@ struct plugin_file_handle {
 #endif
 };
 
-int32_t KRB5_CALLCONV
-krb5int_open_plugin (const char *filename, struct plugin_file_handle **h)
+long KRB5_CALLCONV
+krb5int_open_plugin (const char *filename, struct plugin_file_handle **h,
+                    struct errinfo *ep)
 {
-    int32_t err = 0;
+    long err = 0;
     struct stat statbuf;
     struct plugin_file_handle *htmp = NULL;
     int got_plugin = 0;
-    
+
     if (!err) {
         if (stat (filename, &statbuf) < 0) {
             Tprintf ("stat(%s): %s\n", filename, strerror (errno));
             err = errno;
         }
     }
-    
+
     if (!err) {
         htmp = calloc (1, sizeof (*htmp)); /* calloc initializes ptrs to NULL */
         if (htmp == NULL) { err = errno; }
@@ -95,16 +96,17 @@ krb5int_open_plugin (const char *filename, struct plugin_file_handle **h)
 #if USE_DLOPEN
     if (!err && (statbuf.st_mode & S_IFMT) == S_IFREG) {
         void *handle = NULL;
-        
+
         if (!err) {
             handle = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
             if (handle == NULL) {
-                const char *e = dlerror(); /* XXX copy and save away */
+                const char *e = dlerror();
                 Tprintf ("dlopen(%s): %s\n", filename, e);
                 err = ENOENT; /* XXX */
+               krb5int_set_error (ep, err, "%s", e);
             }
         }
-        
+
         if (!err) {
             got_plugin = 1;
             htmp->dlhandle = handle;
@@ -114,13 +116,13 @@ krb5int_open_plugin (const char *filename, struct plugin_file_handle **h)
         if (handle != NULL) { dlclose (handle); }
     }
 #endif
-    
+
 #if USE_CFBUNDLE
     if (!err && (statbuf.st_mode & S_IFMT) == S_IFDIR) {
         CFStringRef pluginPath = NULL;
         CFURLRef pluginURL = NULL;
         CFBundleRef pluginBundle = NULL;
-        
+
         if (!err) {
             pluginPath = CFStringCreateWithCString (kCFAllocatorDefault, filename, 
                                                     kCFStringEncodingASCII);
@@ -171,11 +173,12 @@ krb5int_open_plugin (const char *filename, struct plugin_file_handle **h)
     return err;
 }
 
-static int32_t
+static long
 krb5int_get_plugin_sym (struct plugin_file_handle *h, 
-                        const char *csymname, int isfunc, void **ptr)
+                        const char *csymname, int isfunc, void **ptr,
+                       struct errinfo *ep)
 {
-    int32_t err = 0;
+    long err = 0;
     void *sym = NULL;
     
 #if USE_DLOPEN
@@ -187,6 +190,7 @@ krb5int_get_plugin_sym (struct plugin_file_handle *h,
             const char *e = dlerror (); /* XXX copy and save away */
             Tprintf ("dlsym(%s): %s\n", csymname, e);
             err = ENOENT; /* XXX */
+           krb5int_set_error(ep, err, "%s", e);
         }
     }
 #endif
@@ -225,19 +229,19 @@ krb5int_get_plugin_sym (struct plugin_file_handle *h,
     return err;
 }
 
-int32_t KRB5_CALLCONV
+long KRB5_CALLCONV
 krb5int_get_plugin_data (struct plugin_file_handle *h, const char *csymname,
-                        void **ptr)
+                        void **ptr, struct errinfo *ep)
 {
-    return krb5int_get_plugin_sym (h, csymname, 0, ptr);
+    return krb5int_get_plugin_sym (h, csymname, 0, ptr, ep);
 }
 
-int32_t KRB5_CALLCONV
+long KRB5_CALLCONV
 krb5int_get_plugin_func (struct plugin_file_handle *h, const char *csymname,
-                        void (**ptr)())
+                        void (**ptr)(), struct errinfo *ep)
 {
     void *dptr = NULL;    
-    int32_t err = krb5int_get_plugin_sym (h, csymname, 1, &dptr);
+    long err = krb5int_get_plugin_sym (h, csymname, 1, &dptr, ep);
     if (!err) {
         /* Cast function pointers to avoid code duplication */
         *ptr = (void (*)()) dptr;
@@ -283,16 +287,16 @@ krb5int_close_plugin (struct plugin_file_handle *h)
     (strerror (ERR))
 #endif
 
-int32_t KRB5_CALLCONV
+long KRB5_CALLCONV
 krb5int_open_plugin_dir (const char *dirname,
-                        struct plugin_dir_handle *dirhandle)
+                        struct plugin_dir_handle *dirhandle,
+                        struct errinfo *ep)
 {
-    int32_t err = 0;
+    long err = 0;
     DIR *dir = NULL;
     struct dirent *d = NULL;
     struct plugin_file_handle **h = NULL;
     int count = 0;
-    char errbuf[1024];
 
     if (!err) {
         h = calloc (1, sizeof (*h)); /* calloc initializes to NULL */
@@ -331,7 +335,7 @@ krb5int_open_plugin_dir (const char *dirname,
         }
         
         if (!err) {            
-            if (krb5int_open_plugin (path, &handle) == 0) {
+            if (krb5int_open_plugin (path, &handle, ep) == 0) {
                 struct plugin_file_handle **newh = NULL;
 
                 count++;
@@ -392,12 +396,13 @@ krb5int_free_plugin_dir_data (void **ptrs)
     free(ptrs);
 }
 
-int32_t KRB5_CALLCONV
+long KRB5_CALLCONV
 krb5int_get_plugin_dir_data (struct plugin_dir_handle *dirhandle,
                             const char *symname,
-                            void ***ptrs)
+                            void ***ptrs,
+                            struct errinfo *ep)
 {
-    int32_t err = 0;
+    long err = 0;
     void **p = NULL;
     int count = 0;
 
@@ -417,7 +422,7 @@ krb5int_get_plugin_dir_data (struct plugin_dir_handle *dirhandle,
         for (i = 0; !err && (dirhandle->files[i] != NULL); i++) {
             void *sym = NULL;
 
-            if (krb5int_get_plugin_data (dirhandle->files[i], symname, &sym) == 0) {
+            if (krb5int_get_plugin_data (dirhandle->files[i], symname, &sym, ep) == 0) {
                 void **newp = NULL;
 
                 count++;
@@ -450,12 +455,13 @@ krb5int_free_plugin_dir_func (void (**ptrs)(void))
     free(ptrs);
 }
 
-int32_t KRB5_CALLCONV
+long KRB5_CALLCONV
 krb5int_get_plugin_dir_func (struct plugin_dir_handle *dirhandle,
                             const char *symname,
-                            void (***ptrs)(void))
+                            void (***ptrs)(void),
+                            struct errinfo *ep)
 {
-    int32_t err = 0;
+    long err = 0;
     void (**p)() = NULL;
     int count = 0;
     
@@ -475,7 +481,7 @@ krb5int_get_plugin_dir_func (struct plugin_dir_handle *dirhandle,
         for (i = 0; !err && (dirhandle->files[i] != NULL); i++) {
             void (*sym)() = NULL;
             
-            if (krb5int_get_plugin_func (dirhandle->files[i], symname, &sym) == 0) {
+            if (krb5int_get_plugin_func (dirhandle->files[i], symname, &sym, ep) == 0) {
                 void (**newp)() = NULL;
 
                 count++;