Compare commits

..
15 Commits
Author SHA1 Message Date
Joachim Nilsson bc2cb21005 Update version links.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-16 20:46:34 +02:00
Joachim Nilsson e1169628ce Update ChangeLog and bump version for v2.1 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-16 20:44:47 +02:00
Joachim Nilsson 48b420b757 Simplify execution and _exit() of service callback.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-16 19:45:09 +02:00
Joachim Nilsson 9796809907 Merge pull request #12 from westermo/wkz/sighup-fix
Unblock blocked signals after forking off a child
2015-10-16 18:42:47 +02:00
Tobias Waldekranz a3193b34a6 Unblock blocked signals after forking off a child
After forking off a new child, all signals that are blocked by finit
should be unblocked before exec-ing the final binary. Also, finit now
blocks SIGHUP, so add it to the set of signals that should be
unblocked.
2015-10-16 18:32:53 +02:00
Joachim Nilsson c0af01db6d Upgrade libite (LITE) to v1.1.1
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-10 17:36:24 +02:00
Joachim Nilsson 3c1c7df420 Default to -O2, not -Os, and use CPPFLAGS for includes, not CFLAGS.
We should not use -Os as default optimization, it is sometimes unstable
in cross compilers.  Instead, default to -O2, which is the more tried
and tested path.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-10 17:34:31 +02:00
Joachim Nilsson 258efd4101 Cleanup, minor bug fixes and silencing of netlink plugin.
Patch courtesy of Westermo.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-08 19:59:19 +02:00
Joachim Nilsson 5e33647f80 Fix too small MAX args in initctl and too few args in svc_t
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-07 21:03:35 +02:00
Joachim Nilsson d2f23e281f Allow Finit to set hostname at dynamic reload.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-06 19:35:02 +02:00
Joachim Nilsson b5e3e69553 Do not allow VERSION to be overloaded by build system.
When integrating finit as a component in another system, that build
system may set VERSION as an environment variable for that OS -- we do
not want that version to be set as the version of finit.

