mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
Issue #14: Improved support for static Finit builds
- Upgrade libite (LITE) for new UNIX file parser API to improve static builds of Finit. - Re-enable bootmisc plugin for static builds by adding built-in support for reading GID from /etc/group. - Allow inetd support for static builds by adding built-in support for reading service and protocol from /etc/services and /etc/protocols. - Do not try to install/uninstall any plugins for static builds. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
b2c5e97417
commit
369fcf2100
6 files changed
+46
-9
No files matched your search
@@ -174,27 +174,33 @@ int print_result(int fail)
|
||||
return fail;
|
||||
}
|
||||
|
||||
#ifndef ENABLE_STATIC
|
||||
int getuser(char *username)
|
||||
{
|
||||
#ifdef ENABLE_STATIC
|
||||
return fgetint("/etc/passwd", "x:\n", username);
|
||||
#else
|
||||
struct passwd *usr;
|
||||
|
||||
if (!username || (usr = getpwnam(username)) == NULL)
|
||||
return -1;
|
||||
|
||||
return usr->pw_uid;
|
||||
#endif
|
||||
}
|
||||
|
||||
int getgroup(char *group)
|
||||
{
|
||||
#ifdef ENABLE_STATIC
|
||||
return fgetint("/etc/group", "x:\n", group);
|
||||
#else
|
||||
struct group *grp;
|
||||
|
||||
if ((grp = getgrnam(group)) == NULL)
|
||||
return -1;
|
||||
|
||||
return grp->gr_gid;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Signal safe sleep ... we get a lot of SIGCHLD at reboot */
|
||||
void do_sleep(unsigned int sec)
|
||||
|
||||
@@ -217,7 +217,22 @@ void inetd_stop(inetd_t *inetd)
|
||||
|
||||
static int getent(char *service, char *proto, struct servent **sv, struct protoent **pv)
|
||||
{
|
||||
#ifdef ENABLE_STATIC
|
||||
int service_num;
|
||||
static struct servent lfs;
|
||||
|
||||
service_num = fgetint("/etc/services", " \n\t", service);
|
||||
if (service_num > 0) {
|
||||
lfs.s_name = service;
|
||||
lfs.s_port = htons(service_num);
|
||||
lfs.s_proto = NULL;
|
||||
if (!strcmp("tcp", proto) || !strcmp("udp", proto))
|
||||
lfs.s_proto = proto;
|
||||
*sv = &lfs;
|
||||
}
|
||||
#else
|
||||
*sv = getservbyname(service, proto);
|
||||
#endif
|
||||
if (!*sv) {
|
||||
const char *errstr;
|
||||
static struct servent s;
|
||||
@@ -238,8 +253,20 @@ static int getent(char *service, char *proto, struct servent **sv, struct protoe
|
||||
*sv = &s;
|
||||
}
|
||||
|
||||
if (pv) {
|
||||
if (pv && (*sv)->s_proto) {
|
||||
#ifdef ENABLE_STATIC
|
||||
int proto_num;
|
||||
static struct protoent lfp;
|
||||
|
||||
proto_num = fgetint("/etc/protocols", " \n\t", (*sv)->s_proto);
|
||||
if (proto_num > 0) {
|
||||
lfp.p_name = proto;
|
||||
lfp.p_proto = proto_num;
|
||||
}
|
||||
*pv = &lfp;
|
||||
#else
|
||||
*pv = getprotobyname((*sv)->s_proto);
|
||||
#endif
|
||||
if (!*pv) {
|
||||
_e("Cannot find proto %s, skipping.", (*sv)->s_proto);
|
||||
return errno = EINVAL;
|
||||
|
||||
+1
-1
Submodule libite updated: db08b20f23...23badc990d.
@@ -317,6 +317,8 @@ int plugin_load_all(uev_ctx_t *ctx, char *path)
|
||||
closedir(dp);
|
||||
#else
|
||||
_d("Finit built statically, not loading plugins from %s ...", path);
|
||||
if (verbose)
|
||||
print_desc("Initializing plugins", NULL);
|
||||
#endif /* ENABLE_STATIC */
|
||||
|
||||
/* Always initialize plugins */
|
||||
|
||||
@@ -27,6 +27,7 @@ clean:
|
||||
distclean:
|
||||
-@$(RM) *.o *.so $(JUNK) $(DEPS)
|
||||
|
||||
ifneq ($(STATIC), 1)
|
||||
install: all
|
||||
@install -d $(DESTDIR)$(plugindir)
|
||||
@for plugin in $(PLUGINS); do \
|
||||
@@ -40,6 +41,12 @@ uninstall:
|
||||
rm $(DESTDIR)$(plugindir)/$$plugin 2>/dev/null; \
|
||||
done
|
||||
-@rmdir $(DESTDIR)$(plugindir) 2>/dev/null
|
||||
else
|
||||
install:
|
||||
@true
|
||||
uninstall:
|
||||
@true
|
||||
endif
|
||||
|
||||
ifneq ($(MAKECMDGOALS),distclean)
|
||||
-include $(DEPS)
|
||||
|
||||
@@ -29,9 +29,6 @@
|
||||
#include "../plugin.h"
|
||||
#include "libite/lite.h"
|
||||
|
||||
/* This plugin uses getuser(), which relies on dynamically linked GLIBC. Cannot be built statically! */
|
||||
#ifndef ENABLE_STATIC
|
||||
|
||||
/*
|
||||
* Setup standard FHS 2.3 structure in /var, and
|
||||
* write runlevel to UTMP, needed by, e.g., printerdrake.
|
||||
@@ -104,8 +101,6 @@ PLUGIN_EXIT(plugin_exit)
|
||||
plugin_unregister(&plugin);
|
||||
}
|
||||
|
||||
#endif/* ENABLE_STATIC */
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* version-control: t
|
||||
|
||||
Reference in new issue
Block a user