mirror of
https://github.com/troglobit/finit.git
synced 2026-10-19 11:09:35 +00:00
Initial support for building Finit statically (incomplete)
This patch adresses issue #5. However, there still remains a few issues to work around before Finit can be built completely standalone. $ make clean all STATIC=1 LINK finit helpers.o: In function `getgroup': helpers.c:(.text+0x10a7): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking helpers.o: In function `getuser': helpers.c:(.text+0x108e): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking inetd.o: In function `getent': inetd.c:(.text+0x127): warning: Using 'getprotobyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking inetd.c:(.text+0xce): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking The problem is the NSS plugins and similar issues that prevent static linking when using the above functions. See issue #5 for more on this. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
52664791f5
commit
a74b640507
5 files changed
+68
-19
No files matched your search
@@ -39,7 +39,9 @@
|
||||
static char *plugpath = NULL; /* Set by first load. */
|
||||
static TAILQ_HEAD(plugin_head, plugin) plugins = TAILQ_HEAD_INITIALIZER(plugins);
|
||||
|
||||
#ifndef PLUGINS_STATIC
|
||||
static void check_plugin_depends(plugin_t *plugin);
|
||||
#endif
|
||||
|
||||
int plugin_register(plugin_t *plugin)
|
||||
{
|
||||
@@ -50,12 +52,16 @@ int plugin_register(plugin_t *plugin)
|
||||
|
||||
/* Setup default name if none is provided */
|
||||
if (!plugin->name) {
|
||||
#ifndef PLUGINS_STATIC
|
||||
Dl_info info;
|
||||
|
||||
if (!dladdr(plugin, &info) || !info.dli_fname)
|
||||
plugin->name = "unknown";
|
||||
else
|
||||
plugin->name = (char *)info.dli_fname;
|
||||
#else
|
||||
plugin->name = "unknown";
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Already registered? */
|
||||
@@ -64,8 +70,10 @@ int plugin_register(plugin_t *plugin)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef PLUGINS_STATIC
|
||||
/* Resolve plugin dependencies */
|
||||
check_plugin_depends(plugin);
|
||||
#endif
|
||||
|
||||
TAILQ_INSERT_TAIL(&plugins, plugin, link);
|
||||
|
||||
@@ -75,6 +83,7 @@ int plugin_register(plugin_t *plugin)
|
||||
/* Not called, at the moment plugins cannot be unloaded. */
|
||||
int plugin_unregister(plugin_t *plugin)
|
||||
{
|
||||
#ifndef PLUGINS_STATIC
|
||||
TAILQ_REMOVE(&plugins, plugin, link);
|
||||
|
||||
if (plugin->svc.cb) {
|
||||
@@ -92,6 +101,9 @@ int plugin_unregister(plugin_t *plugin)
|
||||
_e("Failed unloading %s ...", plugin->name);
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
_d("Finit built statically, cannot unload %s ...", plugin->name);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -191,7 +203,7 @@ static void init_plugins(uev_ctx_t *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef PLUGINS_STATIC
|
||||
/**
|
||||
* load_one - Load one plugin
|
||||
* @path: Path to finit plugins, usually %PLUGIN_PATH
|
||||
@@ -270,10 +282,12 @@ static void check_plugin_depends(plugin_t *plugin)
|
||||
load_one(plugpath, plugin->depends[i]);
|
||||
}
|
||||
}
|
||||
#endif /* PLUGINS_STATIC */
|
||||
|
||||
int plugin_load_all(uev_ctx_t *ctx, char *path)
|
||||
{
|
||||
int fail = 0;
|
||||
#ifndef PLUGINS_STATIC
|
||||
DIR *dp = opendir(path);
|
||||
struct dirent *entry;
|
||||
|
||||
@@ -295,6 +309,11 @@ int plugin_load_all(uev_ctx_t *ctx, char *path)
|
||||
}
|
||||
|
||||
closedir(dp);
|
||||
#else
|
||||
_d("Finit built statically, not loading plugins from %s ...", path);
|
||||
#endif /* PLUGINS_STATIC */
|
||||
|
||||
/* Always initialize plugins */
|
||||
init_plugins(ctx);
|
||||
|
||||
return fail;
|
||||
|
||||
Reference in new issue
Block a user