Giter Site home page Giter Site logo

troglobit / finit Goto Github PK

View Code? Open in Web Editor NEW
607.0 25.0 59.0 5.5 MB

Fast init for Linux. Cookies included

Home Page: https://troglobit.com/projects/finit/

License: MIT License

Makefile 2.78% C 84.65% Shell 9.77% M4 2.70% BitBake 0.10%
runlevel c init init-system supervisor boot boot-process getty watchdog linux

finit's Introduction

License Badge GitHub Status Coverity Status Finit: Fast Init

Introduction

Fast init for Linux systems. Reverse engineered from the EeePC fastinit by Claudio Matsuoka — "gaps filled with frog DNA …"

Alpine screenshot
Figure 1: Screenshot of Finit booting Alpine Linux (HowTo).

Features include:

  • Runlevels, defined per service
  • One-shot tasks, services (daemons), or SysV init start/stop scripts
  • Runparts and /etc/rc.local support
  • Process supervision similar to systemd
  • Sourcing environment files
  • Conditions for network/process/custom dependencies
  • Readiness notification; PID files (native) for synchronizing system startup, support for systemd sd_notify(), or s6 style too
  • Limited support for tmpfiles.d(5) (no aging, attributes, or subvolumes)
  • Pre/Post script actions
  • Rudimentary templating support
  • Tooling to enable/disable services
  • Built-in getty
  • Built-in watchdog, with support for hand-over to watchdogd
  • Built-in support for Debian/BusyBox /etc/network/interfaces
  • Cgroups v2, both configuration and monitoring in initctl top
  • Plugin support for customization
  • Proper rescue mode with bundled sulogin for protected maintenance shell
  • Integration with watchdogd for full system supervision
  • Logging to kernel ring buffer before syslogd has started, see the recommended sysklogd project for complete logging integration and how to log to the kernel ring buffer from scripts using logger

Focus is on small and embedded systems, although Finit is fully usable on server and desktop systems as well. For working examples, see the contrib/ section with tutorials for the following Linux distributions:

Note: support for various Linux distributions does not mean Finit installs easily on all architectures. The bundled install scripts are examples for standard installations, tested on amd64 (x86_64) systems. Custom setups, e.g., for embedded systems, can be found in any of the following Buildroot based examples: myLinux, Infix, or the plain br2-finit-demo.

Example

This example /etc/finit.conf can also be split up in multiple .conf files in /etc/finit.d. Available, but not yet enabled, services can be placed in /etc/finit.d/available and enabled by an operator using the initctl tool. See the above mentioned Linux distributions, or myLinux.

Note: as of Finit v4.4, .conf lines can be broken up using the standard UNIX continuation character (\), also trailing comments are now supported. The latter means you need to escape any hashes used in directives and descriptions (\#). For more on this and examples, see the finit.conf(5) manual or doc/config.md.

# Fallback if /etc/hostname is missing
host default

# Runlevel to start after bootstrap, 'S', default: 2
#runlevel 2

# Support for setting global environment variables, using foo=bar syntax
# be careful though with variables like PATH, SHELL, LOGNAME, etc.
#PATH=/usr/bin:/bin:/usr/sbin:/sbin

# Max file size for each log file: 100 kiB, rotate max 4 copies:
# log => log.1 => log.2.gz => log.3.gz => log.4.gz
log size=100k count=4

# Services to be monitored and respawned as needed
service [S12345] env:-/etc/conf.d/watchdog watchdog $WATCHDOG_OPTS $WATCHDOG_DEV -- System watchdog daemon
service [S12345] env:-/etc/conf.d/syslog syslogd -n $SYSLOGD_OPTS          -- System log daemon
service [S12345] <pid/syslogd> env:-/etc/conf.d/klogd klogd -n $KLOGD_OPTS -- Kernel log daemon
service   [2345] env:-/etc/conf.d/lldpd lldpd -d $LLDPD_OPTS               -- LLDP daemon (IEEE 802.1ab)

# The BusyBox ntpd does not use syslog when running in the foreground
# So we use this trick to redirect stdout/stderr to a log file.  The
# log file is rotated with the above settings.  The condition declares
# a dependency on a system default route (gateway) to be set.  A single
# <!> at the beginning means ntpd does not respect SIGHUP for restart.
service [2345] log:/var/log/ntpd.log <!net/route/default> ntpd -n -l -I eth0 -- NTP daemon

# For multiple instances of the same service, add :ID somewhere between
# the service/run/task keyword and the command.
service :80   [2345] merecat -n -p 80   /var/www -- Web server
service :8080 [2345] merecat -n -p 8080 /var/www -- Old web server

# Alternative method instead of below runparts, can also use /etc/rc.local
#sysv [S] /etc/init.d/keyboard-setup       -- Setting up preliminary keymap
#sysv [S] /etc/init.d/acpid                -- Starting ACPI Daemon
#task [S] /etc/init.d/kbd                  -- Preparing console

# Hidden from boot progress, using empty `--` description
#sysv [S] /etc/init.d/keyboard-setup       --
#sysv [S] /etc/init.d/acpid                --
#task [S] /etc/init.d/kbd                  --

# Run start scripts from this directory
# runparts /etc/start.d

# Virtual consoles run BusyBox getty, keep kernel default speed
tty [12345] /sbin/getty -L 0 /dev/tty1  linux nowait noclear
tty [2345]  /sbin/getty -L 0 /dev/tty2  linux nowait noclear
tty [2345]  /sbin/getty -L 0 /dev/tty3  linux nowait noclear

# Use built-in getty for serial port and USB serial
#tty [12345] /dev/ttyAMA0 noclear nowait
#tty [12345] /dev/ttyUSB0 noclear

# Just give me a shell, I need to debug this embedded system!
#tty [12345] console noclear nologin

The service stanza, as well as task, run and others are described in full in doc/config.md. Here's a quick overview of some of the most common components needed to start a UNIX daemon:

service [LVLS] <COND> log env:[-]/etc/default/daemon daemon ARGS -- Daemon daemon
^       ^      ^      ^   ^                          ^      ^       ^
|       |      |      |   |                          |      |        `---------- Optional description
|       |      |      |   |                          |       `------------------ Daemon arguments
|       |      |      |   |                           `------------------------- Path to daemon
|       |      |      |    `---------------------------------------------------- Optional env. file
|       |      |       `-------------------------------------------------------- Redirect output to log
|       |       `--------------------------------------------------------------- Optional conditions
|        `---------------------------------------------------------------------- Optional Runlevels
 `------------------------------------------------------------------------------ Monitored application

Some components are optional: runlevel(s), condition(s) and description, making it easy to create simple start scripts and still possible for more advanced uses as well:

service /usr/sbin/sshd -D

Dependencies are handled using conditions. One of the most common conditions is to wait for basic networking to become available:

service <net/route/default> nginx -- High performance HTTP server

Here is another example where we instruct Finit to not start BusyBox ntpd until syslogd has started properly. Finit waits for syslogd to create its PID file, by default /var/run/syslogd.pid.

service [2345] log <!pid/syslogd> ntpd -n -N -p pool.ntp.org
service [S12345] syslogd -n -- Syslog daemon

Notice the log keyword, BusyBox ntpd uses stderr for logging when run in the foreground. With log Finit redirects stdout + stderr to the system log daemon using the command line logger(1) tool.

A service, or task, can have multiple dependencies listed. Here we wait for both syslogd to have started and basic networking to be up:

service [2345] log <pid/syslogd,net/route/default> ntpd -n -N -p pool.ntp.org

If either condition fails, e.g. loss of networking, ntpd is stopped and as soon as it comes back up again ntpd is restarted automatically.

Note: Make sure daemons do not fork and detach themselves from the controlling TTY, usually an -n or -f flag, or -D as in the case of OpenSSH above. If it detaches itself, Finit cannot monitor it and will instead try to restart it.

Features

Process Supervision

Start, monitor and restart services should they fail.

Getty

Finit supports external getty but also comes with a limited built-in Getty, useful for really small systems. A getty sets up the TTY and waits for user input before handing over to /bin/login, which is responsible for handling the actual authentication.

tty [12345] /dev/tty1    nowait  linux
tty [12345] /dev/ttyAMA0 noclear vt100
tty [12345] /sbin/getty  -L /dev/ttyAMA0 vt100

Users of embedded systems may want to enable automatic serial console with the special @console device. This works regardless weather the system uses ttyS0, ttyAMA0, ttyMXC0, or anything else. Finit figures it out by querying sysfs: /sys/class/tty/console/active.

tty [12345] @console linux noclear

Notice the optional noclear, nowait, and nologin flags. The latter is for skipping the login process entirely. For more information, see doc/config.md.

Runlevels

Support for SysV init-style runlevels is available, in the same minimal style as everything else in Finit. The [2345] syntax can be applied to service, task, run, and TTY stanzas.

Reserved runlevels are 0 and 6, halt and reboot, respectively just like SysV init. Runlevel 1 can be configured freely, but is recommended to be kept as the system single-user runlevel since Finit will not start networking here. The configured runlevel NUM from /etc/finit.conf is what Finit changes to after bootstrap, unless 'single' (or 'S') is given on the kernel cmdline, in which case runlevel 1 is started.

All services in runlevel S) are started first, followed by the desired run-time runlevel. Run tasks in runlevel S can be started in sequence by using run [S] cmd. Changing runlevels at runtime is done like any other init, e.g. init 4, but also using the more advanced intictl tool.

