mirror of
https://github.com/troglobit/finit.git
synced 2026-10-12 10:12:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc2cb21005 | ||
|
|
e1169628ce | ||
|
|
48b420b757 | ||
|
|
9796809907 | ||
|
|
a3193b34a6 | ||
|
|
c0af01db6d | ||
|
|
3c1c7df420 | ||
|
|
258efd4101 | ||
|
|
5e33647f80 | ||
|
|
d2f23e281f | ||
|
|
b5e3e69553 | ||
|
|
8d85e59214 | ||
|
|
a1c8ada320 | ||
|
|
ae15988eb8 | ||
|
|
9491f18972 |
+24
-3
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Finit | Fast & Extensible init for Linux
|
||||
========================================
|
||||
Finit ][ Fast & Extensible init for Linux
|
||||
=========================================
|
||||
[![Travis Status]][Travis] [![Coverity Status]][Coverity Scan]
|
||||
|
||||

|
||||
|
||||
@@ -415,6 +415,8 @@ void conf_reload_dynamic(void)
|
||||
while (num--)
|
||||
free(e[num]);
|
||||
free(e);
|
||||
|
||||
set_hostname(&hostname);
|
||||
}
|
||||
|
||||
int conf_parse_config(void)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
@@ -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
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user