Commit Graph
1477 Commits
Author SHA1 Message Date
Joachim Nilsson 2b9eecbef3 Spell check and mention use of logger tool in service stanza
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-29 17:17:21 +01:00
Joachim Nilsson b8190c8a2a Refactor, move speed parser from getty() to prepare_tty()
This patch relocates the speed parser so that exec.c can set the TTY
speed properly as soon as possible.  For external getty we make sure
to not touch the TTY speed.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-29 16:53:26 +01:00
Joachim Nilsson adb4670d2f Clear current line before printing \nPlease press Enter ...
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-29 16:52:14 +01:00
Joachim Nilsson d31575538c getty: Disable VINTR + VEOF, re-enable before calling /bin/login
This patch makes the Finit built-in getty behave a bit more like other
getty implementations.  We now not only disable ISIG but also VEOF and
VINTR when prearing the TTY for the getty (built-in or external).

Like before, it is up to the getty process to leave the TTY in a
usable state to /bin/login, so we also move the stty() call to
just before calling /bin/login in getty.c

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-29 16:11:59 +01:00
Joachim Nilsson faf0c680b8 getty: Disable ECHO, XON/OFF while waiting for initial <CR>
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-29 12:14:04 +01:00
Joachim Nilsson 250e26f2f6 Fix #84: Reset TTY w/ stty() before taking any pre-getty action
This patch moves the stty() function from getty.c to a separate file so
it can be called from exec.c as well.  The fix to #84 is simply to call
stty() in prepare_tty(), which is shared by run_getty() and run_getty2()
and called before "Please press Enter ...".

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-29 11:59:48 +01:00
Joachim Nilsson b45c3d5cb8 timespec_newer(): time a should be > or >= to b
Time comparision should be >= not just >.  May seem a bit silly to
nitpick like this since we're comparing nano seconds, but on systems
with no high-res timers this happens more often than you would like.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-24 16:04:18 +02:00
Joachim Nilsson 6b2678c2ed pidfile: On HOOK_SVC_RECONF the netlink plugin must run first
When performing an `initctl reload` with one (unchanged) service
depending on, e.g. `net/iface/lo`, its condition will not be set
to ON by the pidfile plugin unless the netlink plugin hook runs
first.

Example:

    service <net/iface/lo> /sbin/dropbear ...

Which provides the <svc/sbin/dropbear> condition, will not be
set by pidfile.so during `initctl reload` because dropbear is
still SIGSTP:ed waiting for <net/iface/lo>.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-24 15:55:35 +02:00
Joachim Nilsson 0d6f203e0b tty_reload(): When reloading a single TTY dev, remember to clean it
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-24 13:48:25 +02:00
Joachim Nilsson 781ba66905 Revert "Remove reconf condition when .conf reload completes"
This reverts commit 06479aa5f1.
2017-10-24 13:07:48 +02:00
Joachim Nilsson 9a97ab29dc Revert "cond_reassert(): Use cond_set_path(), not cond_clear(), for reconf"
This reverts commit afb3fada50.
2017-10-24 13:07:15 +02:00
Joachim Nilsson b2b17ea4fb doc/config.md: Document new tty @console support in finit.conf
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-23 19:30:24 +02:00
Joachim Nilsson bfa99266e7 Minor, cleanup old unused function prototype
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-23 19:30:04 +02:00
Joachim Nilsson c76a58ef7a Remove long since deprecated finit.conf: console <DEV> support
All this code did was trigger prctl() to set process name to "console",
which you could use as a simple means of figuring out if a process was
started from the system console.

There are other ways to do this, which Finit should not be involved in.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-23 19:28:11 +02:00
Joachim Nilsson 51c5f3cbfa Length of the ANSI escaped runlevels string is 20 chars, need 21
Problem reported by @wkz

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-23 19:20:25 +02:00
Joachim Nilsson a6290da210 screen_init(): Verify that STDOUT is a TTY
Before we call screen_init(), which in turn calls libite:initscr(),
which in turn does a lot of tcgetattr() and termios to STDOUT to figure
out the size, we need to check that we're not backgrounded, or don't
actually have a TTY.  Problem reported by @wkz

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-23 19:16:51 +02:00
Joachim Nilsson 949f02eff4 tty: Add support for auto-detecting serial console from SysFS
This patch adds support for a new TTY device keyword `@console` which
auto-detects the system console by reading the SysFS file:

    /sys/class/tty/console/active

Embedded systems with one of /dev/ttyAMA0, /tty/ttyMXC0 or the original
/dev/ttyS0, as their active serial console can now instead use a single
line to /etc/finit.d/getty.conf to start the built-in getty on the same
TTY as the kernel already runs on:

    tty [12345789] @console 115200 noclear

With no TTY defined Finit will either do nothing (default), or start a
fallback shell if enabled in the configure script.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-23 17:24:46 +02:00
Joachim Nilsson 7970e45f45 Follow-up to cf60cdd, make sure to disable ISIG before calling getty
Disable INTR, QUIT, SUSP, and DSUSP while handing over to getty.  It is
up to the getty process to allow ISIG again.

This patch is due to the differences in control line setup between ARM,
x86/x86_64, and most notably PPC.  PPC in particular seem to have ISIG
set by default from the kernel.