Conditions

As mentioned previously, Finit has an advanced dependency system to handle synchronization, called conditions. It can be used in many ways; depend on another service, network availability, etc.

One really cool example useful for embedded systems is to run certain scripts if a board has a certain feature encoded in its device tree. At bootstrap we run the following ident script:

#!/bin/sh
conddir=/var/run/finit/cond/hw/model
dtmodel=/sys/firmware/devicetree/base/model

if ! test -e $dtmodel; then
    exit 0
fi

model=$(cat $dtmodel | tr "[A-Z] " "[a-z]-")
mkdir -p $conddir && ln -s ../../reconf $conddir/$model

Provided the device tree node exists, and is a string, we can then use the condition <hw/model/foo> when starting other scripts. Here is an example:

run  [S]                /path/to/ident    --
task [2] <hw/model/foo> /path/to/foo-init -- Initializing Foo board

Notice the trick with an empty description to hide the call to ident in the Finit progress output.

Plugins

Plugins can extend the functionality of Finit and hook into the different stages of the boot process and at runtime. Plugins are written in C and compiled into a dynamic library loaded automatically by finit at boot. A basic set of plugins are bundled in the plugins/ directory.

Capabilities:

  • Hooks
    Hook into the boot at predefined points to extend Finit
  • I/O
    Listen to external events and control Finit behavior/services

Extensions and functionality not purely related to what an /sbin/init needs to start a system are available as a set of plugins that either hook into the boot process or respond to various I/O.

For more information, see doc/plugins.md.

Automatic Reload

By default, Finit monitors /etc/finit.d/ and /etc/finit.d/enabled/ registering any changes to .conf files. To activate a change the user must call initctl reload, which reloads all modified files, stops any removed services, starts new ones, and restarts any modified ones. If the command line arguments of a service have changed, the process will be terminated and then started again with the updated arguments. If the arguments have not been modified and the process supports SIGHUP, the process will receive a SIGHUP rather than being terminated and started.

For some use-cases the extra step of calling initctl reload creates an unnecessary overhead, which can be removed at build-time using:

configure --enable-auto-reload

Cgroups

