diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2010-11-24 20:27:02 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2010-11-24 20:27:02 +0200 |
commit | 50d4a80f67e5bcbf3902138d85a25f6a90847d31 (patch) | |
tree | 18ebd4f82b1b5732977926b9bac4634bfb002759 /ext.c | |
parent | b9c0946c39a677f733d42a26d2de3f44131bbdd8 (diff) | |
download | egawk-50d4a80f67e5bcbf3902138d85a25f6a90847d31.tar.gz egawk-50d4a80f67e5bcbf3902138d85a25f6a90847d31.tar.bz2 egawk-50d4a80f67e5bcbf3902138d85a25f6a90847d31.zip |
Add check for plugin license, make close on exec POSIX compatibile.
Diffstat (limited to 'ext.c')
-rw-r--r-- | ext.c | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -48,6 +48,8 @@ do_ext(int nargs) NODE *(*func)(NODE *, void *); void *dl; int flags = RTLD_LAZY; + int fatal_error = FALSE; + int *gpl_compat; #if 0 static short warned = FALSE; #endif @@ -82,24 +84,36 @@ do_ext(int nargs) /* fatal needs `obj', and we need to deallocate it! */ msg(_("fatal: extension: cannot open `%s' (%s)\n"), obj->stptr, dlerror()); -ferror: - DEREF(obj); - DEREF(fun); - gawk_exit(EXIT_FATAL); + fatal_error = TRUE; + goto done; + } + + /* Per the GNU Coding standards */ + gpl_compat = (int *) dlsym(dl, "plugin_is_GPL_compatible"); + if (gpl_compat == NULL) { + msg(_("fatal: extension: library `%s': does not define `plugin_is_GPL_compatible' (%s)\n"), + obj->stptr, dlerror()); + fatal_error = TRUE; + goto done; } + func = (NODE *(*)(NODE *, void *)) dlsym(dl, fun->stptr); if (func == NULL) { msg(_("fatal: extension: library `%s': cannot call function `%s' (%s)\n"), obj->stptr, fun->stptr, dlerror()); - goto ferror; + fatal_error = TRUE; + goto done; } tmp = (*func)(obj, dl); if (tmp == NULL) tmp = Nnull_string; +done: DEREF(obj); DEREF(fun); + if (fatal_error) + gawk_exit(EXIT_FATAL); return tmp; } |