mirror of
https://github.com/troglobit/finit.git
synced 2026-10-19 11:09:35 +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;
|
return fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ENABLE_STATIC
|
|
||||||
int getuser(char *username)
|
int getuser(char *username)
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_STATIC
|
||||||
|
return fgetint("/etc/passwd", "x:\n", username);
|
||||||
|
#else
|
||||||
struct passwd *usr;
|
struct passwd *usr;
|
||||||
|
|
||||||
if (!username || (usr = getpwnam(username)) == NULL)
|
if (!username || (usr = getpwnam(username)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return usr->pw_uid;
|
return usr->pw_uid;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int getgroup(char *group)
|
int getgroup(char *group)
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_STATIC
|
||||||
|
return fgetint("/etc/group", "x:\n", group);
|
||||||
|
#else
|
||||||
struct group *grp;
|
struct group *grp;
|
||||||
|
|
||||||
if ((grp = getgrnam(group)) == NULL)
|
if ((grp = getgrnam(group)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return grp->gr_gid;
|
return grp->gr_gid;
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* Signal safe sleep ... we get a lot of SIGCHLD at reboot */
|
/* Signal safe sleep ... we get a lot of SIGCHLD at reboot */
|
||||||
void do_sleep(unsigned int sec)
|
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)
|
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);
|
*sv = getservbyname(service, proto);
|
||||||
|
#endif
|
||||||
if (!*sv) {
|
if (!*sv) {
|
||||||
const char *errstr;
|
const char *errstr;
|
||||||
static struct servent s;
|
static struct servent s;
|
||||||
@@ -238,8 +253,20 @@ static int getent(char *service, char *proto, struct servent **sv, struct protoe
|
|||||||
*sv = &s;
|
*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);
|
*pv = getprotobyname((*sv)->s_proto);
|
||||||
|
#endif
|
||||||
if (!*pv) {
|
if (!*pv) {
|
||||||
_e("Cannot find proto %s, skipping.", (*sv)->s_proto);
|
_e("Cannot find proto %s, skipping.", (*sv)->s_proto);
|
||||||
return errno = EINVAL;
|
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);
|
closedir(dp);
|
||||||
#else
|
#else
|
||||||
_d("Finit built statically, not loading plugins from %s ...", path);
|
_d("Finit built statically, not loading plugins from %s ...", path);
|
||||||
|
if (verbose)
|
||||||
|
print_desc("Initializing plugins", NULL);
|
||||||
#endif /* ENABLE_STATIC */
|
#endif /* ENABLE_STATIC */
|
||||||
|
|
||||||
/* Always initialize plugins */
|
/* Always initialize plugins */
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ clean:
|
|||||||
distclean:
|
distclean:
|
||||||
-@$(RM) *.o *.so $(JUNK) $(DEPS)
|
-@$(RM) *.o *.so $(JUNK) $(DEPS)
|
||||||
|
|
||||||
|
ifneq ($(STATIC), 1)
|
||||||
install: all
|
install: all
|
||||||
@install -d $(DESTDIR)$(plugindir)
|
@install -d $(DESTDIR)$(plugindir)
|
||||||
@for plugin in $(PLUGINS); do \
|
@for plugin in $(PLUGINS); do \
|
||||||
@@ -40,6 +41,12 @@ uninstall:
|
|||||||
rm $(DESTDIR)$(plugindir)/$$plugin 2>/dev/null; \
|
rm $(DESTDIR)$(plugindir)/$$plugin 2>/dev/null; \
|
||||||
done
|
done
|
||||||
-@rmdir $(DESTDIR)$(plugindir) 2>/dev/null
|
-@rmdir $(DESTDIR)$(plugindir) 2>/dev/null
|
||||||
|
else
|
||||||
|
install:
|
||||||
|
@true
|
||||||
|
uninstall:
|
||||||
|
@true
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(MAKECMDGOALS),distclean)
|
ifneq ($(MAKECMDGOALS),distclean)
|
||||||
-include $(DEPS)
|
-include $(DEPS)
|
||||||
|
|||||||
@@ -29,9 +29,6 @@
|
|||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
#include "libite/lite.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
|
* Setup standard FHS 2.3 structure in /var, and
|
||||||
* write runlevel to UTMP, needed by, e.g., printerdrake.
|
* write runlevel to UTMP, needed by, e.g., printerdrake.
|
||||||
@@ -104,8 +101,6 @@ PLUGIN_EXIT(plugin_exit)
|
|||||||
plugin_unregister(&plugin);
|
plugin_unregister(&plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif/* ENABLE_STATIC */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local Variables:
|
* Local Variables:
|
||||||
* version-control: t
|
* version-control: t
|
||||||
|
|||||||
Reference in new issue
Block a user