Finit supports cgroups v2 and comes with the following default groups in which services and user sessions are placed in:

 /sys/fs/cgroup
   |-- init/               # cpu.weight:100
   |-- system/             # cpu.weight:9800
   `-- user/               # cpu.weight:100

Finit itself and its helper scripts and services are placed in the top-level leaf-node group init/, which also is reserved.

All run/task/service/sysv processes are placed in their own sub-group in system/. The name of each sub-group is taken from the respective .conf file from /etc/finit.d.

All getty/tty processes are placed in their own sub-group in user/. The name of each sub-group is taken from the username.

A fourth group also exists, the root group. It is also reserved and primarily intended for RT tasks. If you have RT tasks they need to be declared as such in their service stanza like this:

service [...] <...> cgroup.root /path/to/foo args -- description

or

cgroup.root
service [...] <...> /path/to/foo args -- description
service [...] <...> /path/to/bar args -- description

See doc/config.md for more information, e.g., how to configure per-group limits.

The initctl tool has three commands to help debug and optimize the setup and monitoring of cgroups. See the ps, top, and cgroup commands for details.

Note: systems that do not support cgroups, specifically version 2, are automatically detected. On such systems the above functionality is disabled early at boot.

Runparts & /etc/rc.local

At the end of the boot, when all bootstrap (S) tasks and services have started, but not networking, Finit calls its built-in run-parts(8) command on any configured runparts <DIR> directory. This happens just before changing to the configured runlevel (default 2). (Networking is enabled just prior to changing from single user mode.)

runparts /etc/rc.d/

Right after the runlevel change when all services have started properly, /etc/rc.local is called.

No configuration stanza in /etc/finit.conf is required for rc.local. If it exists and is an executable shell script Finit calls it at the very end of the boot, before calling the HOOK_SYSTEM_UP. See more on hooks in doc/plugins.md.

Limitations

It is not possible to call Finit via signals or use initctl in any runparts or /etc/rc.local script. This because Finit is single threaded and is calling these scripts in a blocking fashion at the end of runlevel S, at which point the event loop has not yet been started.

The event loop is the whole thing which Finit is built around, except for runlevel S, which remains a slow procession through a lot of set up, with a few hooks and blocking call outs to external scripts.

However, not all initctl commands are prohibited. Supported commands:

  • inictl cond: only operate of files in /run/finit/cond
  • initctl enable/disable: enabled run/task/service is activated on the runlevel change from S to 2
  • initctl touch/show/create/delete/list: create, provided the non-interactive mode is used, again changes take effect in the runlevel change directly after bootstrap
  • initctl -f reboot/poweroff/halt: provided the -f flag is used to force direct kernel commands

Example: you can set a usr/ condition in /etc/rc.local and have a service/task in runlevel 2 depend on it to execute.

Runlevels

Basic support for runlevels is included in Finit from v1.8. By default all services, tasks, run commands and TTYs listed without a set of runlevels get a default set [234] assigned. The default runlevel after boot is 2.

Finit supports runlevels 0-9, and S, with 0 reserved for halt, 6 reboot and S for services to only run at bootstrap. Runlevel 1 is the single user level, where usually no networking is enabled. In Finit this is more of a policy for the user to define. Normally only runlevels 1-6 are used, and even more commonly, only the default runlevel is used.

To specify an allowed set of runlevels for a service, run command, task, or tty, add [NNN] to your /etc/finit.conf, like this:

service [S12345] syslogd -n -x             -- System log daemon
run     [S]      /etc/init.d/acpid start   -- Starting ACPI Daemon
task    [S]      /etc/init.d/kbd start     -- Preparing console
service [S12345] <pid/syslogd> klogd -n -x -- Kernel log daemon

tty     [12345]  /dev/tty1
tty     [2]      /dev/tty2
tty     [2]      /dev/tty3
tty     [2]      /dev/tty4
tty     [2]      /dev/tty5
tty     [2]      /dev/tty6

In this example syslogd is first started, in parallel, and then acpid is called using a conventional SysV init script. It is called with the run command, meaning the following task command to start the kbd script is not called until the acpid init script has fully completed. Then the keyboard setup script is called in parallel with klogd as a monitored service.

Again, tasks and services are started in parallel, while run commands are called in the order listed and subsequent commands are not started until a run command has completed. Also, task and run commands are run in a shell, so pipes and redirects can be used.

The following examples illustrate this. Bootstrap task and run commands are also removed when they have completed, initctl show will not list them.

task [S] echo "foo" | cat >/tmp/bar
run  [S] echo "$HOME" >/tmp/secret

Switching between runlevels can be done by calling init with a single argument, e.g. init 5, or using initctl runlevel 5, both switch to runlevel 5. When changing runlevels Finit also automatically reloads all .conf files in the /etc/finit.d/ directory. So if you want to set a new system config, switch to runlevel 1, change all config files in the system, and touch all .conf files in /etc/finit.d before switching back to the previous runlevel again — that way Finit can both stop old services and start any new ones for you, without rebooting the system.

Rebooting & Halting

Traditionally, rebooting and halting a UNIX system is done by changing its runlevel. Finit comes with its own tooling providing: shutdown, reboot, poweroff, and suspend, but also the initctl tool, detailed in the next section.

For compatibility reasons Finit listens to the same set of signals as BusyBox init. This is not 100% compatible with SysV init, but clearly the more common combination for Finit. For more details, see doc/signals.md.

Commands & Status

Finit also implements a modern API to query status, and start/stop services, called initctl. Unlike telinit the initctl tool does not return until the given command has fully completed.

Usage: initctl [OPTIONS] [COMMAND]

Options:
  -b, --batch               Batch mode, no screen size probing
  -c, --create              Create missing paths (and files) as needed
  -f, --force               Ignore missing files and arguments, never prompt
  -h, --help                This help text
  -j, --json                JSON output in 'status' and 'cond' commands
  -1, --once                Only one lap in commands like 'top'
  -p, --plain               Use plain table headings, no ctrl chars
  -q, --quiet               Silent, only return status of command
  -t, --no-heading          Skip table headings
  -v, --verbose             Verbose output
  -V, --version             Show program version

Commands:
  debug                     Toggle Finit (daemon) debug
  help                      This help text
  version                   Show program version

  ls | list                 List all .conf in /etc/finit.d
  create   <CONF>           Create   .conf in /etc/finit.d/available
  delete   <CONF>           Delete   .conf in /etc/finit.d/available
  show     <CONF>           Show     .conf in /etc/finit.d/available
  edit     <CONF>           Edit     .conf in /etc/finit.d/available
  touch    <CONF>           Change   .conf in /etc/finit.d/available
  enable   <CONF>           Enable   .conf in /etc/finit.d/available
  disable  <CONF>           Disable  .conf in /etc/finit.d/enabled
  reload                    Reload  *.conf in /etc/finit.d (activate changes)

  cond     set   <COND>     Set (assert) user-defined conditions     +usr/COND
  cond     get   <COND>     Get status of user-defined condition, see $? and -v
  cond     clear <COND>     Clear (deassert) user-defined conditions -usr/COND
  cond     status           Show condition status, default cond command
  cond     dump  [TYPE]     Dump all, or a type of, conditions and their status

  log      [NAME]           Show ten last Finit, or NAME, messages from syslog
  start    <NAME>[:ID]      Start service by name, with optional ID
  stop     <NAME>[:ID]      Stop/Pause a running service by name
  reload   <NAME>[:ID]      Reload service as if .conf changed (SIGHUP or restart)
                            This allows restart of run/tasks that have already run
                            Note: Finit .conf file(s) are *not* reloaded!
  restart  <NAME>[:ID]      Restart (stop/start) service by name
  signal   <NAME>[:ID] <S>  Send signal S to service by name, with optional ID
  ident    [NAME]           Show matching identities for NAME, or all
  status   <NAME>[:ID]      Show service status, by name
  status                    Show status of services, default command

  cgroup                    List cgroup config overview
  ps                        List processes based on cgroups
  top                       Show top-like listing based on cgroups

  plugins                   List installed plugins

  runlevel [0-9]            Show or set runlevel: 0 halt, 6 reboot
  reboot                    Reboot system
  halt                      Halt system
  poweroff                  Halt and power off system
  suspend                   Suspend system

  utmp     show             Raw dump of UTMP/WTMP db

For services not supporting SIGHUP the <!> notation in the .conf file must be used to tell Finit to stop and start it on reload and runlevel changes. If <> holds more conditions, these will also affect how a service is maintained.

Note: even though it is possible to start services not belonging in the current runlevel these services will not be respawned automatically by Finit if they exit (crash). Hence, if the runlevel is 2, the below Dropbear SSH service will not be restarted if it is killed or exits.

The status command is the default, it displays a quick overview of all monitored run/task/services. Here we call initctl -p, suitable for scripting and documentation:

alpine:~# initctl -p
PID   IDENT     STATUS   RUNLEVELS     DESCRIPTION
======================================================================
1506  acpid     running  [---2345----] ACPI daemon
1509  crond     running  [---2345----] Cron daemon
1489  dropbear  running  [---2345----] Dropbear SSH daemon
1511  klogd     running  [S-12345----] Kernel log daemon
1512  ntpd      running  [---2345----] NTP daemon
1473  syslogd   running  [S-12345----] Syslog daemon

alpine:~# initctl -pv
PID   IDENT     STATUS   RUNLEVELS     COMMAND
======================================================================
1506  acpid     running  [---2345----] acpid -f
1509  crond     running  [---2345----] crond -f -S $CRON_OPTS
1489  dropbear  running  [---2345----] dropbear -R -F $DROPBEAR_OPTS
1511  klogd     running  [S-12345----] klogd -n $KLOGD_OPTS
1512  ntpd      running  [---2345----] ntpd -n $NTPD_OPTS
1473  syslogd   running  [S-12345----] syslogd -n

The environment variables to each of the services above are read from, in the case of Alpine Linux, /etc/conf.d/. Other distributions may have other directories, e.g., Debian use /etc/default/.

The status command takes an optional NAME:ID argument. Here we check the status of dropbear, which only has one instance in this system:

alpine:~# initctl -p status dropbear
     Status : running
   Identity : dropbear
Description : Dropbear SSH daemon
     Origin : /etc/finit.d/enabled/dropbear.conf
Environment : -/etc/conf.d/dropbear
Condition(s):
    Command : dropbear -R -F $DROPBEAR_OPTS
   PID file : !/run/dropbear.pid
        PID : 1485
       User : root
      Group : root
     Uptime : 2 hour 46 min 56 sec
  Runlevels : [---2345----]
     Memory : 1.2M
     CGroup : /system/dropbear cpu 0 [100, max] mem [--.--, max]
              |- 1485 dropbear -R -F
              |- 2634 dropbear -R -F
              |- 2635 ash
              `- 2652 initctl -p status dropbear

