Commit Graph

198 Commits

Author SHA1 Message Date
Denys Vlasenko
871bd2abac examples/var_service: add /var/run flag file to ntp.script
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-26 13:45:33 +02:00
Denys Vlasenko
14339191af examples/var_service/: use standard logger script, viewer and pager scripts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-03 23:23:09 +02:00
Denys Vlasenko
aa75a7da7f examples/var_service/: use "svc" for service commands, other tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-07-03 17:02:50 +02:00
Denys Vlasenko
e56e091d65 examples: update /var/service/getty for Unicode ttys
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-23 13:55:13 +02:00
Denys Vlasenko
a40a661d97 tweak /var/service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-05-20 22:43:42 +02:00
Denys Vlasenko
c21dfaf836 examples/shutdown-1.0: an example of reboot which does not signal init
For one, my inits know nothing about the concept of "shutting down the system".

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-20 15:12:52 +02:00
Denys Vlasenko
816d8d7a66 setlogcons: open /dev/ttyN for "setlogcons N", not /dev/tty1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-16 21:48:32 +02:00
Denys Vlasenko
266f6f1973 udhcp: support string user options, closes 10946
function                                             old     new   delta
udhcp_str2optset                                     536     628     +92
packed_usage                                       32757   32760      +3
udhcpc_main                                         2708    2692     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 95/-16)             Total: 79 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-13 13:27:52 +02:00
Denys Vlasenko
df65dc89b4 examples/var_service: new example: dnsmasq service
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30 20:49:16 +02:00
Denys Vlasenko
0d79d7709d svok: new applet (daemontools compat)
function                                             old     new   delta
svok_main                                              -     127    +127
packed_usage                                       32705   32757     +52
applet_names                                        2756    2761      +5
applet_main                                         1588    1592      +4
bb_banner                                             46      47      +1
sv                                                  1286    1284      -2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/1 up/down: 189/-2)            Total: 187 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30 20:02:33 +02:00
Denys Vlasenko
d892f7137f ifplugd service example: always run up/down script on startup
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-30 11:14:46 +02:00
Denys Vlasenko
3293bc1469 udhcpd: fix "not dying on SIGTERM"
Fixes:
	commit 52a515d187
	"udhcp: use poll() instead of select()"
	Feb 16 2017

udhcp_sp_read() is meant to check whether signal pipe indeed has some data to read.
In the above commit, it was changed as follows:

-	if (!FD_ISSET(signal_pipe.rd, rfds))
+	if (!pfds[0].revents)
		return 0;

The problem is, the check was working for select() purely by accident.
Caught signal interrupts select()/poll() syscalls, they return with EINTR
(regardless of SA_RESTART flag in sigaction). _Then_ signal handler is invoked.
IOW: they can't see any changes to fd state caused by signal haldler
(in our case, signal handler makes signal pipe ready to be read).

For select(), it means that rfds[] bit array is unmodified, bit of signal
pipe's read fd is still set, and the above check "works": it thinks select()
says there is data to read.

This accident does not work for poll(): .revents stays clear, and we do not
try reading signal pipe as we should. In udhcpd, we fall through and block
in socket read. Further SIGTERM signals simply cause socket read to be
interrupted and then restarted (since SIGTERM handler has SA_RESTART=1).

Fixing this as follows: remove the check altogether. Set signal pipe read fd
to nonblocking mode. Always read it in udhcp_sp_read().
If read fails, assume it's EAGAIN and return 0 ("no signal seen").

udhcpd avoids reading signal pipe on every recvd packet by looping if EINTR
(using safe_poll()) - thus ensuring we have correct .revents for all fds -
and calling udhcp_sp_read() only if pfds[0].revents!=0.

udhcpc performs much fewer reads (typically it sleeps >99.999% of the time),
there is no need to optimize it: can call udhcp_sp_read() after each poll
unconditionally.

To robustify socket reads, unconditionally set pfds[1].revents=0
in udhcp_sp_fd_set() (which is before poll), and check it before reading
network socket in udhcpd.

TODO:
This might still fail: if pfds[1].revents=POLLIN, socket read may still block.
There are rare cases when select/poll indicates that data can be read,
but then actual read still blocks (one such case is UDP packets with
wrong checksum). General advise is, if you use a poll/select loop,
keep all your fds nonblocking.
Maybe we should also do that to our network sockets?

