Commit Graph
1492 Commits
Author SHA1 Message Date
Joachim Nilsson 5af1f05606 plugin: Only close() PID file descriptors >0, skip -1
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-14 14:34:08 +01:00
Joachim Nilsson fcdb5c2965 initctl: Refactor, reduce code duplication
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-12 22:58:50 +01:00
Joachim Nilsson af3e560d79 tty.c: Refactor, move LIST_REMOVE() to tty_unregister()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-12 21:33:22 +01:00
Joachim Nilsson b6e695b656 Bump required libuEv version to v2.0.0, with failure mode support
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-12 19:40:54 +01:00
Joachim Nilsson 123df18847 Travis-CI: Bump required libuEv version to v2.0
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-12 19:40:28 +01:00
Joachim Nilsson dae21d9d64 Simplify rlimit documentation a bit
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-12 19:18:32 +01:00
Joachim Nilsson bf4a0abe5c conf_parse_rlimit(): Refactor, replace 'new' with 'cfg'
'new' is a reserved keyword in C++, it is recommnded to avoid it also in C.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-12 14:57:22 +01:00
Joachim Nilsson 6826d7ee3f Handle event loop watcher failure modes
When alibuEv event watcher callback has `UEV_ERROR` in the events mask
we must handle the error.  Unfortunately, in most cases there is not
much we can do but ignore it or log the error.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-12 11:18:12 +01:00
Joachim Nilsson 168da2a5c6 plugin: Update list of available events for I/O plugins
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-12 02:47:33 +01:00
Joachim Nilsson c82dc54205 initctl: Minor refactor, handle errors first
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-12 02:46:19 +01:00
Joachim Nilsson eb0a759371 TTY: If parsing speed argument fails, do NOT default to B38400
If the speed argument to the `tty` stanza is invalid we should not
default to some other random speed.  Instead, leave the line speed
as-is, like we do when starting an external getty.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-02 10:48:04 +01:00
Joachim Nilsson 830abc1971 getty: Remove leading \n in do_issue(), not needed
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-31 20:57:36 +01:00
Joachim Nilsson 4c3a11131f Minor cleanup + use strlen() rather than sizeof() on const strings
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-31 20:56:48 +01:00
Joachim Nilsson 796701c854 getty: Ignore SIGINT & C:o earlier
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-31 20:54:56 +01:00
Joachim Nilsson ab760aa3ff Mention @console TTYs in top-level README
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-10-29 17:21:21 +01:00
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