Apr  8 12:19:49 alpine authpriv.info dropbear[1485]: Not backgrounding
Apr  8 12:37:45 alpine authpriv.info dropbear[2300]: Child connection from 192.168.121.1:47834
Apr  8 12:37:46 alpine authpriv.notice dropbear[2300]: Password auth succeeded for 'root' from 192.168.121.1:47834
Apr  8 12:37:46 alpine authpriv.info dropbear[2300]: Exit (root) from <192.168.121.1:47834>: Disconnect received
Apr  8 15:02:11 alpine authpriv.info dropbear[2634]: Child connection from 192.168.121.1:48576
Apr  8 15:02:12 alpine authpriv.notice dropbear[2634]: Password auth succeeded for 'root' from 192.168.121.1:48576

Requirements

Finit is capable of running on both desktop/server systems with udev and embedded systems that usually come with BusyBox mdev. Some systems have systemd-udev or eudev today instead of the original udev, Finit probes for all of them at runtime and expects /dev/ to be a writable file system using devtmpfs. It is also possible to run on a statically set up /dev if needed. It is however not a good idea to have both udev and mdev installed at the same time, this will lead to unpredictable results.

At boot Finit calls either mdev or udevd to populate /dev, this is done slightly differently and on systems with udev you might want to add the following one-shot task early in your /etc/finit.conf:

run [S] udevadm settle --timeout=120 -- Waiting for udev

Finit has a built-in Getty for TTYs, but requires a working /bin/login or /bin/sh, if no TTYs are configured in /etc/finit.conf.

For a fully operational system /var, /run and /tmp must be set up properly in /etc/fstab -- which is iterated over at boot.

Origin & References

This project is based on the original finit by Claudio Matsuoka which was reverse engineered from syscalls of the EeePC fastinit — "gaps filled with frog DNA …"

Finit is developed and maintained by Joachim Wiberg at GitHub. Please file bug reports, clone it, or send pull requests for bug fixes and proposed extensions.

finit's People

Contributors

abucodonosor avatar andreasegeberg avatar cmatsuoka avatar firasuke avatar hongkongkiwi avatar jacknewman12 avatar jackuess avatar joerg-krause avatar jonasj76 avatar joy4eg avatar liuming50 avatar magnusmalm avatar markand avatar mattiaswal avatar patstew avatar prologic avatar ptruz avatar roycyt avatar soggyfries avatar solt87 avatar srand avatar stargirl-chan avatar thezbyg avatar timgates42 avatar troglobit avatar villains avatar wishdev avatar wkz avatar xhebox avatar yangfl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

finit's Issues

Add support for early logging using /dev/kmsg

Until the user has started a syslogd service Finit has so far only had the console to log to. At bringup of a new system, or when debugging an existing system, it is sometimes necessary to enable Finit --debug on the kernel command line. This generates a lot of messages and is very difficult to debug and use.

This issue proposes adding support for early logging using the kernel /dev/kmsg. All logs can be sent there, while critical messages can also be output to the console. As soon as userspace has started a syslog() daemon the /dev/log device appears and we can fail-over to use syslog() instead.

Add implicit "initctl reload" after runparts

A user of an embedded system may want to extend/modify services declared in /etc/finit.d/ at boot
via runparts /some/other/path.

When scripts in the run-parts(8) directory have run, Finit should check if any service/tasklet/runlet have
been made "dirty" and then reload them.

Suggestion: more choices about the redirection of service

task    [2345] log <svc/sbin/syslogd> /sbin/ifup -a                      -- Networking