function                                             old     new   delta
udhcp_sp_setup                                        55      65     +10
udhcp_sp_fd_set                                       54      60      +6
udhcp_sp_read                                         46      36     -10
udhcpd_main                                         1451    1437     -14
udhcpc_main                                         2723    2708     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/3 up/down: 16/-39)            Total: -23 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-03-10 19:34:39 +01:00
Denys Vlasenko
2e01eec4d3 tweak examples/var_service/*
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-27 12:53:20 +02:00
Denys Vlasenko
08dfafc437 fix more instances of ": $((a++))" in shell scripts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-15 19:20:45 +02:00
Denys Vlasenko
10ad622dc2 Spelling fixes in comments, documentation, tests and examples
By klemens <ka7@github.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-17 16:13:32 +02:00
Denys Vlasenko
9c192e7f94 examples: make udhcpc script handle /32 netmasks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-04-06 00:53:43 +02:00
Denys Vlasenko
bca4ea8b68 remove "local" bashism from a few scripts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-24 20:52:42 +01:00
Tito Ragusa
d3720828ea README_distro_proposal.txt: typo fixes
Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-03 12:25:18 +01:00
Denys Vlasenko
96f1d6b70c Update to examples/var_service/README_distro_proposal.txt
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-25 20:41:00 +01:00
Mike Frysinger
2098c3511c mdev.conf: rename hw_random to hwrng
The kernel broke the name years ago, but didn't notice until it was much
too late.  Rename the node to match expectations of userland software,
and what the kernel itself documents in its Kconfig help:
	This provides a device that's usually called /dev/hwrng, ...

URL: https://marc.info/?l=linux-crypto-vger&m=144249767024990&w=2
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-12-09 16:12:15 -05:00
Denys Vlasenko
fdb4421e00 README_distro_proposal.txt: writeup about runit adoption
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-03 14:06:55 +01:00
Denys Vlasenko
6bbb48fadf examples: update var_service/README again
Added "ps -AH e" example

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 19:02:11 +02:00
Denys Vlasenko
e43000f2d4 typo fixes in doc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:48:05 +02:00
Denys Vlasenko
93ff2b4b5f examples: update var_service/README again
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:38:08 +02:00
Denys Vlasenko
ee2d19445b examples: update var_service/README
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-14 18:22:50 +02:00
Denys Vlasenko
095ddf7669 examples: add example of a DHCP server
As usual, by multiplying directories - "dhcpd_eth0", "dhcpd_wlan1"
you can run many servers on different interfaces.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-10-03 23:43:44 +02:00
Denys Vlasenko
dea3bdbefe examples: wpa_supplicant.conf has a wrong field deleted in examples
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-26 20:47:17 +02:00
Denys Vlasenko
d8330ca4a4 examples/var_service/supplicant_if: new service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-20 18:09:00 +02:00
Denys Vlasenko
6b5abc9596 service/fw example: do not ruin $if[], use different name
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-30 22:29:10 +02:00
Denys Vlasenko
3191ec7cce var_service/fw: optionally flush all netdevs; optionally prefer one 0/0 routing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-25 16:28:57 +02:00
Denys Vlasenko
f6348e50ef examples: add a useful "see abridged log" script for ntpd service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-10 20:15:28 +02:00
Mike Frysinger
d7d4750e1e unrpm: clean up
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-04-04 01:39:17 -04:00
Mike Frysinger
ee22fe8793 undeb: clean up
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-04-04 01:35:34 -04:00
Denys Vlasenko
bf1866c183 tweak zcip service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 18:57:32 +02:00
Denys Vlasenko
1a1cfedbef Tweak README
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 14:58:58 +02:00
Denys Vlasenko
4f8ecf273c update network service examples
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 14:55:33 +02:00
Denys Vlasenko
d32a1a4054 New example of a service: examples/var_service/zcip_if
Zeroconf for IPv4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-24 05:30:58 +02:00
Denys Vlasenko
5251135bc1 better pinger service example
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-15 02:10:11 +02:00
Denys Vlasenko
e0ddb65cb2 build system: make CONFIG_EXTRA_LDFLAGS go to LDFLAGS, not EXTRA_LDFLAGS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-14 14:15:15 +02:00
Denys Vlasenko
1186894f77 update example ntp.script
Handle an interesting corner case when NTP server is reachable...
but on a different IP now.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-31 22:00:55 +02:00
Denys Vlasenko
a03195941b examples/mdev_fat.conf: document that newer mdev exposes path
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-02-07 18:14:39 +01:00
Denys Vlasenko
192c14bd87 Improve examples/var_service READMEs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-02-21 12:55:43 +01:00
Denys Vlasenko
2e66daca65 examples/udhcp: do not rewrite resolv.conf if no DNS servers. Closes 6788
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-01-13 13:38:53 +01:00
Denys Vlasenko
2df1c64f38 examples/mdev.conf.change_blockdev.sh: update
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-02 13:26:24 +02:00
Denys Vlasenko
e306c11367 examples: add mdev example for Android phone
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-30 16:23:12 +01:00
Denys Vlasenko
2c0508b4fa examples/inittab: fix a few incorrect statements about init
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-29 14:35:44 +01:00
Mike Frysinger
bca5c556c4 udhcpc: use readlink rather than realpath
The realpath utility requires all paths exist when canonicalizing
symlinks.  If /etc/resolv.conf points to a tmpfs, then it might
not exist initially.  Use `readlink -f` so that we follow all
symlinks that are available.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-03-12 10:48:09 -04:00
Denys Vlasenko
5bce135e36 mdev: improve $SEQ handling; improve debug logging
Sequential run of concurrent mdev's was too simplistic:
they waited for /dev/mdev.seq to match. This could sometimes
cause cumulative loss of time on the order of a second.

Added SIGCHLD signaling from exiting mdev to all other mdev's.
Added debugging required to see that code actually works as intended.

Example of /dev/mdev.log (with "woken up" elevated from dbg lvl 3 to 2):

mdev[1023]: first seq written
     ^^^^ seq, not pid
mdev[1023]: 35.022395 ACTION:add SUBSYSTEM:module DEVNAME:(null) DEVPATH:/module/lib80211
mdev[1023]: rule matched, line -1
                          ^^^^^^^ means "default rule"
mdev[1023]: 35.022676 exiting
            ^^^^^^^^^ second,usec timestamp
mdev[1024]: 35.069691 ACTION:add SUBSYSTEM:vc DEVNAME:vcs9 DEVPATH:/devices/virtual/vc/vcs9
mdev[1024]: dev 7,9
mdev[1025]: 35.069889 waiting for '1024'
mdev[1026]: 35.069946 waiting for '1024'
mdev[1027]: 35.070151 waiting for '1024'
mdev[1024]: rule matched, line -1
mdev[1024]: mknod vcs9 (7,9) 20660 0:0
mdev[1024]: 35.070346 exiting
mdev[1025]: woken up
mdev[1026]: woken up
mdev[1025]: 35.071213 ACTION:add SUBSYSTEM:vc DEVNAME:vcsa9 DEVPATH:/devices/virtual/vc/vcsa9
            ^^^^^^^^^ took only a millisecond to start running after prev mdev exited
mdev[1025]: dev 7,137
mdev[1027]: woken up
mdev[1025]: rule matched, line -1
mdev[1025]: mknod vcsa9 (7,137) 20660 0:0
mdev[1025]: 35.072109 exiting

function                                             old     new   delta
mdev_main                                            849    1372    +523
curtime                                                -      59     +59
dirAction                                             87     134     +47
static.ts                                              -       8      +8
keywords                                              19      12      -7
make_device                                         2189    2119     -70

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-27 10:51:41 +01:00
Mike Frysinger
9fed24c031 udhcpc: tweak math shell style with the metric var
Some shells (like dash) are lame and omit the POSIX increment/decrement
feature (because it is listed as optional).  Tweak the shell script to
work in all POSIX variants.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-02-27 01:05:34 -05:00
Mike Frysinger
39b8fb41c5 udhcpc: support resolv.conf symlinks
Often it is desirable to have /etc/ be on read-only storage (well, the
whole rootfs) but have things like /etc/resolv.conf be symlinks to a
writable location.  Tweak the simple script to support that.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-02-27 01:01:43 -05:00