Commit Graph
36 Commits
Author SHA1 Message Date
Yaroslav Syrytsia 0a54a9624a Fix #123: Regression in sysv start/stop scripts
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-26 05:16:52 +01:00
Joachim Nilsson 4163527006 Fix run-parts regression introduced in 9a98bff2
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-03-09 14:29:04 +01:00
Joachim Nilsson 997a699b7e Add more debug logs for /etc/finit.d*/ inotify and exec_runtask()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-01-22 15:48:56 +01:00
Joachim Nilsson d1718d338e Set proper RAW mode for "Please press Enter to activate ..."
Also, while leading with a \n for the activation text and clearing the
line before getty is called, some getty implementations, e.g. BusyBox,
write an extra \n before printing /etc/issue.  For perfectionists that
want a single newline separating started services and the first line
of /etc/issue we now not only clear the line, we also move the cursor
one line up before handing over to getty.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-01-06 18:58:08 +01:00
Joachim Nilsson 58ade5d74e Allow built-in getty to show in ps as 'tty DEV'
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2020-01-06 18:52:40 +01:00
Joachim Nilsson 9a98bff23f Run all runparts scripts using /bin/sh -c foo
This patch is an attempt to address an issue with runparts scripts found
by Magnus Malm, @magnusmalm.  Any script in:

    runparts /foo/bar.d/

were required to have the #!/bin/sh she-bang, otherwise Finit would not
start them.  He tested with the standard run-parts tool, which had no
such restrictions.

The patch not only makes sure to start scripts using `/bin/sh -c`

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-10-18 22:19:51 +02:00
Joachim Nilsson e9670b87b3 Refactor, convert struct tty members to static strings
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2018-03-18 19:19:45 +01:00
Joachim Nilsson 72bc3b1a91 Fix #91: Add support for tty nologin, to start /bin/sh immediately
This patch adds a `nologin` flag to the `tty` configuration directive,
making it possible to set up really simple embedded systems with no
login.

Example, put the following line in `/etc/finit.d/getty.conf` to get
a "Please press Enter to ..." prompt before being presented with a
root shell prompt.

    tty [12345] @console noclear nologin

Needless to say, this is not very secure, but can be really useful
for developer setups, during board bringup, or similar.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-24 01:54:07 +01:00
Joachim Nilsson 5117b723c2 Minor, fix missing rlim2str() declaration
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-12-13 17:58:48 +01:00
Joachim Nilsson b68c5c1291 Fix #45: add support for rlimit per service/run/task/inetd/tty
This patch extends the existing rlimit implementation to support setting
limits per service, run/task, inetd, and tty.

Use rlimit in /etc/finit.conf to change the global setting, which is
then inherited to each /etc/finit.d/*.conf.  For each .conf file the
rlimit is reinitialized to the global finit.conf settings.

Also, add `unlimited` keyword, to replace the now deprecated `infinity`
keyword.  The latter is however kept, for compatibility with previous
releases, for the foreseeable future.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-26 16:35:37 +01:00
Joachim Nilsson cd73c1c951 Replace libite:fmode() with stat(), removed in libite v2
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-11-22 14:40:02 +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 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 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 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 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 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 f3a000560f exec_runtask(): Refactor, remove GLIBC:isms to build with musl
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-04 20:05:22 +02:00
Joachim Nilsson 684314db0f Allow pipe + redirect in task/run stanzas, exec() in /bin/sh
This patch extends the capabilities of task and run .conf stanzas by
enabling pipes and redirects.

Example:

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

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-04 16:00:49 +02:00
Joachim Nilsson 529b39ebba tty: Add 'noclear' + 'nowait' options to built-in and external tty's
This patch aligns the two tty configuration stanzas, thus clear and wait
are now the default for both.

    tty [LVLS] <DEV> [BAUD] [noclear] [nowait] [TERM]
    tty [LVLS] <CMD> <ARGS> [noclear] [nowait]

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-01 06:10:08 +02:00
Joachim Nilsson f029ba2111 Reorder functions a bit, group run_getty*() family
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-01 05:50:50 +02:00
Joachim Nilsson 277c3dbb14 getty: Remove TTY clear from built-in getty, delegate to run_getty()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-09-01 05:47:53 +02:00
Joachim Nilsson f273ecc135 Fix #79: Add 'nowait' option to tty setting, external getty
This patch makes it possible to disable the "Please press Enter" prompt
when using an external getty. Simply append `nowait` to the .conf entry
and Finit will spawn the getty immediately.

A future patch will add support for `noclear` as well to external getty,
as well as a change in default (=> `wait`) for the built-in getty.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-08-31 00:51:11 +02:00
Joachim Nilsson 675f82a6b9 run_getty2(): Minor fixes only, whitespace + cautionary _exit()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-08-27 16:41:58 +02:00
Joachim Nilsson 7c50d86a55 Restore pre built-in run_getty() as run_getty2()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-08-27 15:01:42 +02:00
Joachim Nilsson b629348973 Refactor TTY exec, prepare for external getty
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-08-27 15:00:43 +02:00
Joachim Nilsson e48901b90f tty: Clear tty before login: prompt by default, add 'noclear' option
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-08 15:31:59 +02:00
Joachim Nilsson cda5938215 helpers.c: New function, printv()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 12:43:41 +02:00
Joachim Nilsson 51e1a907e6 log.c: New log_is_debug() function, hide access to debug variable
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 12:40:50 +02:00
Joachim Nilsson e9d5512e1a Refactor, simplify ... print() APIs already check if silent
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-07-02 12:38:35 +02:00
Joachim Nilsson fff68b7b06 Relocate source files to an src/ subdirectory
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
2017-01-16 01:31:02 +01:00