Redirecting to syslog is now the only choice, right?Could not there be more choices , for example none(/dev/null) , /var/log/xx.log(file)?I ran finit on my own distro, and no supported syslog.I like to keep it simple :D

Could it be added in finit?If not, i will close the issue.Or i can try to make a pull request if you're busy.

finit crashes if creating inetd service fails

I was experimenting with having inetd start dropbear when the eth0 interface comes up.

However on my small embedded system, I did not have the usual netbase package files installed. This caused finit to crash during boot and rendered the system unusable.

An ideal solution would be if finit gracefully reported errors if inetd service creation fails, rather than exiting early and preventing the system from starting.

I realize these problems would rarely occur in the majority of cases, but for minimal embedded Linux systems, it may be a concern.

Two cases of interest:

(1) Trying to use a named service

First I tried to use ssh by name, forgetting that I had not installed the netbase files in /etc.

finit.conf line:

inetd ssh/tcp@*,!eth0 nowait [2345] /usr/sbin/dropbear -i -B -R -F -- SSH service

Error messages during boot:

netd.c:getent() - Invalid/unknown inetd service, cannot create custom entry.finit:/home/markus/gumstix/yocto/build/tmp/work/cortexa8hf-vfp-neon-poky-linux-gnueabi/finit/2.4-r0/git/service.c:service_register() - Failed registering new inetd service ssh.[ 3.849273] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

Result

  • Service 'ssh' was not recognized, because file /etc/services is absent
  • finit crashes
  • System cannot boot

(2) Trying to use a protocol by name

Next I tried using the port number 22, instead of the named service 'ssh'.

finit.conf line:

inetd 22/tcp@*,!eth0 nowait [2345] /usr/sbin/dropbear -i -B -R -F -- SSH service

Error messages during boot:

netd.c:getent() - Cannot find proto tcp, skipping.finit:/home/markus/gumstix/yocto/build/tmp/work/cortexa8hf-vfp-neon-poky-linux-gnueabi/finit/2.4-r0/git/service.c:service_register() - Failed registering new inetd service 22.[ 3.835113] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

Result

  • Gets further but crashes when trying to look up the protocol name 'tcp', because the file /etc/protocols is absent
  • System cannot boot

Build fails when configured with --disable-inetd

I'm working on a small embedded system where the finit inetd server is not required.

Compilation fails with the following errors:

service.c: In function ‘service_register’:
service.c:579:4: error: label ‘recreate’ used but not defined
goto recreate;
^
Makefile:797: recipe for target 'finit-service.o' failed
make[2]: *** [finit-service.o] Error 1
make[2]: Leaving directory '/var/shared/finit'
Makefile:1022: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/var/shared/finit'
Makefile:442: recipe for target 'all' failed
make: *** [all] Error 2
markus@partypants:/var/shared/finit$ git rev-parse HEAD
e3783e8
markus@partypants:/var/shared/finit$

The seems to be that in service.c line 563 where the goto label 'recreate' appears inside an #ifndef INETD_DISABLED/#endif block.

Moving the recreate labe' outside the #ifndef/#endif block results in a few more errors:

markus@partypants:/var/shared/finit$ make
make all-recursive
make[1]: Entering directory '/var/shared/finit'
Making all in plugins
make[2]: Entering directory '/var/shared/finit/plugins'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/var/shared/finit/plugins'
make[2]: Entering directory '/var/shared/finit'
CC finit-service.o
CC finit-sig.o
CC finit-svc.o
CC finit-sm.o
CC finit-tty.o
CCLD finit
finit-service.o: In function service_register': /var/shared/finit/service.c:577: undefined reference toinetd_del'
collect2: error: ld returned 1 exit status
Makefile:546: recipe for target 'finit' failed
make[2]: *** [finit] Error 1
make[2]: Leaving directory '/var/shared/finit'
Makefile:1022: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/var/shared/finit'
Makefile:442: recipe for target 'all' failed
make: *** [all] Error 2
markus@partypants:/var/shared/finit$

It would appear that the inetd dependence is not completely eliminated by configuring with --disable-inetd.

Once again, thanks for creating finit. I love and appreciate the new features you are adding all the time. In particular, the "log" keyword to add to services and tasks to route stderr and stdout messages to the system logger, instead of to the serial console.

All the best!

Some problems - tested with my laptop and musl libc

First, sorry for my poor english..
And problems:

1. reboot without sync
in sig.c:

--- finit-3.0-rc1/sig.c 2016-09-14 04:49:41.000000000 +0800
+++ finit-3.0-rc1/sig.c 2016-09-14 04:49:41.000000000 +0800
@@ -152,6 +152,7 @@
        unmount_regular();

        /* We sit on / so we must remount it ro, try all the things! */
+       run("sync");
        run("/bin/mount -n -o remount,ro -t dummytype dummydev /");
        run("/bin/mount -n -o remount,ro dummydev /");
        run("/bin/mount -n -o remount,ro /");

I rebooted my laptop immediately after installing...crashed...I checked /bin/finit, found that it was empty.
Umount will sync automaticly but remount, so this was only happened on /.There is a need of sync command or soomething else can sync.

2. didn't clean hidden files

-       run_interactive("rm -rf /tmp/* /var/run/* /var/lock/*", "Cleaning up temporary directories");
+       run_interactive("rm -rf /tmp/* /tmp/.??* /var/run/* /var/lock/*", "Cleaning up temporary directories");

All files that named .* are not cleaned on boot.But /tmp has a lot of files named .*.

3. start udevd but no trigger

        run_interactive(devfsd, "Populating device tree");
+       run_interactive("/sbin/udevadm trigger --action=add --type=subsystems", "Trigger subsystems");
+       run_interactive("/sbin/udevadm trigger --action=add --type=devices", "Trigger devices");

With out trigger, kernel modules won't be loaded automaticly.Also devices is not under management.
For example, i915 was not loaded after boot, my network card was not renamed from wlan0 to wlp3s0 which means it was not handled by udev.

4. missing dir

+       makedir("/var/lock/subsys", 0755);
        makedir("/var/lock/subsys/messagebus", 0755);

No subsys in some distros.

5. A question
Can rlimit option be used on a specific process?This can be useful in cases like starting jack daemon.

😃 Thx for your excellent work on this init.

getty: reset tty on entry

After a successful login, when the spawned process exits, getty should reset the tty settings. Shells might turn off echo or configure some other non-sane behaviour. Subsequent logins might then not echo the username.

User should be able to choose between mdev/udevd in finit.conf

Currently the SETUP_DEVFS is hard-coded at build time depending on if the user defines EMBEDDED_SYSTEM or not.