Also, bump version to 2.0.1-dev for upcoming patch release cycle.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-10-02 15:09:07 +02:00
Joachim Nilsson 8d85e59214 Optimization is a CFLAG, not a CPPFLAG
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-29 22:39:49 +02:00
Joachim Nilsson a1c8ada320 Play around a bit with project title heading.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-29 22:39:19 +02:00
Tobias Waldekranz ae15988eb8 Add hook point on fstab mount failure
Check return code from `mount -na`, if there where any errors give
plugins a chance to do something about it.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-29 22:38:06 +02:00
Joachim Nilsson 9491f18972 service_enabled(): Only check WCOREDUMP() from if WIFSIGNALED()
Patch courtesy of Westermo.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2015-09-28 19:17:30 +02:00
13 changed files with 77 additions and 46 deletions
+24 -3
View File
@@ -3,6 +3,25 @@ Change Log
All notable changes to the project are documented in this file.
[2.1][] - 2015-10-16
--------------------
### Changes
* Add hook point for fstab mount failure
* Set hostname on dynamic reload
* Upgrade to libite v1.1.1
### Fixes
* Fix service callback coredump checks and simplify callback exit
* Do not use `-Os` use `-O2` as default optimization level. Many cross
compiler toolchains are known to have problems with `-Os`
* Do not allow build VERSION to be overloaded by an environment variable
* Fix too small MAX arguments and too few argments in `svc_t` for
reading currently running services with `initctl show`
[2.0][] - 2015-09-20
--------------------
@@ -19,8 +38,8 @@ introduction of an `initctl` tool.
simply add a `:ID` after the `service` keyword, where `ID` is a unique
instance number for that service.
service #1 [2345] /sbin/httpd -f -h /http -p 80 -- Web server
service #2 [2345] /sbin/httpd -f -h /http -p 8080 -- Old web server
service :1 [2345] /sbin/httpd -f -h /http -p 80 -- Web server
service :2 [2345] /sbin/httpd -f -h /http -p 8080 -- Old web server
* Another noteworthy new feature is support for starting/stopping
services on Netlink events:
@@ -152,6 +171,7 @@ The [libuEv] release.
[1.10][] - 2014-11-27
---------------------
Major bug fix release.
### Changes
@@ -379,7 +399,8 @@ Major bug fix release.
* Initial release
[UNRELEASED]: https://github.com/troglobit/finit/compare/1.12...HEAD
[UNRELEASED]: https://github.com/troglobit/finit/compare/2.1...HEAD
[2.1]: https://github.com/troglobit/finit/compare/2.0...2.1
[2.0]: https://github.com/troglobit/finit/compare/1.12...2.0
[1.12]: https://github.com/troglobit/finit/compare/1.11...1.12
[1.11]: https://github.com/troglobit/finit/compare/1.10...1.11
+2 -2
View File
@@ -25,8 +25,8 @@
install-exec install-data install-dev \
uninstall-exec uninstall-data uninstall-dev
#VERSION ?= $(shell git tag -l | tail -1)
VERSION ?= 2.0
#VERSION = $(shell git tag -l | tail -1)
VERSION = 2.1
NAME = finit
PKG = $(NAME)-$(VERSION)
DEV = $(NAME)-dev
+2 -2
View File
@@ -1,5 +1,5 @@
Finit | Fast & Extensible init for Linux
========================================
Finit ][ Fast & Extensible init for Linux
=========================================
[![Travis Status]][Travis] [![Coverity Status]][Coverity Scan]
![Original Finit homepage image](images/finit.jpg "Finit in action!")
+2
View File
@@ -415,6 +415,8 @@ void conf_reload_dynamic(void)
while (num--)
free(e[num]);
free(e);
set_hostname(&hostname);
}
int conf_parse_config(void)
Vendored
+5 -5
View File
@@ -345,9 +345,9 @@ fi
echo >> config.mk
if [ $debug -eq 1 ]; then
echo "CPPFLAGS += -O0 -g" >> config.mk
echo "CFLAGS += -O0 -g" >> config.mk
else
echo "CPPFLAGS += -Os" >> config.mk
echo "CFLAGS += -O2" >> config.mk
fi
echo >> config.mk
@@ -375,7 +375,7 @@ fi
if [ x"$libite" != x"" ]; then
echo "LIBITE = $libite" >> config.mk
echo "CFLAGS += -I\$(LIBITE)/include" >> config.mk
echo "CPPFLAGS += -I\$(LIBITE)/include" >> config.mk
echo "LDFLAGS += -L\$(LIBITE)/lib" >> config.mk
echo "LDLIBS += -l:libite.so.2" >> config.mk
else
@@ -386,7 +386,7 @@ fi
if [ x"$libuev" != x"" ]; then
echo "LIBUEV = $libuev" >> config.mk
echo "CFLAGS += -I\$(LIBUEV)/include" >> config.mk
echo "CPPFLAGS += -I\$(LIBUEV)/include" >> config.mk
echo "LDFLAGS += -L\$(LIBUEV)/lib" >> config.mk
echo "LDLIBS += -l:libuev.so.1" >> config.mk
else
@@ -397,7 +397,7 @@ fi
echo >> config.mk
echo "export libdir plugindir incdir" >> config.mk
echo "export CPPFLAGS LDFLAGS LDLIBS STATIC" >> config.mk
echo "export CFLAGS CPPFLAGS LDFLAGS LDLIBS STATIC" >> config.mk
##############################################################################
echo "/* Generated by finit configure script. */" > config.h
+8 -1
View File
@@ -71,6 +71,7 @@ static int banner(void)
int main(int argc, char* argv[])
{
int err;
uev_ctx_t loop;
/*
@@ -151,7 +152,13 @@ int main(int argc, char* argv[])
plugin_run_hooks(HOOK_ROOTFS_UP);
umask(0);
run("/bin/mount -na");
print_desc("Mounting filesystems", NULL);
err = run("/bin/mount -na");
print_result(err);
if (err)
plugin_run_hooks(HOOK_MOUNT_ERROR);
run("/sbin/swapon -ea");
umask(0022);
+1 -1
View File
@@ -150,7 +150,7 @@ static int show_status(char *UNUSED(arg))
for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) {
int inetd = svc_is_inetd(svc);
char jobid[10], args[80] = "";
char jobid[10], args[512] = "";
struct init_request rq = {
.magic = INIT_MAGIC,
.cmd = INIT_CMD_QUERY_INETD,
+1 -1
Submodule libite updated: 4d6c32f81a...bd9a618ea3
+1
View File
@@ -43,6 +43,7 @@
typedef enum {
/* Bootstrap hooks */
HOOK_ROOTFS_UP = 0,
HOOK_MOUNT_ERROR,
HOOK_BASEFS_UP,
HOOK_NETWORK_UP,
HOOK_SVC_UP,
+24 -25
View File
@@ -29,16 +29,20 @@
#include "../helpers.h"
#include "../plugin.h"
static int nlmsg_validate(struct nlmsghdr *nlmsg, size_t len)
static int nlmsg_validate(struct nlmsghdr *nh, size_t len)
{
if (!NLMSG_OK(nlmsg, len))
if (!NLMSG_OK(nh, len))
return 1;
if (len < sizeof(struct nlmsghdr))
if (nh->nlmsg_type == NLMSG_DONE) {
_d("Done with netlink messages.");
return 1;
}
if (len < nlmsg->nlmsg_len)
if (nh->nlmsg_type == NLMSG_ERROR) {
_d("Netlink reports error.");
return 1;
}
return 0;
}
@@ -155,28 +159,23 @@ static void nl_link(struct nlmsghdr *nlmsg)
static void nl_callback(void *UNUSED(arg), int sd, int UNUSED(events))
{
ssize_t len;
static char replybuf[2048];
struct nlmsghdr *p = (struct nlmsghdr *)replybuf;
static char buf[4096];
struct nlmsghdr *nh;
memset(replybuf, 0, sizeof(replybuf));
len = recv(sd, replybuf, sizeof(replybuf), 0);
memset(buf, 0, sizeof(buf));
len = recv(sd, buf, sizeof(buf), 0);
if (len < 0) {
if (errno != EINTR) /* Signal */
_pe("recv()");
return;
}
for (; len > 0; p = NLMSG_NEXT(p, len)) {
if (nlmsg_validate(p, len)) {
_e("Packet too small or truncated!");
return;
}
_d("Well formed netlink message received.");
if (p->nlmsg_type == RTM_NEWROUTE || p->nlmsg_type == RTM_DELROUTE)
nl_route(p);
for (nh = (struct nlmsghdr *)buf; !nlmsg_validate(nh, len); nh = NLMSG_NEXT(nh, len)) {
//_d("Well formed netlink message received. type %d ...", nh->nlmsg_type);
if (nh->nlmsg_type == RTM_NEWROUTE || nh->nlmsg_type == RTM_DELROUTE)
nl_route(nh);
else
nl_link(p);
nl_link(nh);
}
}
@@ -190,20 +189,20 @@ static plugin_t plugin = {
PLUGIN_INIT(plugin_init)
{
int sd;
struct sockaddr_nl addr;
struct sockaddr_nl sa;
sd = socket(PF_NETLINK, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, NETLINK_ROUTE);
sd = socket(AF_NETLINK, SOCK_RAW | SOCK_NONBLOCK | SOCK_CLOEXEC, NETLINK_ROUTE);
if (sd < 0) {
_pe("socket()");
return;
}
memset(&addr, 0, sizeof(addr));
addr.nl_family = AF_NETLINK;
addr.nl_groups = RTMGRP_IPV4_ROUTE | RTMGRP_LINK;
addr.nl_pid = getpid();
memset(&sa, 0, sizeof(sa));
sa.nl_family = AF_NETLINK;
sa.nl_groups = RTMGRP_IPV4_ROUTE | RTMGRP_LINK; // | RTMGRP_NOTIFY | RTMGRP_IPV4_IFADDR;
sa.nl_pid = getpid();
if (bind(sd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
if (bind(sd, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
_pe("bind()");
close(sd);
return;
+5 -5
View File
@@ -113,10 +113,8 @@ svc_cmd_t service_enabled(svc_t *svc, int event, void *arg)
return SVC_STOP;
}
if (!pid) {
status = svc->cb(svc, event, arg);
exit(status);
}
if (!pid)
_exit(svc->cb(svc, event, arg));
if (waitpid(pid, &status, 0) == -1) {
_pe("Failed reading status from %s callback", svc->cmd);
@@ -128,7 +126,7 @@ svc_cmd_t service_enabled(svc_t *svc, int event, void *arg)
return WEXITSTATUS(status);
/* Check for SEGFAULT or other error ... */
if (WCOREDUMP(status))
if (WIFSIGNALED(status) && WCOREDUMP(status))
_e("Callback to %s crashed!\n", svc->cmd);
else
_e("Callback to %s did not exit normally!\n", svc->cmd);
@@ -278,6 +276,8 @@ int service_start(svc_t *svc)
_e("%starting %s: %s", respawn ? "Res" : "S", svc->cmd, buf);
}
sig_unblock();
if (svc->inetd.cmd)
status = svc->inetd.cmd(svc->inetd.type);
else
+1
View File
@@ -188,6 +188,7 @@ void sig_unblock(void)
struct sigaction sa;
sigemptyset(&nmask);
sigaddset(&nmask, SIGHUP);
sigaddset(&nmask, SIGCHLD);
sigaddset(&nmask, SIGINT);
sigaddset(&nmask, SIGPWR);
+1 -1
View File
@@ -52,7 +52,7 @@ typedef enum {
#define MAX_USER_LEN 16
#define MAX_NUM_FDS 64 /* Max number of I/O plugins */
#define MAX_NUM_SVC 64 /* Enough? */
#define MAX_NUM_SVC_ARGS 16
#define MAX_NUM_SVC_ARGS 32
/* Default enable for all services, can be stopped by means
* of issuing an initctl call. E.g.