Without this patch pressing Ctrl-C before getty is started will lead to
Finit receiving SIGINT and defaulting to a reboot, as introduced in the
BusyBox init signal adoption in eeb59eb.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-23 11:57:58 +02:00
Joachim Nilsson a36dafaa6c README: Update initctl usage
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-19 20:16:37 +02:00
Joachim Nilsson c092d22d48 initctl: Default to show services listing, not usage text
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-19 20:01:15 +02:00
Joachim Nilsson e4401f92ad Bump version for v3.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
3.0
2017-10-19 09:58:05 +02:00
Joachim Nilsson 0197a9427c Update ChangeLog for v3.0 release
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-19 09:58:05 +02:00
Joachim Nilsson 49481053a4 Fix GCC 7 string truncation warning, too small temporary buffer
In GCC 7 the -Wall infers the new -Wformat-truncation which finds
problems with string truncation in functions like snprintf().

This patch suppresses the warning by allowing only a subset of the
parent inetd service description to be copied to the child connection.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-19 09:58:05 +02:00
Joachim Nilsson 13887f323a Fix GCC 7 string truncation warning, too small temporary buffer
In GCC 7 the -Wall infers the new -Wformat-truncation which finds
problems with string truncation in functions like snprintf().

This patch fixes a possibly problem in path name creation which,
combined with the scandir() function, might cause loss of .conf
files, failure to call run-parts properly, and kill services at
shutdown.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-19 09:58:05 +02:00
Joachim Nilsson faca84a590 Fix GCC 7 string truncation warning, too small temporary buffer
In GCC 7 the -Wall infers the new -Wformat-truncation which finds
problems with string truncation in functions like snprintf().

This patch fixes a problem in condition parsing for very long
PID filenames which might be truncated in internal buffers
causing a mismatch in Finit condition tracking.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-19 09:58:05 +02:00
Joachim Nilsson 920df09cd5 Fix GCC 7 warning, convert "Fall through" to "fallthrough" comment
In GCC 7 the -Wextra infers the new -Wimplicit-fallthrough which can be
suppressed by adding a simple comment

    /* fallthrough */

Which we had, but was too verbose (and misspelled) for GCC to notice.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-19 09:58:05 +02:00
Joachim Nilsson 3e71d43bff Follow-up to 22192ac, missing semicolon
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 23:19:41 +02:00
Joachim Nilsson 5c3a07e8e6 tty_exist(): Simplify, no need to call access() and then open()
Found by Coverity Scan, classified as security issue but was just
unnecessary overhead.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 23:06:04 +02:00
Joachim Nilsson 11dd877484 initctl: Fix possible divide by zero, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 23:01:07 +02:00
Joachim Nilsson 921fd1e363 service_start(): Don't fclose() invalid file pointer, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:58:31 +02:00
Joachim Nilsson f949017596 logrotate(): Ignore any error from rename(), file may not exist
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:57:18 +02:00
Joachim Nilsson 03a33fc0ee Check stat() return value, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:56:02 +02:00
Joachim Nilsson 22192acce4 initctl: Make sure to NUL terminate info string from Finit
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:53:23 +02:00
Joachim Nilsson 500d301700 tty_unregister(): Fix possible out-of-bounds access, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:45:02 +02:00
Joachim Nilsson e8f26709e2 service_register(): Fix possible memory leak, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:41:13 +02:00
Joachim Nilsson 91b3e5eeb4 inetd: Fix possible tcp socket leaks, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:37:21 +02:00
Joachim Nilsson 71026adf03 tty_register(): Fix possible memory leak, found by Coverity Scan
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:32:26 +02:00
Joachim Nilsson 978beb8e7e Don't log if failed to remove non-existing condition
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 22:05:00 +02:00
Joachim Nilsson 3ef75ac176 debian: Mention the possibility to change the default init to Finit
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 21:49:19 +02:00
Joachim Nilsson 83b613581a void: Clean up README
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 21:48:58 +02:00
Joachim Nilsson d4c28f87d1 void: Update installation instruction, recommend manual edit of grub
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 19:15:28 +02:00
Joachim Nilsson 5b53f001a2 Revert parts of c2bf7d3, core-services scripts not executable
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 11:24:29 +02:00
Joachim Nilsson f1c9581da9 service_start(): Must set GID before dropping user privs, obvs
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 11:05:59 +02:00
Joachim Nilsson 5301bcb4f1 void: Drop-privs to correct @username:group
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:51:39 +02:00
Joachim Nilsson c2bf7d3a50 void: Call runit core startup scripts using run-parts at bootstrap
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:30:21 +02:00
Joachim Nilsson 685771aef2 void: Simplify uuidd service description
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:29:53 +02:00
Joachim Nilsson 3ebb697910 Install a proper #!/bin/sh style rc.local on Void Linux
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:18:11 +02:00
Joachim Nilsson bacaea0e02 bootmisc: Fix misspelled uuidd
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:14:56 +02:00
Joachim Nilsson 07d6e69c30 bootmisc: Check return value from getgroup()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:10:13 +02:00
Joachim Nilsson d2053bd07d bootmisc: Follow-up to f4662d8
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-18 10:09:15 +02:00