Add support for dev-setup /sbin/mdev -s, or similar, to /etc/finit.conf to let the user decide.

Note: the udev/mdev soup currently must run before parsing finit.conf, due to fsck being called from inside the conf-parser. This should be refactored into a postponed action that can run just before remounting / as read/write.

built-in getty does not ask for password

Hi!

I have built buildroot with finit. And I have an issue that built-in getty does not ask for password in serial console. If I remove all mentions of tty in /etc/finit.conf, getty keeps starting.

Also, I was looking for a way to avoid using built-in getty and use busybox getty instead. I've found --enable-embedded option in build.md but looks like it does not exist anymore. Can you please at least remove it from the docs?

Add a --disable-plugins option?

Is this possible?

I'm not sure (from reading the sources) that any of the plugins are gonig to work for our system design. Just tested a compile against HEAD:

plugins/bootmisc.c:32:2: error: #error This plugin uses getuser(), which relies on dynamically linked GLIBC. Cannot be built statically!
 #error This plugin uses getuser(), which relies on dynamically linked GLIBC.  Cannot be built statically!
  ^
common.mk:18: recipe for target 'plugins/bootmisc.o' failed
make: *** [plugins/bootmisc.o] Error 1
=======> ERROR: Building '/home/prologic/vallinux/base/packages/finit/finit#HEAD-1.pkg.tar.gz' failed.

Failed creating .X11-unix and .ICE-unix with proper permissions

From issue #42 @xhebox reports:

I've noticed that .X11-unix is not 1777, the same problems about .ICE-unix and makedir(xxx)?Also, there's a makedir("/var/lock/subsys"0755); in bootmisc-plugin, then why we get error before patched dbus-plugin?

UPDATE2: @troglobit http://stackoverflow.com/questions/8719867/linux-mkdir-function-cant-authorize-full-permission. It looks like umask(affect mkdir but chmod)...

#include <sys/stat.h>

int main() {
        printf("%d\n", mkdir("/tmp/s", 777));
        return 0;
}

dr----x--t  2 xhe  users 4096 Oct  2 13:10 s
#include <sys/stat.h>

int main() {
        printf("%d\n", mkdir("/tmp/s", 777));
        printf("%d\n", chmod("/tmp/s", 01777));
        return 0;
}
drwxrwxrwt  2 xhe  users 4096 Oct  2 13:10 s

So your lite lib needs to be fixed like(also other functions about perm):

static inline int makedir(const char *path, mode_t mode)
{
        if (mkdir(path, mode) && errno != EEXIST)
                return -1;
        if (chmod(path, mode))
                return -1;
        return 0;
}

Regression in getty on mpc85xx after #50

The fix for issue #50 caused a regression on mpc85xx systems (Freescale PowerPC 8250 driver)
causing garbled output as soon as the built-in getty starts.

The following patch by @mattiaswal fixes the problem and seems to work fine on x86, ARM and PPC.

diff --git a/getty.c b/getty.c
index cfff72a..e781dd5 100644
--- a/getty.c
+++ b/getty.c
@@ -77,7 +77,7 @@ static void stty(int fd, speed_t speed)
        tcflush(fd, TCIOFLUSH);
 
        /* Disable modem specific flags */
-       term.c_cflag     &= (0|CSTOPB|PARENB|PARODD);
+       term.c_cflag     &= ~(0|CSTOPB|PARENB|PARODD);
        term.c_cflag     &= ~CRTSCTS;
        term.c_cflag     |= CLOCAL;

add a way to use log_silent or not

long time no see, :)

I've updated to the latest finit now, and found all the log has gone due to log_silent(). log_silent() may be good when you have a stable environment, but when not, i need those logs to know what happened. It should not only be available when you compile it in debug, not so convenient. Especially i thought i was in a stable env, but i just failed to boot and i dont know what happened.

some idea:

  1. add a flag in finit.conf
  2. maybe check /proc/cmdline for quiet and use it as a flag for finit

Template .conf files for built-in inetd services

For ease of use, it would be neat to be able to, e.g.:

initctl add inetd echo

To start an echo server.


From TODO:

  • Solaris SMF (Service Management Facility) has some interesting features that may be well worth looking into adopting:

       svcs enable -rt svc:/network/ssh:default
    

    That is: (r)esolve dependencies and only enable ssh (t)emporary iin the default runlevel when networking is available.

  • initctl add /sbin/service -n -- Service description, for details #69 (comment)

Add support for soft dependencies

Real life example: user starts lldpd and is happy. A few days later user starts snmpd and wants to be equally happy, but snmpd was never a requirement for lldpd to run so user is no longer happy because expected lldpd to restart and connect to snmpd over Agent-X protocol.

This issue details a feature request to Finit for "soft dependencies" to service stanzas. The idea is, as laid out in the ingress, to be allowed to start a daemon without a soft dependency but to restart it if a soft dependency is introduced. This could maybe be realized by simply inspecting the registered services, if a dependency is not registered, then simply ignore the dependency the user knows best after all, but if it is registered then take it into account like anything else.

Example:

service [2345] <pid/snmpd> /sbin/lldpd -- IEEE 802.1AB LLDP daemon

When snmpd is not an enabled service this results in:

service [2345] /sbin/lldpd -- IEEE 802.1AB LLDP daemon

When snmpd is enabled, and initctl reload is called, lldpd is also updated to become:

service [2345] <pid/snmpd> /sbin/lldpd -- IEEE 802.1AB LLDP daemon

Bootmisc plugin does not set up /var/lock/subsys before dbus plugin runs

I am using Buildroot to build an embedded Linux system. The rootfs filesystem does not create the directory subsys in /var/lock. Actually, it is only created if a user-space process like dbus is started. As finit is the first process, the directory /var/lock/subsys does not yet exist and finit throws an error:

finit: Failed creating directory /var/lock/subsys/messagebus: No such file or directory

EDIT: Note that /var/lock is a symlink to /tmp.

Remove old startx and user .conf directives

Original subject: respect user configurations in passwd, allow Xorg.wrap to start as non-root by default

I recently set finit to startx, i met two points, where i think we should do sth. (copied from #76)

  1. USER and SHELL env vars when start service: It's not a login shell, so finit invoked /bin/sh(dash) rather than /bin/bash which is configured to the default one. I am think about if it's better to set SHELL, not only to respect user configuration, but also respect the configuration like setting shell to /bin/nologin to prevent possible attacks. And i have learned that USER was also provided, better compatibility, not so bad.

  2. startx is an alias to service, so it's not a login shell, in another word, it's not a console. Xorg.wrap defaults only to allow console users to non-root-start. It's absolutely a good idea to make it console instead set 'allow_users = anybody` in config file. But, i dont know if it's possible.

Add basic watchdog support with API

In the watchdogd project there is a need to be able to register with Finit in such a way that it can
delegate the actual reboot to a WDT chip, with fallback to kernel reboot(), after a safe shutdown.

This would best be implemented as a built-in watchdog plugin, in Finit, that can register itself as
a default watchdog daemon.

<net/*> conditions turns to flux state after config reload

Looks like there is a bug in netlink plugin. In troglos VM, after initctl reload both of net/* conditions are turned to flux state:

~ # initctl cond | grep net
124     /sbin/dropbear        on      <+net/eth0/up,+net/route/default>
~ # initctl reload
~ # initctl cond | grep net
124     /sbin/dropbear        flux    <~net/eth0/up,~net/route/default>
~ #

AFAIU netlink plugin should handle this and reset those conditions.

Failed connecting to shared memory, error 38: Function not implemented

I am trying finit on a Banana Pro board using Buildroot (Linux 4.13.4).
Using latest finit commit 9d9dc74.
Running Linux system on a SD-card.

[    2.172219] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    2.180407] VFS: Mounted root (ext4 filesystem) readonly on device 179:2.
[    2.187794] devtmpfs: mounted
[    2.191904] Freeing unused kernel memory: 1024K
[    2.719908] EXT4-fs (mmcblk0p2): re-mounted. Opts: data=ordered
/usr/sbin/finit: Failed connecting to shared memory, error 38: Function not implemented
[    2.804870] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
[    2.804870] 
[    2.814011] CPU: 1 PID: 1 Comm: finit Not tainted 4.13.4 #2
[    2.819575] Hardware name: Allwinner sun7i (A20) Family
[    2.824829] [<c010e46c>] (unwind_backtrace) from [<c010b194>] (show_stack+0x10/0x14)
[    2.832571] [<c010b194>] (show_stack) from [<c0624994>] (dump_stack+0x84/0x98)
[    2.839793] [<c0624994>] (dump_stack) from [<c011b4e8>] (panic+0xdc/0x248)
[    2.846665] [<c011b4e8>] (panic) from [<c011e008>] (do_exit+0xa64/0xa94)
[    2.853363] [<c011e008>] (do_exit) from [<c011ee04>] (do_group_exit+0x3c/0xd0)
[    2.860579] [<c011ee04>] (do_group_exit) from [<c011eea8>] (__wake_up_parent+0x0/0x18)
[    2.868498] CPU0: stopping
[    2.871209] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.13.4 #2
[    2.877119] Hardware name: Allwinner sun7i (A20) Family
[    2.882347] [<c010e46c>] (unwind_backtrace) from [<c010b194>] (show_stack+0x10/0x14)
[    2.890087] [<c010b194>] (show_stack) from [<c0624994>] (dump_stack+0x84/0x98)
[    2.897304] [<c0624994>] (dump_stack) from [<c010d774>] (handle_IPI+0x170/0x190)
[    2.904693] [<c010d774>] (handle_IPI) from [<c01014dc>] (gic_handle_irq+0x8c/0x90)
[    2.912256] [<c01014dc>] (gic_handle_irq) from [<c010bccc>] (__irq_svc+0x6c/0x90)
[    2.919728] Exception stack(0xc0a01f48 to 0xc0a01f90)
[    2.924776] 1f40:                   00000000 00001364 2ee75000 c0116fc0 c0a00000 c0a03cb4
[    2.932945] 1f60: c0a03c68 c0a59592 c0a60700 c0937a28 ef7e1f40 00000000 2ee75000 c0a01f98
[    2.941110] 1f80: c0107f68 c0107f6c 60000013 ffffffff
[    2.946160] [<c010bccc>] (__irq_svc) from [<c0107f6c>] (arch_cpu_idle+0x38/0x3c)
[    2.953553] [<c0107f6c>] (arch_cpu_idle) from [<c014f6d8>] (do_idle+0xc0/0x138)
[    2.960858] [<c014f6d8>] (do_idle) from [<c014f9b8>] (cpu_startup_entry+0x18/0x1c)
[    2.968426] [<c014f9b8>] (cpu_startup_entry) from [<c0900c54>] (start_kernel+0x374/0x380)
[    2.976600] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00
[    2.976600]

Need ability to set up commands to run in response to hooks in finit.conf

This is just an idea that I would find useful.

For an embedded system I am working, I need to run a script that checks and attaches a UBIFS volume before "/bin/mount -na" is called.
In /etc/fstab, I created an entry that will mount the UBIFS volume and if the volume is not attached, the mount will fail.

To accomplish this, I currently have two options:

  1. Patch finit.c to call a hard coded script, or run some hard coded commands, before "/bin/mount -na" (or before plugins are called for HOOK_ROOTFS_UP)
  2. Create a plugin to call my script in response to HOOK_ROOTFS_UP

I am probably going to use option 2 for this project.

However in the future, it would be a lot easier if you could do simple things like that right from finit.conf.
For example:

hooktask [ROOTFS_UP] /sbin/attachubi.sh   # run in parallel with other hook commands
hookrun [NETWORK_UP] /sbin/dosomething.sh    # run in sequence with other hook commands

This feature could probably be implemented as an internal plugin. It would need tighter integration in the conf file parsing code, unlike normal plugins. There could be options in the configure script as well, to enable/disable this feature.

Finally... thanks again for all the work you do on finit!
All the best.

After --enable-watchdog, reboot -p rebooted my pc instead of down

Hmm...Without this option, works normally. Have no ideas about whether it's my specific problem(musl, or my configs). Or it's indeed a bug of finit. I'll take a look tomorrow, time to bed... I'll close the issue if it's on my own or post a patch. Also, you can do it yourself if you cloud see this while i'm sleeping. 😄

Support for nested fs

Currently its not possible for finit to mount nested FS, like a cryptsetup LUKS parition with a LVM PV.
Also I think the reverse is also possible.

Guess this needs a cryptsetup and a lvm plugin and some nesting logic.

sig_unblock: lacks unblocking of segv

Open a new issue since it's not the same issue! Comment on issue50 has been deleted.

I infer from this that you suppose to block SIGSEGV only on services. But actually sig_unblock did not unblock SIGSEGV, though you commented that it will unblock all signals when starting children.

 	uev_signal_init(ctx, &sigchld_watcher, sigchld_cb, NULL, SIGCHLD);
 
 	/* Trap SIGSEGV in case service callbacks crash */
	uev_signal_init(ctx, &sigsegv_watcher, sigsegv_cb, NULL, SIGSEGV);
 
 	/* Stopping init is a bit tricky. */
 	uev_signal_init(ctx, &sigstop_watcher, sigstop_cb, NULL, SIGSTOP);

And this is my temporary patch.

--- sig.c	2016-11-27 04:05:25.281957561 +0000
+++ b/sig.c	2016-11-27 04:05:25.281957561 +0000
@@ -355,6 +355,7 @@
 	sigaddset(&nmask, SIGTERM);
 	sigaddset(&nmask, SIGUSR1);
 	sigaddset(&nmask, SIGUSR2);
+	sigaddset(&nmask, SIGSEGV);
 	sigprocmask(SIG_UNBLOCK, &nmask, NULL);
 
 	/* Reset signal handlers that were set by the parent process */
--- service.c	2016-11-27 04:05:25.281957561 +0000
+++ b/service.c	2016-11-27 04:05:25.281957561 +0000
@@ -143,7 +143,7 @@
 {
 	int i, result = 0;
 	pid_t pid;
-	sigset_t nmask, omask;
+	sigset_t nmask, omask, segvmask;
 
 	if (!svc)
 		return 1;
@@ -190,6 +190,9 @@
 	sigaddset(&nmask, SIGCHLD);
 	sigprocmask(SIG_BLOCK, &nmask, &omask);
 
+	sigemptyset(&segvmask);
+	sigaddset(&segvmask, SIGSEGV);
+
 	pid = fork();
 	if (pid == 0) {
 		int status;
@@ -260,6 +263,8 @@
 
 				/* Reset signals */
 				sig_unblock();
+				/* Reblock segv */
+				sigprocmask(SIG_BLOCK, &segvmask, NULL);
 
 				execlp("logger", "logger", "-t", svc->cmd, "-p", "daemon.info", NULL);
 				_exit(0);
@@ -280,6 +285,8 @@
 		}
 	logger_err:
 		sig_unblock();
+		/* Reblock segv */
+		sigprocmask(SIG_BLOCK, &segvmask, NULL);
 
 		if (svc->inetd.cmd)
 			status = svc->inetd.cmd(svc->inetd.type);

Zombie processes and cant reboot/shutdown when --enable-emergency-shell

Me again :).

In short, processes that invoked fork() are likely to be Z. Processes closed manually was the same. And by reboot, i mean i can execute the reboot command, but no shutdown progress was shown, no reaction.

I have checked the corresponding the code, and i guess, finit.c:212 if (pid != 0) and finit.c:213 waitpid(0... should be the solution. Because emergency shell should start right after the crash in my view. So some undefined behavior was executed unexpectedly, that's what i though.

That's all.

finit doesn't register input from keyboard

From commit 510b53e to 3f15090 finit doesn't register any keys at all, so basically at the login prompt I can not login. I have custom musl based linux distribution using finit as primary init system and I'm happy to say that it works nice and fast. Thank you for the good work!

initctl ignores nonexistent services

Hi,
while digging in finit and troglos, I found that initctl start/stop any_nonexistent_service_name just exits without any error:

~ # initctl start nonexistent-service
~ # echo $?
0

I don't think it is a good idea. Do you have any plans to add some warnings and make initctl return non-zero exit code in such situation?

Building with --enable-rw-rootfs fails

If you configure with --enable-rw-rootfs make fails as follows:

service.o: In function service_start': service.c:(.text+0x608): undefined reference togetuser'
collect2: error: ld returned 1 exit status
common.mk:22: recipe for target 'finit' failed
make: *** [finit] Error 1

External getty does not support agetty syntax

sorry, i am already in my bed. In short, agetty ask for ttyX instead of /dev/ttyX. finit told me it didn't find device, any plan on supporting agetty? though your builtin one is enough for me, just let you know. gotta sleep, see you..

initctl runlevel does not update UTMP

Using initctl runlevel LVL to change runlevel does not seem to update UTMP, so the UNIX runlevel command reports the previous runlevel.

(Maybe the runlevel wasn't really changed?)

User should be able to set up hotplug from finit.conf

On an embedded system I am working on, I patched finit to enable kernel hotplugging to use busybox mdev.

Right after the call to banner() in main(), I inserted the following code:

#ifdef EMBEDDED_SYSTEM
    fp = fopen("/proc/sys/kernel/hotplug", "w");
    print_desc("", "Enabling hotplug");
    if (fp) {
        fputs("/sbin/mdev", fp);
        fclose(fp);
        print_result(0);
    }
    else {
        print_result(1);
    }
#endif

This is a hacky solution suitable for my needs, but possibly other embedded users may find something similar useful in their work.

Finally, as always, thanks for your work on finit!

Make inetd optional

In my case I don't see myself using inetd in the system/distro I'm building.

Let's make it a compile time optional feature :)

utmp: logs are not rotated

Seen on: finit-3.0-rc2

On a system with the issue described in issue #56 I noticed that the utmp/wtmp logs are not being rotated. My ramfs backing /var was filled (4M) in a few minutes. Even though the tty-issue itself has been fixed, the system could still potentially fill up /var after enough logins.

Suggestion: logrotate(8) these files.

Add support for reloading TTYs on event

As of #56 Finit no longer tries to start a non-existing TTY. It would be helpful though if the TTY could be restarted on a kernel event. E.g., triggered by an mdev script: initctl ttyN reload, or similar.

Idea by @wkz

Add support building finit statically

Is it possible to build finit statically? I've had a few attempts but I don't think the Makefile(s) currently make this very easy at the moment...

Allow vendor service file that are not enabled by default

Hi,

referring to the discussion in #69 a way to provide some service definition without automatically enabling it would be nice.

Traditional inits use a file based approach for that: if a symlink to the actual config is found in a runlevel/target specific directory the service will be enabled.

This is "UNIX way" and its easy for a Distro to provide those files, and have a script to either enable the service on install or use a *ctl tool to do it.

The other idea mentioned in #69 (to use a command to create the file) is also possible but not that easy.

Also it might be an idea to have a "override" feature so files in /etc/finit.d will override those in /usr/lib/finit.d which would be difficult with the command.

Allow a fallback shell in debug mode instead of crashing

When bringing up a new system with Finit it would be greatly helpful if Finit did not crash or cause a reboot when encountering a problem, but instead fall back to /bin/sh

This should probably be guarded with a --enable-fallback-shell to the configure script so production code does not have this by default. Possibly also guard this by the debug flag.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.