Compare commits

...

190 Commits

Author SHA1 Message Date
Roy Marples
0298e4ffa0 Remove leading and trailing space on the ctrl_interface line. 2009-01-05 09:37:38 +00:00
Roy Marples
a063035b37 Make _SVNVER_SH more readable. 2009-01-02 22:51:47 +00:00
Roy Marples
213cef1739 Fix version for releases. 2009-01-02 16:48:42 +00:00
Roy Marples
386ee57432 Fix compile, #136 2009-01-02 15:11:15 +00:00
Roy Marples
631acff7aa Document the --chuid option. 2009-01-01 14:32:09 +00:00
Roy Marples
877a328179 dmesg and sysfs won't work in a vserver, #137 thanks to Hollow. 2009-01-01 14:27:29 +00:00
Roy Marples
1efa64cae8 Typo. 2008-12-30 19:08:51 +00:00
Roy Marples
22959c3963 Fix working on zsh 2008-12-30 00:05:17 +00:00
Roy Marples
2464f9e93b Add parens, #134 thanks to Matthias Schwarzott. 2008-12-29 23:06:22 +00:00
Roy Marples
d91201cb94 Skip all forcefsck checking when stopping, #134. 2008-12-28 15:25:40 +00:00
Roy Marples
1c5ec9d161 Fake get_bootparam function so that we don't check for kernel options forcefsck when doing an fsck on shutdown. 2008-12-28 14:49:07 +00:00
Roy Marples
f4b8366942 Parse retry schedule correctly, #129. Thanks to vaeth. 2008-12-28 14:05:33 +00:00
Roy Marples
438665357b Release 0.4.1 2008-12-23 10:45:16 +00:00
Roy Marples
7ad40abf64 Our error messages don't have full stops at the end 2008-12-23 10:42:25 +00:00
Roy Marples
7e12abe035 Typo. 2008-12-23 10:41:33 +00:00
Roy Marples
4dba5b1ff1 Disallow hotplug to run during sysinit, but allow elsewhere. Fixes #131. 2008-12-23 10:40:27 +00:00
Roy Marples
1ff289e305 Whitespace. 2008-12-23 10:39:45 +00:00
Roy Marples
53e2bec385 We should match on the correct args for stopping daemons when pidfiles
are not being used.
2008-12-23 10:15:41 +00:00
Roy Marples
9d9f17aa52 Allow working with the new ctrl_iface=DIR=foo directive. 2008-12-23 10:13:58 +00:00
Roy Marples
803dbbf0c8 Allow rc_runlevel/softlevel to set runlevel from kernel commandline. 2008-12-21 01:15:02 +00:00
Roy Marples
9e5e60f257 Store interactive mode after sysinit, #128 thanks to Matthias Schwarzott. 2008-12-13 22:20:21 +00:00
Roy Marples
6bf0289f33 Warn about stopping sysinit services, thanks to Matthias Schwarzott. Fixes #126. 2008-12-11 14:50:58 +00:00
Roy Marples
bdb3485b49 Punt redundant dirs from git mirgation. 2008-12-07 08:38:16 +00:00
Roy Marples
eb6daeca43 Fix dist for svn 2008-12-07 07:51:40 +00:00
Roy Marples
10e88090f6 Release 0.4.0 2008-12-07 07:49:24 +00:00
Roy Marples
8cce75925f Ignore FreeBSD targets. 2008-12-05 09:24:49 +00:00
Roy Marples
e72aeebbcd make ignore now updates svn:ignore as different OS's have different targets. 2008-12-04 19:21:47 +00:00
Roy Marples
dc712a109e runlevel override works correctly again. 2008-12-04 17:30:26 +00:00
Roy Marples
1acbfcf5ca Report invalid runlevels. 2008-12-04 17:17:09 +00:00
Roy Marples
f8210050e5 If we're building from subversion, brand the binary as such. 2008-12-04 13:12:46 +00:00
Roy Marples
38e6c9ba5c make ignore now configures the sv:ignore property. 2008-12-04 12:38:23 +00:00
Roy Marples
2c98c5326a Punt .gitignore files. 2008-12-04 12:12:09 +00:00
Roy Marples
57f90a42ba Include hotplugged services in our start list. 2008-12-01 08:46:50 +00:00
Roy Marples
bde35d03ed Actally show hotplugged services. 2008-12-01 08:46:25 +00:00
Roy Marples
8b76e1d2e0 Ignore interupts when waiting for processes to finish. Also, style fixes. 2008-11-28 10:48:01 +00:00
Roy Marples
b859710cc8 Style. 2008-11-28 10:47:17 +00:00
Roy Marples
c064393f08 Save screen space. 2008-11-28 10:46:58 +00:00
Roy Marples
e84f71596e Not needed. 2008-11-27 21:14:52 +00:00
Roy Marples
23e73957a0 Switch from select to poll and improve the no prefixing of eend calls. 2008-11-27 21:14:43 +00:00
Roy Marples
2537a07e10 Switch from select to poll and improve the no prefixing of eend calls. 2008-11-27 21:05:39 +00:00
Roy Marples
5403e70313 Save more screen space by removing the space befor the * for einfo and friends. Also remove the leading space before ... for ebegin. 2008-11-26 10:46:33 +00:00
Roy Marples
fe12134a5b Don't warn about waiting for services marked as notimeout, Gentoo #247306. 2008-11-23 18:40:43 +00:00
Roy Marples
1deaa0fae0 Fix lib. 2008-11-13 09:35:00 +00:00
Roy Marples
0cca768b82 Mark the addon code as deprecated. 2008-11-12 19:19:56 +00:00
Roy Marples
df22978de9 Punt halt init script. sysvinit should install it. See Gentoo bug #246502 on how to handle this. 2008-11-12 16:28:07 +00:00
Roy Marples
fe509db660 Save a needless malloc when re-creating PATH. 2008-11-12 10:55:42 +00:00
Roy Marples
937b1b2abf Don't set user info unless stated. 2008-11-11 19:47:30 +00:00
Roy Marples
eafbed0366 Fix stopping with a faulty pidfile. 2008-11-10 20:57:03 +00:00
Roy Marples
0786141026 Restore interface_exists, interface_up and interface_exists, #123. 2008-11-10 12:31:20 +00:00
Roy Marples
90d175ae27 Remove deprecated use of modprobe -l. If we need this functionaltiy back, we need to use something else, like say find. 2008-11-04 17:08:35 +00:00
Roy Marples
a178fd0f32 We should not update mtab here. 2008-11-04 17:07:32 +00:00
Roy Marples
03e8e0cb68 More Typos. 2008-11-04 14:28:51 +00:00
Roy Marples
a3d266e741 Use mount-ro 2008-11-04 11:32:07 +00:00
Roy Marples
42e6a95b1d Move romount to mount-ro and use the umount -r option as it's more reliable for / --bind mounts, Gentoo #239922. Thanks to Duncan. 2008-11-04 11:30:15 +00:00
Roy Marples
45044c9239 Typo 2008-11-04 11:28:24 +00:00
Roy Marples
5fc6f21169 Typo 2008-11-04 11:05:30 +00:00
Roy Marples
2cf24fe793 Ignore after dependencies for shutdown when not in the runlevel. 2008-11-04 09:32:21 +00:00
Roy Marples
cc14b55414 Now the linx fsck man page has return codes, I find them different from the BSD's so adjust accordingly. 2008-11-04 07:45:05 +00:00
Roy Marples
33d4fba5be We start off in sysinit correctly. 2008-11-04 00:21:30 +00:00
Roy Marples
32e17af92f No need for NULL here. 2008-11-03 23:13:36 +00:00
Roy Marples
77d56f5489 Avoid depends not in the runlevel for sysinit and shutdown. 2008-11-03 23:13:12 +00:00
Roy Marples
c520d4a23a --nice is -N, not -n. Also, correct default timeout. 2008-11-03 21:11:29 +00:00
Roy Marples
8a76c27325 Fix sending signals, #121. 2008-11-03 21:06:45 +00:00
Roy Marples
7467440a29 Fix fstabinfo for mounting /dev/shm, Gentoo #245367. 2008-11-03 18:00:55 +00:00
Roy Marples
282ad4bae6 Add descriptions. 2008-11-03 16:16:12 +00:00
Roy Marples
1e5a6f40e5 We shouldn't run halt.sh anymore. 2008-11-03 16:11:29 +00:00
Roy Marples
0af7d5bc20 Add a new shutdown runlevel, Gentoo #224537.
Split halt.sh into halt, killprocs, romount and savecache services.
The reboot runlevel is removed but mapped to shutdown.
The halt script should be moved to the sysvinit package.
2008-11-03 15:31:01 +00:00
Roy Marples
895c4f4149 Plug a leak and expand exec also. 2008-10-30 17:57:58 +00:00
Roy Marples
20380d3144 Allow ~ and ~user to expand for chdir and chroot. 2008-10-30 17:40:48 +00:00
Roy Marples
e1341e372b Fix --name when stopping, Gentoo #243088. 2008-10-30 16:26:05 +00:00
Roy Marples
1c73f2967c We no longer hotplug by default. 2008-10-30 15:03:12 +00:00
Roy Marples
2ff0838abb We should show hotplugged services, needed services and manually started services in rc-status. 2008-10-30 14:59:14 +00:00
Roy Marples
53ddd6ca96 Properly set PAM enviornment variables after opening session.
Without this change, modules like pam_mktemp or pam_env and similar
will be unable to change users' environments, like they are supposed
to.
2008-10-29 21:35:45 +00:00
Roy Marples
9ec6ff02bb Style and typo. 2008-10-28 15:43:36 +00:00
Roy Marples
aa991a3c99 Style. 2008-10-27 18:38:56 +00:00
Roy Marples
0d98d56188 Remove sysvinit specific code.
The runlevels shutdown, reboot, sysinit and single should be called by
init(8) and shutdown(8) and not manually.
sysvinit users will have to add sulogin to their inittab to secure the
console.
2008-10-27 18:01:03 +00:00
Roy Marples
ae692e294e Don't quote $tunnel, Gentoo #218123. 2008-10-26 19:58:57 +00:00
Roy Marples
f6e3c167ae Remove bash localisation feature, Gentoo #244444 thanks to Andrey Grozin. 2008-10-26 19:19:19 +00:00
Mike Frysinger
1d96620b84 hwclock: skip rtc checks if kernel lacks module support
Since we only use the result of the device scan to load modules, there is
no point in doing the scan if the kernel doesn't support modules in the
first place.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2008-10-26 07:09:02 +00:00
Roy Marples
d12bb5cf3c Really fix .depend 2008-10-20 16:47:56 +00:00
Roy Marples
9c76b077d6 Enable use of .depend on gmake. Also, generate extra dependencies for our shared libraries. 2008-10-20 12:09:14 +00:00
Roy Marples
0a39145a5e Include sysinit services even in single user. 2008-10-16 17:04:44 +00:00
Roy Marples
734e60608a Ignore new scripts. 2008-10-16 09:41:14 +00:00
Roy Marples
66ae6e38a7 Compile with FreeBSD 6.x make 2008-10-15 09:02:27 +00:00
Roy Marples
8d47d6c022 Fix fuser on BSD platforms. 2008-10-15 08:35:21 +00:00
Roy Marples
c18c74e816 Fix adding just the default route, #119 thanks to pva. 2008-10-14 15:27:52 +00:00
Roy Marples
da94fad3f5 Re-evaluate sys after running initsh. 2008-10-10 14:53:50 +00:00
Roy Marples
10cb4c18df Remove hardedcoded foo here. 2008-10-10 09:35:13 +00:00
Roy Marples
50b8aba8d9 Remove coldplug and just have hotplug which is a list of allowed/disallowed services. Makes things much easier. 2008-10-10 09:08:59 +00:00
Roy Marples
72dcac8c55 Shorten common messages for prefixed output. 2008-10-10 09:03:59 +00:00
Roy Marples
d6da8e8c48 sysinit is now a real runlevel that handles things like udev, dmesg and
mounting various bits in /dev and /sys.
init.sh JUST mounts /lib/rc/init.d (and /proc for Linux systems)
To make development of this easier we now return an empty RC_STRINGLIST
instead of a NULL for empty things.

If you don't have a udev init script installed, don't reboot your box OR
roll back to an older OpenRC version.
2008-10-10 08:37:21 +00:00
Roy Marples
247766695c Fix umounting reporting exit status, Gentoo #239922. 2008-10-09 16:36:42 +00:00
Roy Marples
1a88a43aa5 Warn about sulogin timeout and then continue as normal, Gentoo #240383 2008-10-09 16:34:21 +00:00
Roy Marples
c4e673edbc Add a better, but incomplete tgoto implementation to make gcc happy. 2008-10-08 21:07:04 +00:00
Roy Marples
a872fe5590 Fix status check, #239922 2008-10-08 18:32:39 +00:00
Roy Marples
8c8751fa60 Clean up warnings regarding printf. 2008-10-08 15:56:47 +00:00
Roy Marples
5cdc489573 Fix utmp permissions, Gentoo #240437. 2008-10-08 13:58:17 +00:00
Roy Marples
4d74e94c39 Merge branch 'master' of git@git.overlays.gentoo.org:proj/openrc 2008-10-07 12:18:22 +00:00
Roy Marples
d117b2d644 Fix tests, #Gentoo 240350. 2008-10-07 12:14:53 +00:00
Roy Marples
cb44b0a46c #ifdef atexit cleanups calling free as the OS should do this for us, but valgrind debuggers need it. 2008-10-06 15:02:32 +00:00
Roy Marples
4e4c4a5bf4 kenv is not always available. 2008-10-03 17:50:30 +00:00
Roy Marples
09a1a5ecd4 Fix a segfault when profile.env does not exist. 2008-10-03 17:50:10 +00:00
Roy Marples
84f6bf4bff Release 0.3 2008-10-02 16:14:13 +00:00
Roy Marples
5f76c1121a Clean stale sockets. 2008-10-01 21:12:54 +00:00
Roy Marples
41c1e170d6 Add an env var so plugins know when leaving single means the end, or start the default level. 2008-10-01 08:46:53 +00:00
Roy Marples
f53197818b Correcly call the right runlevel for plugins when shutting down. 2008-10-01 06:10:34 +00:00
Roy Marples
bb41d2cc80 Use flock to lock PREFIX_LOCK so that multiple processes can cleanly write to the same tty. 2008-09-27 18:50:21 +00:00
Roy Marples
4291b9140e Warn when waiting for a service every few seconds. 2008-09-27 17:17:15 +00:00
Roy Marples
28d7fb9430 When stopping services, check the newlevel if given otherwise the current runlevel. Fixes #100. 2008-09-27 16:56:03 +00:00
Roy Marples
abe94bec6f Load rtc-cmos if needed, Gentoo #235647 thanks to Robin Johnson. 2008-09-27 06:48:21 +00:00
Roy Marples
c3e192a834 Stop ssd from waiting by default - most daemons are good now. 2008-09-26 23:58:57 +00:00
Roy Marples
13d88731b7 We don't check exec when starting, so don't when testing for crashed. 2008-09-22 20:07:14 +00:00
Roy Marples
ffc79a50c2 Style 2008-09-22 19:49:16 +00:00
Roy Marples
6748c0e04e Allow forcefsck instead of gentoo=forcefsck on the kernel command line. 2008-09-22 12:32:35 +00:00
Roy Marples
27805de20a Allow forcefsck on the kernel command line, Gentoo #218431 2008-09-22 12:32:11 +00:00
Roy Marples
53693367df Our match arguments could be different from the exec arguments, as only the kernel should set script arguments. 2008-09-22 12:14:47 +00:00
Roy Marples
554d2fea19 Allow interpreted daemons to detect interperter options. 2008-09-22 10:45:01 +00:00
Roy Marples
a63303971a Document the --verbose option. 2008-09-22 09:37:28 +00:00
Roy Marples
5610c8560c s-s-d now handles interpreted daemons more easily. 2008-09-22 09:34:51 +00:00
Roy Marples
2c62d095c8 Typo. 2008-09-21 09:53:48 +00:00
Roy Marples
a72dc1194a Style. 2008-09-19 11:34:35 +00:00
Roy Marples
dcc4aa131c Document the limitation of symlinking services outside of the service directory, Gentoo #237263. 2008-09-19 11:32:24 +00:00
Roy Marples
6b3d8cf598 Fix stopping wpa_supplicant incorrectly, #107 2008-09-19 11:24:21 +00:00
Roy Marples
600d1f62fb Allow configuration of bond via extra sysfs entries, #105. 2008-09-19 09:32:24 +00:00
Roy Marples
2de401bca1 Enable bonding via sysfs, #104 thanks to Wolfram Schlich 2008-09-18 22:24:58 +00:00
Roy Marples
e368a4b4f8 Add missing profile bits to env, #72. 2008-09-18 19:46:10 +00:00
Roy Marples
354fb96ee9 Use the new rc_stringlist_find function. 2008-09-18 15:36:22 +00:00
Roy Marples
312d6f3e57 Work with NULL lists. 2008-09-18 15:32:57 +00:00
Roy Marples
39ea0cb84d Use the new rc_stringlist_find function. 2008-09-18 15:28:20 +00:00
Roy Marples
17bf78a539 Use the new rc_stringlist_find function. 2008-09-18 15:20:57 +00:00
Roy Marples
072328ff60 rc_nostop now lists services we should not stop on shutdown. 2008-09-18 15:13:53 +00:00
Roy Marples
e0dfa472d1 Add new functions, rc_stringlist_find and rc_stringlist_split. 2008-09-18 15:12:43 +00:00
Roy Marples
ccc24d1086 Add a config file for ipfw, #110 2008-09-18 14:25:23 +00:00
Roy Marples
c4c024fc9d Allow an empty bridge with no options, Gentoo #237485. 2008-09-18 14:13:33 +00:00
Roy Marples
223015920c Warn about parallel still locking the system. 2008-09-18 13:59:05 +00:00
Roy Marples
aa02a5516a Use better CFLAGS - some new warnings will need to be fixed. 2008-09-18 13:49:58 +00:00
Roy Marples
80a17eb596 Clean up some compile warnings. 2008-09-18 13:09:51 +00:00
Roy Marples
39304745d4 Allow interpreted daemons to use s-s-d a little easier. 2008-09-17 16:56:23 +00:00
Roy Marples
93a3b2dd02 Fix iwconfig parsing on Linux, #111 thanks to Andrew Gaffney. 2008-09-04 14:54:56 +00:00
Roy Marples
00d010fbe0 Work without IP6 kernels, #108 2008-08-29 06:43:54 +00:00
Roy Marples
01de348ede Add rpc.lockd to netmount.in for BSD 2008-08-27 16:06:01 +00:00
Roy Marples
fabee4dc2d Actually set the umask. 2008-08-20 10:19:03 +00:00
Roy Marples
1ab1e9328a Add -k,--umask option, Gentoo #232455. 2008-08-20 10:02:11 +00:00
Roy Marples
a9f7d2d5e5 Allow dhcpcd to use global dhcpcd variable for commandline options. 2008-08-19 22:30:59 +00:00
Roy Marples
a3c8706618 Allow OpenVZ to mount /sys and device managers, #102 2008-08-19 15:27:15 +00:00
Roy Marples
1f227d62bf Allow renaming of modules, #103 thanks to Sven. 2008-08-19 15:25:06 +00:00
Roy Marples
cdace75539 OpenVZ can mount NFS shares. 2008-08-19 06:44:47 +00:00
Roy Marples
15678263d5 Add new OpenVZ detection code 2008-08-19 06:36:43 +00:00
Roy Marples
cea206014d Attempt to make s-s-d simpler by not enforcing the need for a full path and maybe working better with interpreted scripts. 2008-07-27 11:30:49 +00:00
Roy Marples
46a74f244e Typo 2008-07-24 19:02:28 +00:00
Roy Marples
c67233f15c Don't set silly defaults that may brake users. 2008-07-09 18:28:45 +00:00
Roy Marples
b15c4758f8 We should unmount / here. 2008-07-09 18:28:14 +00:00
Roy Marples
289889ebf0 Fix unmounting some more. 2008-07-09 17:05:10 +00:00
Roy Marples
7183cb1b18 Fix last commit 2008-07-09 16:20:48 +00:00
Roy Marples
b83108cd2e Add a knob to avoid the unmounting of some points. 2008-07-09 16:08:38 +00:00
Roy Marples
1ca63447c9 Hide mkdir error's 2008-07-09 15:22:15 +00:00
Roy Marples
c2781c209e Really test if we can write to RC_LIBDIR or not. 2008-07-09 15:12:56 +00:00
Roy Marples
5983add0f2 No point in re-mounting ro filesystems that are already ro. 2008-07-09 14:24:48 +00:00
Roy Marples
a566493eb8 Ignore core files 2008-07-09 14:04:40 +00:00
Roy Marples
bdd8b150cd Fix return display. 2008-07-09 13:36:37 +00:00
Roy Marples
53401cd35f STAILQ -> TAILQ 2008-07-08 10:48:21 +00:00
Roy Marples
7a6112d3b0 Punt STAILQ and just use TAILQ so we're a bit more portable. 2008-07-07 14:16:46 +00:00
Roy Marples
157db50df7 Fix is_older_than a little better, and make is_newer_than correct. 2008-07-03 13:30:17 +00:00
Roy Marples
a88a177f99 Add older_than function to complement newer_than function. Also make the userland instance reversed to be compatable with current baselayout, which truely does suck. 2008-07-03 13:11:47 +00:00
Roy Marples
d61f831896 More unit fixes. 2008-07-03 13:09:24 +00:00
Roy Marples
28a65393ca More unit fixes. 2008-07-03 13:09:10 +00:00
Roy Marples
aa57dd1ff6 More unit fixes. 2008-07-03 12:33:42 +00:00
Roy Marples
e0968a1c2e Fix test. 2008-07-03 12:20:32 +00:00
Roy Marples
2f5d2855ba Add an is_older_than unit test, thanks to zzam 2008-07-03 12:07:46 +00:00
Roy Marples
db9bf18587 Fix compile with pcc. 2008-07-02 23:20:04 +00:00
Roy Marples
feac5ea1d5 Ignore ewaitfile. 2008-06-30 13:36:59 +00:00
Roy Marples
64dbae7f61 If filtering fstab, only match additional mounts asked for. 2008-06-30 13:33:42 +00:00
Roy Marples
11e4059b05 Set the default RC_SVCDIR higher up. 2008-06-21 15:31:04 +00:00
Roy Marples
5510451bac We need to replace @LIB@ here. 2008-06-21 14:10:59 +00:00
Roy Marples
11acce3c7d Use CPPFLAGS so we work with -combine in CFLAGS. 2008-06-19 23:12:00 +00:00
Roy Marples
4f2bb5ceaf open should use 3 args when using O_CREAT. 2008-06-17 15:14:33 +00:00
Roy Marples
bf8f0da921 fuzzy dependency ordering should be started, starting, stopped whilst checking runlevel, bootlevel, any at each stage. 2008-06-10 15:19:46 +00:00
Roy Marples
9b1cb4e246 When we have dependant scheduled services, don't error if a need is stopped. 2008-06-10 15:04:29 +00:00
Roy Marples
2adc99a8f5 No need to include this. 2008-06-05 12:26:53 +00:00
Roy Marples
fc747f9894 Remove the macro ;) 2008-06-05 12:19:49 +00:00
Roy Marples
76063daee5 Update style to more BSDish and replace the big macro with a function. 2008-06-05 12:17:41 +00:00
Roy Marples
dc891b0647 Remove broken before dependencies, Gentoo #224171. 2008-06-05 10:14:11 +00:00
Roy Marples
3525e602d6 Use addu instead of another loop. 2008-06-04 19:07:09 +00:00
Roy Marples
79ebd89d19 Only add a backreference if it doesn't already exist. 2008-06-04 19:00:46 +00:00
Roy Marples
ba8008fb05 Include time headers for ewaitfile. 2008-06-04 14:09:25 +00:00
Roy Marples
5e2c3fb5fe Merge branch 'master' of git@git.overlays.gentoo.org:proj/openrc 2008-06-04 12:58:05 +00:00
Roy Marples
e6aed12328 No need to check type twice like this. 2008-06-04 12:47:06 +00:00
Roy Marples
83ade5b701 Style. 2008-06-04 12:44:45 +00:00
Roy Marples
587051ec67 Add the ewaitfile function so init scripts can wait until sockts are created, Gentoo #175783. 2008-06-03 11:57:15 +00:00
Roy Marples
f2ea7ca514 Let ifdown control all interfaces. 2008-06-03 11:51:36 +00:00
128 changed files with 3107 additions and 2796 deletions

3
.gitignore vendored
View File

@@ -1,3 +0,0 @@
openrc-0.1.tar.bz2
.gdb_history
.gdbinit

View File

@@ -3,7 +3,7 @@
# All rights reserved. Released under the 2-clause BSD license.
NAME= openrc
VERSION= 0.2.5
VERSION= 0.4.1
PKG= ${NAME}-${VERSION}
SUBDIR= conf.d doc etc init.d man net sh src
@@ -17,7 +17,6 @@ include ${MK}/sys.mk
include ${MK}/os.mk
include ${MK}/subdir.mk
include ${MK}/dist.mk
include ${MK}/gitignore.mk
_installafter:
${INSTALL} -d ${DESTDIR}/${PREFIX}/${RC_LIB}/init.d

2
README
View File

@@ -19,6 +19,8 @@ PREFIX=/usr/local
We don't support building a static OpenRC with PAM.
You may need to use PROGLDFLAGS=-Wl,-Bstatic on glibc instead of just -static.
If you debug memory under valgrind, add -DDEBUG_MEMORY to your CPPFLAGS
so that all malloc memory should be freed at exit.
You can also brand OpenRC if you so wish like so
BRANDING=\"Gentoo/$(uname -s)\"

View File

@@ -1,5 +1,5 @@
DIR= ${CONFDIR}
CONF= bootmisc fsck hostname local net urandom
CONF= bootmisc fsck hostname local localmount net urandom
MK= ../mk
include ${MK}/os.mk

View File

@@ -1 +1 @@
CONF+= moused powerd rarpd savecore syscons
CONF+= ipfw moused powerd rarpd savecore syscons

View File

@@ -1 +1 @@
CONF+= consolefont hwclock keymaps modules
CONF+= consolefont dmesg hwclock keymaps modules

3
conf.d/dmesg Normal file
View File

@@ -0,0 +1,3 @@
# Sets the level at which logging of messages is done to the
# console. See dmesg(8) for more info.
dmesg_level="1"

14
conf.d/ipfw Normal file
View File

@@ -0,0 +1,14 @@
# ipfw provides a stateful firewall.
# This means we allow everything out, and if we have a connection we allow it
# back in. This is very flexable and quite secure.
# For ease of use, we allow auth and ssh ports through as well.
# To override the list of allowed ports
#ipfw_ports_in="auth ssh"
# You may want to enable logging of denied connections
#ipfw_log_deny="YES"
# This ports not logged
#ipfw_ports_nolog="135-139,445 1026,1027 1433,1434"

3
conf.d/localmount Normal file
View File

@@ -0,0 +1,3 @@
# Stop the unmounting of certain points.
# This could be useful for some NFS related work.
#no_umounts="/dir1:/var/dir2"

View File

@@ -5,6 +5,10 @@
#modules_2_6="tun"
#modules="ohci1394"
# You can give modules a different name when they load - the new name
# will also be used to pick arguments below.
#modules="dummy:dummy1"
# Give the modules some arguments if needed, per version if necessary.
#module_ieee1394_args="debug"
#module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394"

1
doc/.gitignore vendored
View File

@@ -1 +0,0 @@
net.example

View File

@@ -569,12 +569,18 @@
#-----------------------------------------------------------------------------
# Bonding
# For link bonding/trunking emerge net-misc/ifenslave
# For link bonding/trunking on 2.4 kernels, or kernels without sysfs
# emerge net-misc/ifenslave
# To bond interfaces together
#slaves_bond0="eth0 eth1 eth2"
#config_bond0="null" # You may not want to assign an IP the the bond
# You can also configure the bond here, which must be done via sysfs on 2.6
# kernels or newer. See the kernel bonding documention for a description of
# these options.
#arp_ip_target_bond0="+26.0.0.0"
# If any of the slaves require extra configuration - for example wireless or
# ppp devices - we need to depend function on the bonded interfaces
#rc_need_bond0="net.eth0 net.eth1"
@@ -1010,7 +1016,7 @@
#postdown() {
# # Enable Wake-On-LAN for every interface except for lo
# # Probably a good idea to set RC_DOWN_INTERFACE="no" in /etc/conf.d/rc
# # Probably a good idea to set ifdown="no" in /etc/conf.d/net
# # as well ;)
# [ "${IFACE}" != "lo" ] && ethtool -s "${IFACE}" wol g

3
etc/.gitignore vendored
View File

@@ -1,3 +0,0 @@
rc.conf
rc
rc.shutdown

View File

@@ -1,6 +1,8 @@
DIR= ${SYSCONFDIR}
CONF= rc.conf
CLEANFILES+= rc.conf
MK= ../mk
include ${MK}/os.mk
include Makefile.${OS}

View File

@@ -6,20 +6,3 @@
# consolefont, numlock, etc ...)
rc_tty_number=12
# Use this variable to control the /dev management behavior.
# devfs - use devfs (requires sys-fs/devfsd)
# mdev - use mdev (requires sys-apps/busybox)
# udev - use udev (requires sys-fs/udev)
# static - let the user manage /dev (YOU need to create ALL device nodes)
# Leave it blank to let rc work it out (udev, mdev, devfs, static)
#rc_devices=""
# UDEV OPTION:
# Set to "yes" if you want to save /dev to a tarball on shutdown
# and restore it on startup. This is useful if you have a lot of
# custom device nodes that udev does not handle/know about.
rc_device_tarball="NO"
# Sets the level at which logging of messages is done to the
# console. See dmesg(8) for more info.
dmesg_level="1"

View File

@@ -4,6 +4,9 @@
# in parallel for a slight speed improvement. When running in parallel we
# prefix the service output with it's name as the output will get
# jumbled up.
# WARNING: whilst we have improved parallel, it can still potentially lock
# the boot process. Don't file bugs about this unless you can supply
# patches that fix it without breaking other things!
rc_parallel="NO"
# Set rc_interactive to "YES" and you'll be able to press the I key during
@@ -19,36 +22,36 @@ rc_interactive="YES"
# come up.
rc_depend_strict="YES"
# Do we allow services to be hotplugged? If not, set to rc_hotplug="NO"
# NOTE: This does not affect anything hotplug/udev/devd related, just the
# starting/stopping of the init.d service triggered by it.
rc_hotplug="YES"
# Dynamic /dev managers can trigger coldplug events which cause services to
# start before we are ready for them. If this happens, we can defer these
# services to start in the boot runlevel. Set rc_coldplug="NO" if you don't
# want this.
# NOTE: This also affects module coldplugging in udev-096 and higher
# If you want module coldplugging but not coldplugging of services then you
# can set rc_coldplug="YES" and rc_plug_services="!*"
rc_coldplug="YES"
# Some people want a finer grain over hotplug/coldplug. rc_plug_services is a
# list of services that are matched in order, either allowing or not. By
# default we allow services through as rc_coldplug/rc_hotplug has to be YES
# anyway.
# Example - rc_plug_services="net.wlan !net.*"
# rc_hotplug is a list of services that we allow to be hotplugged.
# By default we do not allow hotplugging.
# A hotplugged service is one started by a dynamic dev manager when a matching
# hardware device is found.
# This service is intrinsically included in the boot runlevel.
# To disable services, prefix with a !
# Example - rc_hotplug="net.wlan !net.*"
# This allows net.wlan and any service not matching net.* to be plugged.
rc_plug_services=""
# Example - rc_hotplug="*"
# This allows all services to be hotplugged
#rc_hotplug="*"
# rc_logger launches a logging daemon to log the entire rc process to
# /var/log/rc.log
# NOTE: Linux systems require the devfs service to be started before
# logging can take place and as such cannot log the sysinit runlevel.
rc_logger="NO"
# By default we filter the environment for our running scripts. To allow other
# variables through, add them here. Use a * to allow all variables through.
# rc_env_allow="VAR1 VAR2"
# By default we assume that all daemons will start correctly.
# However, some do not - a classic example is that they fork and return 0 AND
# then child barfs on a configuration error. Or the daemon has a bug and the
# child crashes. You can set the number of milliseconds start-stop-daemon
# waits to check that the daemon is still running after starting here.
# The default is 0 - no checking.
# rc_start_wait=100
##############################################################################
# MISC CONFIGURATION VARIABLES
# There variables are shared between many init scripts

View File

@@ -10,12 +10,9 @@
trap : SIGINT
trap "echo 'Boot interrupted'; exit 1" SIGQUIT
# BSD's init works somewhat differently to sysvinit.
# This block should 'translate' from the way init calls it to the way it would
# be called by sysvinit on linux.
RUNLEVEL="1" /sbin/rc sysinit || exit 1
RUNLEVEL="1" /sbin/rc boot || exit 1
PREVLEVEL="1" /sbin/rc default
/sbin/rc sysinit || exit 1
/sbin/rc boot || exit 1
/sbin/rc default
# We don't actually care if rc default worked or not, we should exit 0
# to allow logins

View File

@@ -14,13 +14,4 @@ export LD_LIBRARY_PATH="/lib${LD_LIBRARY_PATH:+:}${LDLIBRARY_PATH}"
[ -z "$TERM" -o "$TERM" = "dumb" ] && export TERM="@TERM@"
action=${1:-shutdown}
# BSD's init works somewhat differently to sysvinit.
# This block should 'translate' from the way init calls it to the way it would
# be called by sysvinit on linux.
case "${action}" in
reboot) export RUNLEVEL=6;;
single) export RUNLEVEL=S;;
*) export RUNLEVEL=0;;
esac
exec /sbin/rc "${action}"

View File

@@ -1,9 +0,0 @@
avahi-dnsconfd
avahid
dbus
hald
named
ntpd
openvpn
polkitd
sshd

41
init.d/.gitignore vendored
View File

@@ -1,41 +0,0 @@
bootmisc
fsck
halt.sh
hostname
local
localmount
netmount
root
swap
sysctl
urandom
hostid
moused
newsyslog
pf
rarpd
rc-enabled
rpcbind
savecore
syslogd
adjkerntz
devd
dumpon
ipfw
mixer
nscd
powerd
syscons
net.lo
ttys
swap-blk
wscons
consolefont
hwclock
keymaps
modules
mtab
numlock
procfs
termencoding
devdb

View File

@@ -1,6 +1,6 @@
DIR= ${INITDIR}
SRCS= bootmisc.in fsck.in halt.sh.in hostname.in local.in localmount.in \
netmount.in root.in swap.in sysctl.in urandom.in
SRCS= bootmisc.in fsck.in hostname.in local.in localmount.in \
netmount.in root.in savecache.in swap.in sysctl.in urandom.in
BIN= ${OBJS}
INSTALLAFTER= _installafter

View File

@@ -1,7 +1,8 @@
NET_LO= net.lo
SRCS+= hwclock.in consolefont.in keymaps.in modules.in mtab.in numlock.in \
procfs.in termencoding.in
SRCS+= devfs.in dmesg.in hwclock.in consolefont.in keymaps.in killprocs.in \
modules.in mount-ro.in mtab.in numlock.in procfs.in sysfs.in \
termencoding.in
.SUFFIXES: .Linux.in
.Linux.in:

View File

@@ -77,10 +77,13 @@ start()
if dir_writeable /var/run; then
ebegin "Creating user login records"
cp /dev/null /var/run/utmp
chgrp utmp /var/run/utmp
chmod 0664 /var/run/utmp
if dir_writeable /var/log; then
logw=true
[ -e /var/log/wtmp ] || cp /dev/null /var/log/wtmp
chmod 0644 /var/run/utmp /var/log/wtmp
chgrp utmp /var/log/wtmp
chmod 0664 /var/log/wtmp
fi
eend 0
@@ -88,7 +91,15 @@ start()
for x in $(find /var/run ! -type d ! -name utmp \
! -name random-seed ! -name dev.db \
! -name ld-elf.so.hints ! -name ld.so.hints);
do
do
# Clean stale sockets
if [ -S "${x}" ]; then
if type fuser >/dev/null 2>&1; then
fuser "${x}" 2>/dev/null || rm "${x}"
else
rm "${x}"
fi
fi
[ ! -f "${x}" ] && continue
# Do not remove pidfiles of already running daemons
case "${x}" in

36
init.d/devfs.in Normal file
View File

@@ -0,0 +1,36 @@
#!@PREFIX@/sbin/runscript
# Copyright 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
description="Mount system critical filesystems in /dev."
depend() {
use dev
keyword noprefix
}
start() {
# Mount required stuff as user may not have then in /etc/fstab
for x in \
"devpts /dev/pts 0755 ,gid=5,mode=0620 devpts" \
"tmpfs /dev/shm 1777 ,nodev shm" \
; do
set -- ${x}
grep -Eq "[[:space:]]+$1$" /proc/filesystems || continue
mountinfo -q "$2" && continue
if [ ! -d "$2" ]; then
mkdir -m "$3" -p "$2" >/dev/null 2>&1 || \
ewarn "Could not create $2!"
fi
if [ -d "$2" ]; then
ebegin "Mounting $2"
if ! fstabinfo --mount "$2"; then
mount -n -t "$1" -o noexec,nosuid"$4" "$5" "$2"
fi
eend $?
fi
done
return 0
}

18
init.d/dmesg.in Normal file
View File

@@ -0,0 +1,18 @@
#!@PREFIX@/sbin/runscript
# Copyright 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
description="Set the dmesg level for a cleaner boot"
depend()
{
before dev modules
keyword novserver
}
start()
{
if [ -n "${dmesg_level}" ]; then
dmesg -n"${dmesg_level}"
fi
}

View File

@@ -8,7 +8,7 @@ _IFS="
depend()
{
after clock modules
use dev clock modules
keyword nojail noopenvz noprefix notimeout novserver
}
@@ -25,15 +25,20 @@ _reboot() {
fi
}
_forcefsck()
{
[ -e /forcefsck ] || get_bootparam forcefsck
}
start()
{
local reboot_opts= fsck_opts= p= check_extra=
local fsck_opts= p= check_extra=
if [ -e /fastboot ]; then
ewarn "Skipping fsck due to /fastboot"
return 0
fi
if [ -e /forcefsck ]; then
if _forcefsck; then
fsck_opts="${fsck_opts} -f"
check_extra="(check forced)"
fi
@@ -60,21 +65,31 @@ start()
fsck_opts="${fsck_opts} -R"
fi
fi
reboot_opts="-f"
fi
trap : INT QUIT
fsck ${fsck_args--p} ${fsck_opts} "$@"
case $? in
0) eend 0; return 0;;
1) ewend 1 "Filesystems repaired"; return 0;;
2|3|4) ewend 1 "Filesystems repaired, but reboot needed"
_reboot ${reboot_opts} || return 1;;
8) ewend 1 "Operational error"; return 0;;
12) ewend 1 "fsck interupted"; return 1;;
*) eend 2 "Filesystems couldn't be fixed"
_abort || return 1;;
0) eend 0; return 0;;
1) ewend 1 "Filesystems repaired"; return 0;;
2|3) if [ "${RC_UNAME}" = "Linux" ]; then
ewend 1 "Filesystems repaired, but reboot needed"
_reboot -f
else
ewend 1 "Filesystems still have errors; manual fsck required"
fi;;
4) if [ "${RC_UNAME}" = "Linux" ]; then
ewend 1 "Fileystem errors left uncorrected"
return 0
else
ewend 1 "Filesystems repaired, but reboot needed"
_reboot
fi;;
8) ewend 1 "Operational error"; return 0;;
12) ewend 1 "fsck interupted";;
*) eend 2 "Filesystems couldn't be fixed";;
esac
_abort || return 1
}
stop()
@@ -82,6 +97,7 @@ stop()
# Fake function so we always shutdown correctly.
_abort() { return 0; }
_reboot() { return 0; }
_forcefsck() { return 1; }
yesno "${fsck_shutdown}" && start
return 0

View File

@@ -1,100 +0,0 @@
#!@SHELL@
# Copyright 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
. @SYSCONFDIR@/init.d/functions.sh
. "${RC_LIBDIR}"/sh/rc-functions.sh
[ -r @SYSCONFDIR@/rc.conf ] && . @SYSCONFDIR@/rc.conf
# Support LiveCD foo
if [ -r /sbin/livecd-functions.sh ]; then
. /sbin/livecd-functions.sh
livecd_read_commandline
fi
stop_addon devfs
stop_addon udev
# Really kill things off before unmounting
if [ -x /sbin/killall5 ]; then
killall5 -15
killall5 -9
fi
# Flush all pending disk writes now
sync; sync
# If we are in a VPS, we don't need anything below here, because
# 1) we don't need (and by default can't) umount anything (VServer) or
# 2) the host utils take care of all umounting stuff (OpenVZ)
if [ "${RC_SYS}" = "VSERVER" -o "${RC_SYS}" = "OPENVZ" ]; then
[ "${RC_SYS}" = "OPENVZ" -a "$1" = "reboot" ] && echo "" > /reboot
if [ -e @SYSCONFDIR@/init.d/"$1".sh ]; then
. @SYSCONFDIR@/init.d/"$1".sh
else
exit 0
fi
fi
# If $svcdir is still mounted, preserve it if we can
mnt=$(mountinfo --node "${RC_SVCDIR}")
if [ -n "${mnt}" -a -w "${RC_LIBDIR}" ]; then
f_opts="-m -c"
[ "${RC_UNAME}" = "Linux" ] && f_opts="-c"
if type fuser >/dev/null 2>&1; then
if [ -n "$(fuser ${f_opts} "${svcdir}" 2>/dev/null)" ]; then
fuser -k ${f_opts} "${svcdir}" >/dev/null 2>&1
sleep 2
fi
fi
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
"${RC_SVCDIR}"/softlevel "${RC_SVCDIR}"/nettree \
"${RC_SVCDIR}"/rc.log \
"${RC_LIBDIR}" 2>/dev/null
umount "${RC_SVCDIR}"
rm -rf "${RC_SVCDIR}"/*
# Pipe errors to /dev/null as we may have future timestamps
cp -p "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/depconfig \
"${RC_LIBDIR}"/softlevel "${RC_LIBDIR}"/nettree \
"${RC_LIBDIR}"/rc.log \
"${RC_SVCDIR}" 2>/dev/null
rm -f "${RC_LIBDIR}"/deptree "${RC_LIBDIR}"/depconfig \
"${RC_LIBDIR}"/softlevel "${RC_LIBDIR}"/nettree \
"${RC_LIBDIR}"/rc.log
# Release the memory disk if we used it
case "${mnt}" in
"/dev/md"[0-9]*) mdconfig -d -u "${mnt#/dev/md*}";;
esac
fi
unmounted=0
# Remount the remaining filesystems read-only
# Most BSD's don't need this as the kernel handles it nicely
if [ "${RC_UNAME}" = "Linux" ]; then
ebegin "Remounting remaining filesystems read-only"
# We need the do_unmount function
. "${RC_LIBDIR}"/sh/rc-mount.sh
eindent
fs=
for x in ${net_fs_list}; do
fs="${fs}${fs:+|}${x}"
done
[ -n "${fs}" ] && fs="^(${fs})$"
do_unmount "mount -n -o remount,ro" \
--skip-point-regex "^(/dev|/dev/.*|/proc|/proc/.*|/sys|/sys/.*)$" \
${fs:+--skip-fstype-regex} ${fs} --nonetdev
eoutdent
eend $?
unmounted=$?
fi
if [ ${unmounted} -ne 0 ]; then
[ -x /sbin/sulogin ] && sulogin -t 10 /dev/console
exit 1
fi
# Load the final script - not needed on BSD so they should not exist
[ -e @SYSCONFDIR@/init.d/"$1".sh ] && . @SYSCONFDIR@/init.d/"$1".sh
# Always exit 0 here
exit 0

View File

@@ -38,9 +38,11 @@ _set()
# otherwise we generate a random UUID.
reset()
{
local uuid=$(kenv smbios.system.uuid 2>/dev/null)
local x="[0-9a-f]"
local y="${x}${x}${x}${x}"
local uuid= x="[0-9a-f]" y="${x}${x}${x}${x}"
if type kenv >/dev/null 2>&1; then
uuid=$(kenv smbios.system.uuid 2>/dev/null)
fi
case "${uuid}" in
${y}${y}-${y}-${y}-${y}-${y}${y}${y});;
*) uuid=;;

View File

@@ -74,8 +74,14 @@ start()
fi
ebegin "Setting system clock using the hardware clock [${utc}]"
if [ -e /proc/modules -a ! -e /dev/rtc ]; then
modprobe -q rtc || modprobe -q genrtc
if [ -e /proc/modules ]; then
local rtc=
for rtc in /dev/rtc /dev/rtc[0-9]*; do
[ -e "${rtc}" ] && break
done
if [ ! -e "${rtc}" ]; then
modprobe -q rtc-cmos || modprobe -q rtc || modprobe -q genrtc
fi
fi
if [ -e /etc/adjtime ] && yesno ${clock_adjfile}; then

View File

@@ -20,6 +20,10 @@ ipfw() {
/sbin/ipfw -f -q "$@"
}
have_ip6() {
sysctl net.ipv6 2>/dev/null
}
init() {
# Load the kernel module
if ! sysctl net.inet.ip.fw.enable=1 >/dev/null 2>&1; then
@@ -36,13 +40,15 @@ init() {
ipfw add deny all from any to 127.0.0.0/8
ipfw add deny ip from 127.0.0.0/8 to any
ipfw add pass ip6 from any to any via lo0
ipfw add deny ip6 from any to ::1
ipfw add deny ip6 from ::1 to any
if have_ip6; then
ipfw add pass ip6 from any to any via lo0
ipfw add deny ip6 from any to ::1
ipfw add deny ip6 from ::1 to any
ipfw add pass ip6 from :: to ff02::/16 proto ipv6-icmp
ipfw add pass ip6 from fe80::/10 to fe80::/10 proto ipv6-icmp
ipfw add pass ip6 from fe80::/10 to ff02::/16 proto ipv6-icmp
ipfw add pass ip6 from :: to ff02::/16 proto ipv6-icmp
ipfw add pass ip6 from fe80::/10 to fe80::/10 proto ipv6-icmp
ipfw add pass ip6 from fe80::/10 to ff02::/16 proto ipv6-icmp
fi
}
start() {
@@ -62,9 +68,11 @@ start() {
ipfw add pass udp from me to any keep-state
ipfw add pass icmp from me to any keep-state
ipfw add pass tcp from me6 to any setup keep-state
ipfw add pass udp from me6 to any keep-state
ipfw add pass icmp from me6 to any keep-state
if have_ip6; then
ipfw add pass tcp from me6 to any setup keep-state
ipfw add pass udp from me6 to any keep-state
ipfw add pass icmp from me6 to any keep-state
fi
# Allow DHCP.
ipfw add pass udp from 0.0.0.0 68 to 255.255.255.255 67 out
@@ -77,11 +85,13 @@ start() {
# Allow "mandatory" ICMP in.
ipfw add pass icmp from any to any icmptype 3,4,11
# Allow ICMPv6 destination unreach
ipfw add pass ip6 from any to any icmp6types 1 proto ipv6-icmp
# Allow NS/NA/toobig (don't filter it out)
ipfw add pass ip6 from any to any icmp6types 2,135,136 proto ipv6-icmp
if have_ip6; then
# Allow ICMPv6 destination unreach
ipfw add pass ip6 from any to any icmp6types 1 proto ipv6-icmp
# Allow NS/NA/toobig (don't filter it out)
ipfw add pass ip6 from any to any icmp6types 2,135,136 proto ipv6-icmp
fi
# Add permits for this workstations published services below
# Only IPs and nets in firewall_allowservices is allowed in.

22
init.d/killprocs.in Normal file
View File

@@ -0,0 +1,22 @@
#!@PREFIX@/sbin/runscript
# Copyright 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
description="Kill all processes so we can unmount disks cleanly."
depend()
{
keyword noprefix
}
start()
{
ebegin "Terminating remaining processes"
killall5 -15
sleep 1
eend 0
ebegin "Killing remaining processes"
killall5 -9
sleep 1
eend 0
}

View File

@@ -39,5 +39,5 @@ stop()
. @SYSCONFDIR@/conf.d/local.stop
fi
eend $? $"Failed to stop local"
eend $? "Failed to stop local"
}

View File

@@ -30,13 +30,13 @@ start()
stop()
{
# We never unmount / or /dev or $RC_SVCDIR
local x= no_umounts="/|/dev|/dev/.*|${RC_SVCDIR}"
local x= no_umounts_r="/|/dev|/dev/.*|${RC_SVCDIR}"
# RC_NO_UMOUNTS is an env var that can be set by plugins
OIFS=${IFS} SIFS=${IFS-y}
IFS=$IFS:
for x in ${no_umounts} ${RC_NO_UMOUNTS}; do
no_umounts="${no_umounts}|${x}"
no_umounts_r="${no_umounts_r}|${x}"
done
if [ "${SIFS}" = "y" ]; then
IFS=$OIFS
@@ -45,9 +45,9 @@ stop()
fi
if [ "${RC_UNAME}" = "Linux" ]; then
no_umounts="${no_umounts}|/proc|/proc/.*|/sys|/sys/.*"
no_umounts_r="${no_umounts_r}|/proc|/proc/.*|/sys|/sys/.*"
fi
no_umounts="^(${no_umounts})$"
no_umounts_r="^(${no_umounts_r})$"
# Flush all pending disk writes now
sync; sync
@@ -63,7 +63,7 @@ stop()
# Umount loopback devices
einfo "Unmounting loopback devices"
eindent
do_unmount "umount -d" --skip-point-regex "${no_umounts}" \
do_unmount "umount -d" --skip-point-regex "${no_umounts_r}" \
--node-regex "^/dev/loop"
eoutdent
@@ -76,7 +76,7 @@ stop()
fs="${fs}${fs:+|}${x}"
done
[ -n "${fs}" ] && fs="^(${fs})$"
do_unmount "umount" --skip-point-regex "${no_umounts}" \
do_unmount "umount" --skip-point-regex "${no_umounts_r}" \
${fs:+--skip-fstype-regex} ${fs} --nonetdev
eoutdent

View File

@@ -23,7 +23,7 @@ start()
x=${KV#*.*.}
local KV_MICRO=${x%%-*}
local list= x= xx= y= args= cnt=0
local list= x= xx= y= args= mpargs= cnt=0 a=
for x in "${KV}" \
${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \
${KV_MAJOR}.${KV_MINOR} \
@@ -34,25 +34,30 @@ start()
[ -z "${list}" ] && list=${modules}
for x in ${list}; do
ebegin "Loading module ${x}"
a=${x#*:}
if [ "${a}" = "${x}" ]; then
unset mpargs
ebegin "Loading module ${x}"
else
x=${x%%:*}
mpargs="-o ${a}"
ebegin "Loading module ${x} as ${a}"
fi
aa=$(shell_var "${a}")
xx=$(shell_var "${x}")
for y in "${KV}" \
${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \
${KV_MAJOR}.${KV_MINOR} \
; do
eval args=\$module_${aa}_args_$(shell_var "${y}")
[ -n "${args}" ] && break
eval args=\$module_${xx}_args_$(shell_var "${y}")
[ -n "${args}" ] && break
done
[ -z "${args}" ] && eval args=\$module_${aa}_args
[ -z "${args}" ] && eval args=\$module_${xx}_args
eval modprobe -q "${x}" "${args}"
eval modprobe -q "${mpargs}" "${x}" "${args}"
eend $? "Failed to load ${x}" && cnt=$((${cnt} + 1))
done
einfo "Autoloaded ${cnt} module(s)"
# Just in case a sysadmin prefers generic symbolic links in
# /lib/modules/boot for boot time modules we will load these modules
[ -n "$(modprobe -l -t boot)" ] && modprobe -a -t boot \* 2>/dev/null
# Above test clobbers the return
return 0
}

45
init.d/mount-ro.in Normal file
View File

@@ -0,0 +1,45 @@
#!@PREFIX@/sbin/runscript
# Copyright 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
description="Re-mount filesytems read-only for a clean reboot."
depend()
{
need killprocs savecache
keyword noprefix noopenvz novserver
}
start()
{
# Flush all pending disk writes now
sync; sync
ebegin "Remounting remaining filesystems read-only"
# We need the do_unmount function
. "${RC_LIBDIR}"/sh/rc-mount.sh
eindent
local m="/dev|/dev/.*|/proc|/proc.*|/sys|/sys/.*|${RC_SVCDIR}" x= fs=
# RC_NO_UMOUNTS is an env var that can be set by plugins
local OIFS=$IFS SIFS=${IFS-y} IFS=$IFS
IFS=$IFS:
for x in ${no_umounts} ${RC_NO_UMOUNTS}; do
m="${m}|${x}"
done
if [ "${SIFS}" = y ]; then
IFS=$OIFS
else
unset IFS
fi
m="^(${m})$"
fs=
for x in ${net_fs_list}; do
fs="${fs}${fs:+|}${x}"
done
[ -n "${fs}" ] && fs="^(${fs})$"
do_unmount "umount -r" \
--skip-point-regex "${m}" \
${fs:+--skip-fstype-regex} ${fs} --nonetdev
eoutdent
eend $?
}

View File

@@ -445,6 +445,35 @@ _load_config()
config_index=-1
}
# Support functions
_run_if()
{
local cmd=$1 iface=$2 ifr=${IFACE} ifv=${IFVAR}
# Ensure that we don't stamp on real values
local IFACE= IFVAR=
shift
if [ -n "${iface}" ]; then
IFACE="${iface}"
[ "${iface}" != "${ifr}" ] && IFVAR=$(shell_var "${IFACE}")
else
IFACE=${ifr}
IFVAR=${ifv}
fi
${cmd}
}
interface_exists()
{
_run_if _exists "$@"
}
interface_up()
{
_run_if _up "$@"
}
interface_down()
{
_run_if _down "$@"
}
start()
{
local IFACE=${RC_SVCNAME#*.} oneworked=false module=
@@ -566,7 +595,7 @@ ${routes}"
fi
fi
local OIFS="${IFS}" SIFS=${IFS-y}
local OIFS="${IFS}" SIFS="${IFS-y}"
local IFS="$__IFS"
for cmd in ${routes}; do
unset IFS
@@ -581,7 +610,8 @@ ${routes}"
-net" "*|-host" "*);;
*" "netmask" "*) cmd="-net ${cmd}";;
*.*.*.*/32*) cmd="-host ${cmd}";;
*.*.*.*/*|0.0.0.0" "*|default" "*) cmd="-net ${cmd}";;
*.*.*.*/*|0.0.0.0|0.0.0.0" "*) cmd="-net ${cmd}";;
default|default" "*) cmd="-net ${cmd}";;
*) cmd="-host ${cmd}";;
esac
if ${hidefirstroute}; then
@@ -668,7 +698,7 @@ stop()
if ! yesno ${IN_BACKGROUND} && \
[ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then
eval module=\$ifdown_${IFVAR}
module=${module:-YES}
module=${module:-${ifdown:-YES}}
yesno ${module} && _down 2>/dev/null
fi

View File

@@ -34,8 +34,8 @@ depend()
config /etc/fstab
need net ${pmap}
use afc-client amd autofs openvpn
use dns nfs nfsmount portmap rpcbind rpc.statd
keyword nojail noopenvz noprefix novserver
use dns nfs nfsmount portmap rpcbind rpc.statd rpc.lockd
keyword nojail noprefix novserver
}
start()

View File

@@ -6,6 +6,7 @@ description="Mounts misc filesystems in /proc."
depend()
{
use devfs
need localmount
keyword noopenvz noprefix novserver
}
@@ -39,7 +40,7 @@ start()
# Setup Kernel Support for the NFS daemon status
if [ -d /proc/fs/nfsd ] && ! mountinfo -q /proc/fs/nfsd; then
if grep -qs nfsd /proc/filesystems; then
ebegin "Mounting nfsd filesystem"
ebegin "Mounting NFS filesystem"
mount -t nfsd -o nodev,noexec,nosuid \
nfsd /proc/fs/nfsd
eend $?
@@ -56,26 +57,6 @@ start()
fi
fi
# Setup Kernel Support for securityfs
if [ -d /sys/kernel/security ] && ! mountinfo -q /sys/kernel/security; then
if grep -qs securityfs /proc/filesystems; then
ebegin "Mounting security filesystem"
mount -t securityfs -o nodev,noexec,nosuid \
securityfs /sys/kernel/security
eend $?
fi
fi
# Setup Kernel Support for debugfs
if [ -d /sys/kernel/debug ] && ! mountinfo -q /sys/kernel/debug; then
if grep -qs debugfs /proc/filesystems; then
ebegin "Mounting debug filesystem"
mount -t debugfs -o nodev,noexec,nosuid \
debugfs /sys/kernel/debug
eend $?
fi
fi
# Setup Kernel Support for SELinux
if [ -d /selinux ] && ! mountinfo -q /selinux; then
if grep -qs selinuxfs /proc/filesystems; then

25
init.d/savecache.in Normal file
View File

@@ -0,0 +1,25 @@
#!@PREFIX@/sbin/runscript
# Copyright 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
description="Saves the caches OpenRC uses to non volatile storage"
start()
{
ebegin "Saving dependency cache"
if [ ! -d "${RC_LIBDIR}"/cache ]; then
rm -rf "${RC_LIBDIR}"/cache
if ! mkdir "${RC_LIBDIR}"/cache; then
eend $?
return $?
fi
fi
local save=
for x in deptree depconfig softlevel nettree rc.log; do
[ -e "${RC_SVCDIR}/${x}" ] && save="${save} ${RC_SVCDIR}/${x}"
done
if [ -n "${save}" ]; then
cp -p ${save} "${RC_LIBDIR}"/cache 2>/dev/null
fi
eend $?
}

63
init.d/sysfs.in Normal file
View File

@@ -0,0 +1,63 @@
#!@PREFIX@/sbin/runscript
# Copyright 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
description="Mount the sys filesystem."
depend()
{
keyword noprefix novserver
}
mount_sys()
{
grep -Eq "[[:space:]]+sysfs$" /proc/filesystems || return 1
mountinfo -q /sys && return 0
if [ ! -d /sys ]; then
if ! mkdir -m 0755 /sys; then
ewarn "Could not create /sys!"
return 1
fi
fi
ebegin "Mounting /sys"
if ! fstabinfo --mount /sys; then
mount -n -t sysfs -o noexec,nosuid,nodev sysfs /sys
fi
eend $?
}
mount_misc()
{
# Setup Kernel Support for securityfs
if [ -d /sys/kernel/security ] && ! mountinfo -q /sys/kernel/security; then
if grep -qs securityfs /proc/filesystems; then
ebegin "Mounting security filesystem"
mount -n -t securityfs -o nodev,noexec,nosuid \
securityfs /sys/kernel/security
eend $?
fi
fi
# Setup Kernel Support for debugfs
if [ -d /sys/kernel/debug ] && ! mountinfo -q /sys/kernel/debug; then
if grep -qs debugfs /proc/filesystems; then
ebegin "Mounting debug filesystem"
mount -n -t debugfs -o nodev,noexec,nosuid \
debugfs /sys/kernel/debug
eend $?
fi
fi
}
start()
{
local retval
mount_sys
retval=$?
if [ ${retval} -eq 0 ]; then
mount_misc
fi
return ${retval}
}

View File

@@ -18,7 +18,7 @@ MAKE_LINKS= suffix=$${man\#*.}; \
MK= ../mk
include ${MK}/sys.mk
include ${MK}/gitignore.mk
include ${MK}/svnignore.mk
all:

View File

@@ -202,4 +202,4 @@ Rinse and repeat for the other verbose functions.
.Sh SEE ALSO
.Xr printf 3 ,
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -61,4 +61,4 @@ does the same and also prints the full path of the service to stdout.
.Xr rc 8 ,
.Xr stdout 3
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -61,4 +61,4 @@ Show information only for the named
.Xr rc 8 ,
.Xr rc-update 8
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -77,4 +77,4 @@ Show all services.
.Xr rc 8 ,
.Xr rc-status 8
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Feb 22, 2008
.Dd November 03, 2008
.Dt RC 8 SMM
.Os OpenRC
.Sh NAME
@@ -60,18 +60,25 @@ sysinit always runs when the host first starts should not be run again.
Generally the only services you should add to the boot runlevel are those
which deal with the mounting of filesystems, set the initial state of attached
peripherals and logging.
Coldplugged services are added to the boot runlevel by the system.
All services in the boot runlevel are automatically included in all other
runlevels except for those listed here.
Hotplugged services are added to the boot runlevel by the system.
All services in the boot and sysinit runlevels are automatically included
in all other runlevels except for those listed here.
.It Ar single
Stops all services and enters single user mode.
.It Ar reboot
Changes to the single runlevel and then reboots the host.
Stops all services except for those in the sysinit runlevel.
.It Ar shutdown
Changes to the single runlevel and then halts the host.
.El
.Pp
You should not call any of these runlevels yourself.
Instead you should use
.Xr init 8
and
.Xr shutdown 8
and let them call these special runlevels.
.Sh SEE ALSO
.Xr rc-status 8 ,
.Xr rc-update 8
.Xr rc-update 8 ,
.Xr init 8 ,
.Xr shutdown 8
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -70,4 +70,4 @@ is set to
.Xr rc_stringlist_free 3 ,
.Xr sh 1
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -110,4 +110,4 @@ when done.
.Xr rc_stringlist_free 3 ,
.Xr runscript 8
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -67,4 +67,4 @@ Each RC_PID should be freed in the list as well as the list itself when done.
.Xr free 3 ,
.Xr queue 3
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -48,4 +48,4 @@ Plugins can affect the parent environemnt by writing NULL separated strings to
.Xr rc 8 ,
.Xr runscript 8
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -63,4 +63,4 @@ Rinse and repeat for the other verbose functions.
.Xr free 3
.Xr rc_stringlist_free 3
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -227,4 +227,4 @@ normally holds the volatile state data for services on a RAM backed disk.
.Xr rc_stringlist_free 3 ,
.Xr start-stop-daemon 8
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -85,4 +85,4 @@ itself.
.Xr queue 3 ,
.Xr strcmp 3
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Mar 19, 2008
.Dd September 19, 2008
.Dt RUNSCRIPT 8 SMM
.Os OpenRC
.Sh NAME
@@ -111,11 +111,11 @@ You should define a
function for the service so that
.Nm
will start and stop it in the right order in relation to other services.
As it's a function it can be very flexable, see the example below.
As it's a function it can be very flexible, see the example below.
Here is a list of the functions you can use in a
.Ic depend
function. You simply pass the names of the services to it to add to that
dpendency type, or prefix it with ! to remove it.
dependency type, or prefix it with ! to remove it.
.Bl -tag -width "RC_DEFAULTLEVEL"
.It Ic need
The service will refuse to start until needed services have started and it
@@ -173,8 +173,9 @@ If
does not equal 0 then output the string using
.Ic eerror
and !! in square brackets
at the end of the line. Otherwise output ok in square brackets at the end of
the line. The value of
at the end of the line.
Otherwise output ok in square brackets at the end of the line.
The value of
.Ar retval
is returned.
.It Ic ewend Ar retval Op Ar string
@@ -193,6 +194,14 @@ output when the environment variable
.Va EINFO_VERBOSE
is true.
.Bl -tag -width indent
.It Ic ewaitfile Ar timeout Ar file1 Ar file2 ...
Wait for
.Ar timeout
seconds until all files exist.
Returns 0 if all files exist, otherwise non zero.
If
.Ar timeout
is less then 1 then we wait indefinitely.
.It Ic is_newer_than Ar file1 Ar file2 ...
If
.Ar file1
@@ -205,7 +214,7 @@ is a directory, then check all it's contents too.
.It Ic is_older_than Ar file1 Ar file2 ...
If
.Ar file1
is older than
is newer than
.Ar file2
return 0, otherwise 1.
If
@@ -432,6 +441,16 @@ show()
}
.Ed
.Sh BUGS
Because of the way we load our configuration files and the need to handle
more than one service directory, you can only use symlinks in service
directories to other services in the same directory.
You cannot symlink to a service in a different directory even if it is
another service directory.
.Pp
is_older_than should return 0 on success.
Instead we return 1 to be compliant with Gentoo baselayout.
Users are encouraged to use the is_newer_than function which returns correctly.
.Sh SEE ALSO
.Xr einfo 3 ,
.Xr rc 8 ,
@@ -442,4 +461,4 @@ show()
.Xr start-stop-daemon 8 ,
.Xr uname 1
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -1,4 +1,4 @@
.\" Copyright 2007-2008 Roy Marples
.\" Copyright 2007-2009 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd Feb 24, 2008
.Dd January 1, 2009
.Dt START-STOP-DAEMON 8 SMM
.Os OpenRC
.Sh NAME
@@ -44,6 +44,11 @@
.Sh DESCRIPTION
.Nm
provides a consistent method of starting, stopping and signalling daemons.
If neither
.Fl K , -stop
nor
.Fl s , -signal
are provided, then we assume we are starting the daemon.
If a daemon cannot background by itself, nor create a pidfile,
.Nm
can do it for the daemon in a secure fashion.
@@ -67,16 +72,8 @@ Here are the options to specify the daemon and how it should start or stop:
The
.Ar daemon
we start or stop.
If the
.Ar daemon
is a script and you are not using the pidfile or process name options,
then you should replace
.Ar daemon
with the interpreter and pass
.Ar daemon
as an argument. Below is an example:
.Pp
start-stop-daemon -Sx /usr/bin/perl -- /usr/bin/daemon.pl
If this option is not specified, then the first non option argument
is used.
.It Fl p , -pidfile Ar pidfile
When starting, we expect the daemon to create a valid
.Ar pidfile
@@ -97,10 +94,17 @@ name here also.
.It Fl t , -test
Print the action(s) that would be taken, but don't actually do anything.
The return value is set as if the command was taken and worked.
.It Fl v , -verbose
P
Print the action(s) that are taken just before doing them.
.El
.Pp
These options are only used for starting daemons:
.Bl -tag -width indent
.It Fl a , -startas Ar name
Change the process name of the daemon to
.Ar name .
This just changes the first argument passed to the daemon.
.It Fl b , -background
Force the daemon into the background. Some daemons don't create pidfiles, so a
good trick is to get the daemon to run in the foreground, and use the this
@@ -112,10 +116,16 @@ chdir to this directory before starting the daemon.
.It Fl r , -chroot Ar path
chroot to this directory before starting the daemon. All other paths, such
as the path to the daemon, chdir and pidfile, should be relative to the chroot.
.It Fl c , -chuid Ar user
Same as the
.Fl u , -user
option.
.It Fl e , -env Ar VAR=VALUE
Set the environment variable VAR to VALUE.
.It Fl g , -group Ar group
Start the daemon as in the group.
.It Fl k , -umask Ar mode
Set the umask of the daemon.
.It Fl m , -make-pidfile
Saves the pid of the daemon in the file specified by the
.Fl p , -pidfile
@@ -123,7 +133,7 @@ option. Only useful when used with daemons that run in the foreground and
forced into the background with the
.Fl -b , -background
option.
.It Fl n , -nice Ar level
.It Fl N , -nice Ar level
Modifies the scheduling priority of the daemon.
.It Fl 1 , -stdout Ar logfile
Redirect the standard output of the process to logfile when started with
@@ -142,13 +152,19 @@ These options are only used for stopping daemons:
.It Fl R , -retry Ar timeout | Ar signal Ns / Ns Ar timeout
You can either specify a timeout or a multiple signal/timeout pairs as a
stopping schedule.
If not specified then a default value of SIGTERM/5 is
If not specified then a default value of SIGTERM/0 is
assumed.
.El
.Sh ENVIRONMENT
.Va SSD_NICELEVEL
can also set the scheduling priority of the daemon, but the command line
option takes precedence.
.Pp
.Va SSD_STARTWAIT
overrides the number of milliseconds set in
.Pa /etc/rc.conf
.Nm
waits for to check the daemon is still running.
.Sh NOTE
.Nm
uses
@@ -163,6 +179,9 @@ to stop or signal.
.Xr getopt 3 ,
.Xr nice 2 ,
.Xr rc_find_pids 3
.Sh BUGS
.Nm
cannot stop an interpreted daemon that no longer exists without a pidfile.
.Sh HISTORY
.Nm
first appeared in Debian.
@@ -170,4 +189,4 @@ first appeared in Debian.
This is a complete re-implementation with the process finding code in the
OpenRC library (librc, -lrc) so other programs can make use of it.
.Sh AUTHORS
.An "Roy Marples" Aq roy@marples.name
.An Roy Marples <roy@marples.name>

View File

@@ -1,5 +1,4 @@
# Copyright 2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
# Setup some good default CFLAGS
CFLAGS?= -O2
@@ -10,15 +9,25 @@ _CSTD_SH= if test -n "${CSTD}"; then echo "-std=${CSTD}"; else echo ""; fi
_CSTD!= ${_CSTD_SH}
CFLAGS+= ${_CSTD}$(shell ${_CSTD_SH})
# Try and use some good cc flags
_CC_FLAGS= -pedantic -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
-Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
-Wbad-function-cast -Wnested-externs -Wcomment -Winline \
-Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
-Wdeclaration-after-statement -Wsequence-point -Wextra
_CC_FLAGS_SH= for f in ${_CC_FLAGS}; do \
if ${CC} $$f -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
# Try and use some good cc flags if we're building from git
# We don't use -pedantic as it will warn about our perfectly valid
# use of %m in our logger.
_CCFLAGS= -Wall -Wextra -Wimplicit -Wshadow -Wformat=2 \
-Wmissing-prototypes -Wmissing-declarations \
-Wmissing-noreturn -Wmissing-format-attribute \
-Wnested-externs \
-Winline -Wwrite-strings -Wcast-align -Wcast-qual \
-Wpointer-arith \
-Wdeclaration-after-statement -Wsequence-point
# We should be using -Wredundant-decls, but our library hidden proto stuff
# gives loads of warnings. I don't fully understand it (the hidden proto,
# not the warning) so we just silence the warning.
_CC_FLAGS_SH= for f in ${_CCFLAGS}; do \
if echo "int main(void) { return 0;} " | \
${CC} $$f -S -xc -o /dev/null - ; \
then printf "%s" "$$f "; fi \
done
done;
_CC_FLAGS!= ${_CC_FLAGS_SH}
CFLAGS+= ${_CC_FLAGS}$(shell ${CC_FLAGS_SH})
CFLAGS+= ${_CC_FLAGS}$(shell ${_CC_FLAGS_SH})

View File

@@ -4,7 +4,7 @@
_RC_DEBUG_SH= case "${DEBUG}" in "") echo "";; *) echo "-DRC_DEBUG";; esac
_RC_DEBUG!= ${_RC_DEBUG_SH}
CFLAGS+= ${_RC_DEBUG}$(shell ${_RC_DEBUG_SH})
CPPFLAGS+= ${_RC_DEBUG}$(shell ${_RC_DEBUG_SH})
# Should we enable this with a different flag?
_LD_DEBUG_SH= case "${DEBUG}" in "") echo "";; *) echo "-Wl,--rpath=../librc -Wl,--rpath=../libeinfo";; esac

2
mk/depend-.mk Normal file
View File

@@ -0,0 +1,2 @@
# This space left intentionally blank because gmake does not load .depend
# by default

3
mk/depend-gmake.mk Normal file
View File

@@ -0,0 +1,3 @@
# Tell gmake to include the optional dependency file.
# This sucks, but I don't know any other way of portably making this work.
-include .depend

View File

@@ -1,13 +1,17 @@
# This only works for make implementations that always include a .depend if
# it exists. Only GNU make does not do this.
# Generate .depend
# Copyright 2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
CLEANFILES+= .depend
IGNOREFILES+= .depend
.depend: ${SRCS}
${CC} ${CFLAGS} -MM ${SRCS} > .depend
${CC} ${CPPFLAGS} -MM ${SRCS} > .depend
depend: .depend
depend: .depend extra_depend
# Nasty hack. depend-.mk is a blank file, depend-gmake.mk has a gmake specific
# command to optionally include .depend.
# Someone should patch gmake to optionally include .depend if it exists.
_INC_DEP= $(shell if ${MAKE} --version | grep -q "^GNU "; then \
echo "gmake"; else echo ""; fi)
include ${MK}/depend-${_INC_DEP}.mk

View File

@@ -2,11 +2,12 @@
# Copyright 2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
GITREF?= HEAD
DISTPREFIX?= ${NAME}-${VERSION}
DISTFILE?= ${DISTPREFIX}.tar.bz2
CLEANFILES+= ${DISTFILE}
dist:
git archive --prefix=${DISTPREFIX}/ ${GITREF} | bzip2 > ${DISTFILE}
svn export . ${DISTPREFIX}
tar cjpf ${DISTFILE} ${DISTPREFIX}
rm -rf ${DISTPREFIX}

View File

@@ -1,15 +0,0 @@
# rules to make .gitignore files
# Copyright 2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
IGNOREFILES+= ${CLEANFILES}
.PHONY: .gitignore
.gitignore:
@if test -n "${IGNOREFILES}"; then \
echo "Ignoring ${IGNOREFILES}"; \
echo ${IGNOREFILES} | tr ' ' '\n' > .gitignore; \
fi
gitignore: .gitignore

View File

@@ -16,8 +16,11 @@ CLEANFILES+= ${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK}
.SUFFIXES: .So
.c.o:
${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
.c.So:
${CC} ${PICFLAG} -DPIC ${CFLAGS} -c $< -o $@
${CC} ${PICFLAG} -DPIC ${CPPFLAGS} ${CFLAGS} -c $< -o $@
all: depend ${_LIBS}
@@ -53,7 +56,12 @@ check test::
clean:
rm -f ${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK} ${CLEANFILES}
extra_depend:
@TMP=depend.$$$$; \
${SED} -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.So:/' .depend > $${TMP}; \
mv $${TMP} .depend
include ${MK}/sys.mk
include ${MK}/os.mk
include ${MK}/depend.mk
include ${MK}/gitignore.mk
include ${MK}/svnignore.mk

View File

@@ -1,3 +1,3 @@
LIBTERMCAP?= -lncurses
CFLAGS+= -DHAVE_TERMCAP
CPPFLAGS+= -DHAVE_TERMCAP
LDADD+= ${LIBTERMCAP}

View File

@@ -1,5 +1,5 @@
# Copyright 2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
CFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=600
CPPFLAGS+= -D_BSD_SOURCE -D_XOPEN_SOURCE=600
LIBDL= -Wl,-Bdynamic -ldl

View File

@@ -1,5 +1,5 @@
LIBPAM?= -lpam
CFLAGS+= -DHAVE_PAM
CPPFLAGS+= -DHAVE_PAM
LDADD+= ${LIBPAM}
PAMDIR?= /etc/pam.d

View File

@@ -24,13 +24,18 @@ CLEANFILES+= ${OBJS} ${PROG}
all: depend ${PROG}
.c.o:
${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
${PROG}: ${SCRIPTS} ${OBJS}
${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
clean:
rm -f ${CLEANFILES}
extra_depend:
include ${MK}/sys.mk
include ${MK}/os.mk
include ${MK}/depend.mk
include ${MK}/gitignore.mk
include ${MK}/svnignore.mk

View File

@@ -56,4 +56,4 @@ CLEANFILES+= ${OBJS}
clean:
@if test -n "${CLEANFILES}"; then echo "rm -f ${CLEANFILES}"; rm -f ${CLEANFILES}; fi
include ${MK}/gitignore.mk
include ${MK}/svnignore.mk

View File

@@ -27,5 +27,5 @@ check test::
${_SUBDIR}
depend:
${_SUBDIR}
gitignore:
ignore:
${_SUBDIR}

14
mk/svnignore.mk Normal file
View File

@@ -0,0 +1,14 @@
# rules to make svn ignore files
# Copyright 2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
IGNOREFILES+= ${CLEANFILES}
ignore:
@if test -n "${IGNOREFILES}"; then \
echo "=> Ignoring ${IGNOREFILES}"; \
files="$$(echo "${IGNOREFILES}" | tr ' ' '\n')"; \
efiles="$$(svn propget svn:ignore .)"; \
sfiles="$$(printf "$${files}\n$${efiles}" | sort -u)"; \
eval svn propset svn:ignore \'"$${sfiles}"\' .; \
fi

View File

@@ -1,3 +1,3 @@
LIBTERMCAP?= -ltermcap
CFLAGS+= -DHAVE_TERMCAP
CPPFLAGS+= -DHAVE_TERMCAP
LDADD+= ${LIBTERMCAP}

2
net/.gitignore vendored
View File

@@ -1,2 +0,0 @@
ifconfig.sh
iwconfig.sh

View File

@@ -4,7 +4,6 @@
bonding_depend()
{
before interface macchanger
program /sbin/ifenslave
}
_config_vars="$_config_vars slaves"
@@ -16,7 +15,7 @@ _is_bond()
bonding_pre_start()
{
local s= slaves="$(_get_array "slaves_${IFVAR}")"
local x= s= slaves="$(_get_array "slaves_${IFVAR}")"
[ -z "${slaves}" ] && return 0
@@ -40,6 +39,16 @@ bonding_pre_start()
return 1
fi
# Configure the bond.
# Nice and dynamic :)
for x in /sys/class/net/"${IFACE}"/bonding/*; do
[ -f "${x}" ] || continue
eval s=\$${x##*/}_${IFVAR}
if [ -n "${s}" ]; then
echo "${s}" >"${x}"
fi
done
ebegin "Adding slaves to ${IFACE}"
eindent
einfo "${slaves}"
@@ -53,7 +62,7 @@ bonding_pre_start()
# Must force the slaves to a particular state before adding them
for IFACE in ${slaves}; do
_delete_addresses
_up
_down
done
)
@@ -62,7 +71,13 @@ bonding_pre_start()
# finally add in slaves
eoutdent
/sbin/ifenslave "${IFACE}" ${slaves} >/dev/null
if [ -d /sys/class/net ]; then
for s in ${slaves}; do
echo "+${s}" >/sys/class/net/"${IFACE}"/bonding/slaves
done
else
/sbin/ifenslave "${IFACE}" ${slaves} >/dev/null
fi
eend $?
return 0 #important
@@ -84,7 +99,13 @@ bonding_stop()
eindent
einfo "${slaves}"
eoutdent
/sbin/ifenslave -d "${IFACE}" ${slaves}
if [ -d /sys/class/net ]; then
for s in ${slaves}; do
echo -"${s}" > /sys/class/net/"${IFACE}"/bonding/slaves
done
else
/sbin/ifenslave -d "${IFACE}" ${slaves}
fi
# reset all slaves
(

View File

@@ -16,12 +16,15 @@ _is_bridge()
bridge_pre_start()
{
local ports= brif= iface="${IFACE}" e= x=
local brif= iface="${IFACE}" e= x=
local ports="$(_get_array "bridge_${IFVAR}")"
local opts="$(_get_array "brctl_${IFVAR}")"
eval brif=\$bridge_add_${IFVAR}
[ -z "${ports}" -a -z "${brif}" -a -z "${opts}" ] && return 0
eval x=\${bridge_${IFVAR}-y\}
if [ -z "${brif}" -a -z "${opts}" ]; then
[ -n "${ports}" -o "${x}" != "y" ] || return 0
fi
[ -n "${ports}" ] && bridge_post_stop

View File

@@ -17,6 +17,7 @@ dhcpcd_start()
{
local args= opt= opts= pidfile="/var/run/dhcpcd-${IFACE}.pid" new=true
eval args=\$dhcpcd_${IFVAR}
[ -z "${args}" ] && args=${dhcpcd}
# Get our options
eval opts=\$dhcp_${IFVAR}

View File

@@ -278,7 +278,7 @@ ifconfig_pre_start()
metric=1000
ebegin "Creating tunnel ${IFVAR}"
iptunnel add "${tunnel}"
iptunnel add ${tunnel}
eend $?
}

View File

@@ -31,13 +31,13 @@ ifplugd_pre_start()
for f in bond bridge tuntap vlan wireless; do
if type "_is_${f}" >/dev/null 2>&1; then
if _is_${f}; then
veinfo "netplug does not work with" "${f}"
veinfo "ifplugd does not work with ${f}"
return 0
fi
fi
done
ebegin "Starting ifplugd on" "${IFACE}"
ebegin "Starting ifplugd on ${IFACE}"
eval args=\$ifplugd_${IFVAR}
@@ -47,7 +47,7 @@ ifplugd_pre_start()
# Start ifplugd
eval start-stop-daemon --start --exec /usr/sbin/ifplugd \
--pidfile "${pidfile}" -- "${args}" --iface="${IFACE}"
eend "$?" || return 1
eend $? || return 1
eindent
@@ -85,7 +85,7 @@ ifplugd_stop()
local pidfile="/var/run/ifplugd.${IFACE}.pid"
[ ! -e "${pidfile}" ] && return 0
ebegin "Stopping ifplugd on" "${IFACE}"
ebegin "Stopping ifplugd on ${IFACE}"
start-stop-daemon --stop --quiet --exec /usr/sbin/ifplugd \
--pidfile "${pidfile}" --signal QUIT
eend $?

View File

@@ -54,7 +54,6 @@ ifwatchd_stop()
ebegin "Stopping ifwatchd on" "${IFACE}"
start-stop-daemon --stop --exec /usr/sbin/ifwatchd \
-- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \
-n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \
&& return 0
-n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}"
eend $?
}

View File

@@ -137,7 +137,7 @@ iwconfig_associate()
case "${caps}" in
[EI]P*)
if [ "${key}" = "-" ] ; then
ewarn "WEP key is not set for \"${SSID}\"; not connecting"
ewarn "WEP key is not set for \"${SSID}\""
return 1
fi
;;
@@ -145,7 +145,7 @@ iwconfig_associate()
*)
if [ "${key}" != "-" ] ; then
key="-"
ewarn "\"${SSID}\" is not WEP enabled; ignoring setting"
ewarn "\"${SSID}\" is not WEP enabled"
fi
;;
esac

View File

@@ -250,12 +250,12 @@ iwconfig_associate()
SSIDVAR=$(shell_var "${SSID}")
key="$(iwconfig_get_wep_key "${mac}")"
if [ "${wep_required}" = "on" -a "${key}" = "off" ]; then
ewarn "WEP key is not set for \"${SSID}\" - not connecting"
ewarn "WEP key is not set for \"${SSID}\""
return 1
fi
if [ "${wep_required}" = "off" -a "${key}" != "off" ]; then
key="off"
ewarn "\"${SSID}\" is not WEP enabled - ignoring setting"
ewarn "\"${SSID}\" is not WEP enabled"
fi
if ! eval iwconfig "${IFACE}" key "${key}"; then
@@ -433,7 +433,7 @@ iwconfig_scan()
[ -z "${a}" ] && break
eval b=\$QUALITY_${k}
if [ -n "${b}" -a "${a}" -lt "${b}" ]; then
for x in MAC SSID CHAN QUALITY ENC; do
for x in MAC SSID MODE CHAN QUALITY ENC; do
eval t=\$${x}_${i}
eval ${x}_${i}=\$${x}_${k}
eval ${x}_${k}=\$t
@@ -457,7 +457,7 @@ iwconfig_scan()
local u=${k}
# We need to split this into two tests, otherwise bash errors
[ -n "${a}" -a -n "${b}" ] && [ "${a}" -lt "${b}" ] && u=${i}
unset MAC_${u} SSID_${u} CHAN_${u} QUALITY_${u} ENC_${u}
unset MAC_${u} SSID_${u} MODE_${u} CHAN_${u} QUALITY_${u} ENC_${u}
fi
k=$((${k} + 1))
done
@@ -503,7 +503,7 @@ iwconfig_scan()
for x; do
if [ "${x}" = "${s}" ]; then
ewarn "${s} has been blacklisted - not connecting"
unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i}
unset SSID_${i} MAC_${i} ${MODE}_${i} CHAN_${i} QUALITY_${i} ENC_${i}
fi
done
i=$((${i} + 1))
@@ -601,10 +601,8 @@ iwconfig_connect_not_preferred()
iwconfig_defaults()
{
local x=
for x in txpower rate rts frag; do
iwconfig "${IFACE}" "${x}" auto 2>/dev/null
done
# Turn on the radio
iwconfig "${IFACE}" txpower on 2>/dev/null
# Release the AP forced
# Must do ap and then ssid otherwise scanning borks
@@ -739,7 +737,7 @@ iwconfig_pre_start()
# which reports NOT READY!
x="$(iwconfig_get_type)"
if [ "${x}" = "NOT READY!" ]; then
eerror "Looks like there was a probem loading the firmware for ${IFACE}"
eerror "Looks like there was a problem loading the firmware for ${IFACE}"
return 1
fi

View File

@@ -105,7 +105,15 @@ wpa_supplicant_pre_start()
fi
# Work out where the ctrl_interface dir is if it's not specified
local ctrl_dir=$(sed -n -e 's/[[:space:]]*#.*//g;s/[[:space:]]*$//g;s/^ctrl_interface=//p' "${cfgfile}")
local ctrl_dir=$(sed -e 's/^ *//' \
-e '/^ctrl_interface=/!d' \
-e 's/^ctrl_interface=//' \
-e 's/^ *//' \
-e 's/^DIR=//' \
-e 's/^ *//' \
-e 's/GROUP=.*//' \
-e 's/ *$//' \
"${cfgfile}")
if [ -z "${ctrl_dir}" ]; then
ctrl_dir=${opts##* -C}
if [ -n "${ctrl_dir}" -a "${ctrl_dir}" != "${opts}" ]; then
@@ -120,7 +128,6 @@ wpa_supplicant_pre_start()
fi
service_set_value ctrl_dir "${ctrl_dir}"
if [ -n "${wpac}" ]; then
opts="${opts} -W"
elif service_started devd; then

View File

@@ -1,22 +1,33 @@
BOOT= bootmisc fsck hostname localmount \
root swap sysctl urandom
DEFAULT= local netmount
SHUTDOWN= savecache
LEVELDIR= ${DESTDIR}/${SYSCONFDIR}/runlevels
SYSINITDIR= ${LEVELDIR}/sysinit
BOOTDIR= ${LEVELDIR}/boot
DEFAULTDIR= ${LEVELDIR}/default
SHUTDOWNDIR= ${LEVELDIR}/shutdown
INITDIR= ../init.d
MK= ../mk
include ${MK}/sys.mk
include ${MK}/os.mk
include ${MK}/gitignore.mk
include ${MK}/svnignore.mk
include Makefile.${OS}
all:
install:
if ! test -d "${SYSINITDIR}"; then \
${INSTALL} -d ${SYSINITDIR} || exit $$?; \
for x in ${SYSINIT}; do \
if test -n "${PREFIX}"; then \
grep -q "keyword .*noprefix" ${INITDIR}/"$$x" && continue; \
fi; \
ln -snf ${PREFIX}/etc/init.d/"$$x" ${SYSINITDIR}/"$$x" || exit $$?; done \
fi
if ! test -d "${BOOTDIR}"; then \
${INSTALL} -d ${BOOTDIR} || exit $$?; \
for x in ${BOOT}; do \
@@ -35,6 +46,14 @@ install:
fi; \
ln -snf ${PREFIX}/etc/init.d/"$$x" ${DEFAULTDIR}/"$$x" || exit $$?; done \
fi
if ! test -d "${SHUTDOWNDIR}"; then \
${INSTALL} -d ${SHUTDOWNDIR} || exit $$?; \
for x in ${SHUTDOWN}; do \
if test -n "${PREFIX}"; then \
grep -q "keyword .*noprefix" ${INITDIR}/"$$x" && continue; \
fi; \
ln -snf ${PREFIX}/etc/init.d/"$$x" ${SHUTDOWNDIR}/"$$x" || exit $$?; done \
fi
check test::

View File

@@ -1,2 +1,3 @@
BOOT+= hwclock consolefont keymaps modules mtab net.lo procfs \
termencoding
SYSINIT+= devfs dmesg
BOOT+= hwclock keymaps modules mtab net.lo procfs termencoding
SHUTDOWN+= killprocs mount-ro

8
sh/.gitignore vendored
View File

@@ -1,8 +0,0 @@
functions.sh
gendepends.sh
net.sh
rc-functions.sh
runscript.sh
init.sh
ifwatchd-carrier.sh
ifwatchd-nocarrier.sh

View File

@@ -1,5 +1,5 @@
DIR= ${PREFIX}/${RC_LIB}/sh
SRCS= functions.sh.in gendepends.sh.in \
SRCS= functions.sh.in gendepends.sh.in init-common-post.sh.in \
rc-functions.sh.in runscript.sh.in
INC= init-common-post.sh rc-mount.sh functions.sh rc-functions.sh
BIN= gendepends.sh init.sh runscript.sh

View File

@@ -6,23 +6,18 @@ retval=0
# mount $svcdir as something we can write to if it's not rw
# On vservers, / is always rw at this point, so we need to clean out
# the old service state data
RC_SVCDIR=${RC_SVCDIR:-/@LIB@/rc/init.d}
if [ "${RC_SVCDIR}" != "/" ] && mkdir "${RC_SVCDIR}/.test.$$" 2>/dev/null; then
rmdir "${RC_SVCDIR}/.test.$$"
for x in ${RC_SVCDIR:-/@LIB@/rc/init.d}/*; do
[ -e "${x}" ] || continue
case ${x##*/} in
depconfig|deptree|ksoftlevel|rc.log);;
*) rm -rf "${x}";;
esac
done
rm -rf "${RC_SVCDIR}"/*
else
mount_svcdir
retval=$?
fi
if [ -e "${RC_LIBDIR}"/cache/deptree ]; then
cp -p "${RC_LIBDIR}"/cache/* "${RC_SVCDIR}" 2>/dev/null
fi
echo "sysinit" > "${RC_SVCDIR}/softlevel"
# sysinit is now done, so allow init scripts to run normally
[ -e /dev/.rcsysinit ] && rm -f /dev/.rcsysinit
exit ${retval}

View File

@@ -10,18 +10,6 @@
# FreeBSD-7 supports tmpfs now :)
mount_svcdir()
{
local dotmp=false release=false retval=0
if [ -e "${RC_SVCDIR}"/deptree ]; then
dotmp=true
if ! mount -t tmpfs none "${RC_LIBDIR}"/tmp 2>/dev/null; then
mdconfig -a -t malloc -s 1m -u 1
newfs /dev/md1
mount /dev/md1 "${RC_LIBDIR}"/tmp
release=true
fi
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
"${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null
fi
if ! fstabinfo --mount "${RC_SVCDIR}"; then
if ! mount -t tmpfs -o rw,noexec,nosuid none "${RC_SVCDIR}" 2>/dev/null; then
mdconfig -a -t malloc -s "${rc_svcsize:-1024}"k -u 0
@@ -29,15 +17,6 @@ mount_svcdir()
mount -o rw,noexec,nosuid /dev/md0 "${RC_SVCDIR}"
fi
fi
retval=$?
if ${dotmp}; then
cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \
"${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null
umount "${RC_LIBDIR}"/tmp
${release} && mdconfig -d -u 1
fi
return ${retval}
}
. "${RC_LIBDIR}"/sh/functions.sh

View File

@@ -3,13 +3,13 @@
# Copyright 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
# This basically mounts $RC_SVCDIR as a ramdisk, but preserving its content
# which allows us to store service state and generate dependencies if needed.
# This basically mounts $RC_SVCDIR as a ramdisk.
# The tricky part is finding something our kernel supports
# tmpfs and ramfs are easy, so force one or the other.
mount_svcdir()
{
local fs= fsopts="-o rw,noexec,nodev,nosuid" devdir="rc-svcdir" devtmp="none" x=
local fs= fsopts="-o rw,noexec,nodev,nosuid"
local devdir="rc-svcdir" x=
local svcsize=${rc_svcsize:-1024}
if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then
@@ -18,55 +18,29 @@ mount_svcdir()
elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then
fs="ramfs"
# ramfs has no special options
elif [ -e /dev/ram0 -a -e /dev/ram1 ] \
elif [ -e /dev/ram0 ] \
&& grep -Eq "[[:space:]]+ext2$" /proc/filesystems; then
devdir="/dev/ram0"
devtmp="/dev/ram1"
fs="ext2"
for x in ${devdir} ${devtmp}; do
dd if=/dev/zero of="${x}" bs=1k count="${svcsize}"
mkfs -t "${fs}" -i 1024 -vm0 "${x}" "${svcsize}"
done
dd if=/dev/zero of="${devdir}" bs=1k count="${svcsize}"
mkfs -t "${fs}" -i 1024 -vm0 "${devdir}" "${svcsize}"
else
echo
eerror "OpenRC requires tmpfs, ramfs or 2 ramdisks + ext2"
eerror "OpenRC requires tmpfs, ramfs or a ramdisk + ext2"
eerror "compiled into the kernel"
echo
return 1
fi
local dotmp=false
if [ -e "${RC_SVCDIR}"/deptree ]; then
dotmp=true
mount -n -t "${fs}" -o rw "${devtmp}" "${RC_LIBDIR}"/tmp
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
"${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null
fi
# If we have no entry in fstab for $RC_SVCDIR, provide our own
if ! fstabinfo --mount "${RC_SVCDIR}"; then
mount -n -t "${fs}" ${fsopts} "${devdir}" "${RC_SVCDIR}"
fi
if ${dotmp}; then
cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \
"${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null
umount -n "${RC_LIBDIR}"/tmp
fi
}
. /etc/init.d/functions.sh
. "${RC_LIBDIR}"/sh/rc-functions.sh
[ -r /etc/conf.d/rc ] && . /etc/conf.d/rc
[ -r /etc/rc.conf ] && . /etc/rc.conf
# Set the console loglevel to 1 for a cleaner boot
# the logger should anyhow dump the ring-0 buffer at start to the
# logs, and that with dmesg can be used to check for problems
if [ -n "${dmesg_level}" -a "${RC_SYS}" != "VSERVER" ]; then
dmesg -n "${dmesg_level}"
fi
# By default VServer already has /proc mounted, but OpenVZ does not!
# However, some of our users have an old proc image in /proc
# NFC how they managed that, but the end result means we have to test if
@@ -82,7 +56,6 @@ if [ -e /proc/uptime ]; then
einfo "/proc is already mounted, skipping"
mountproc=false
fi
unset up
fi
if ${mountproc}; then
@@ -94,95 +67,5 @@ if ${mountproc}; then
fi
eend $?
fi
unset mountproc
# Re-load RC_SYS if empty now we have /proc mounted
[ -z "${RC_SYS}" ] && export RC_SYS="$(rc --sys)"
# Read off the kernel commandline to see if there's any special settings
# especially check to see if we need to set the CDBOOT environment variable
# Note: /proc MUST be mounted
if [ -r /sbin/livecd-functions.sh ]; then
. /sbin/livecd-functions.sh
livecd_read_commandline
fi
if [ "${RC_UNAME}" != "GNU/kFreeBSD" \
-a "${RC_SYS}" != "VSERVER" \
-a "${RC_SYS}" != "OPENVZ" ]
then
if grep -Eq "[[:space:]]+sysfs$" /proc/filesystems; then
if [ -d /sys ]; then
if ! mountinfo --quiet /sys; then
ebegin "Mounting /sys"
if ! fstabinfo --mount /sys; then
mount -n -t sysfs -o noexec,nosuid,nodev sysfs /sys
fi
eend $?
fi
else
ewarn "No /sys to mount sysfs needed in 2.6 and later kernels!"
fi
fi
fi
# Try to figure out how the user wants /dev handled
if [ "${rc_devices}" = "static" \
-o "${RC_SYS}" = "VSERVER" \
-o "${RC_SYS}" = "OPENVZ" \
-o "${RC_UNAME}" = "GNU/kFreeBSD" ]
then
ebegin "Using existing device nodes in /dev"
eend 0
else
case ${rc_devices} in
devfs) managers="devfs udev mdev";;
udev) managers="udev devfs mdev";;
mdev) managers="mdev udev devfs";;
*) managers="udev devfs mdev";;
esac
for m in ${managers}; do
# Check kernel params
if get_bootparam "no${m}" || ! has_addon ${m}-start; then
continue
fi
# Let's see if we can get this puppy rolling
start_addon ${m} && break
# Clean up
mountinfo -q /dev && umount -n /dev
done
fi
# Mount required stuff as user may not have then in /etc/fstab
for x in "devpts /dev/pts 0755 ,gid=5,mode=0620 devpts" "tmpfs /dev/shm 1777 ,nodev shm"
do
set -- ${x}
grep -Eq "[[:space:]]+$1$" /proc/filesystems || continue
mountinfo -q "$2" && continue
if [ ! -d "$2" ] && \
[ "${m}" = "devfs" -o "${m}" = "udev" ]; then
mkdir -m "$3" -p "$2" >/dev/null 2>&1 || \
ewarn "Could not create $2!"
fi
if [ -d "$2" ]; then
ebegin "Mounting $2"
if ! fstabinfo --mount "$2"; then
mount -n -t "$1" -o noexec,nosuid"$4" "$5" "$2"
fi
eend $?
fi
done
# If booting off CD, we want to update inittab before setting the runlevel
if [ -f /sbin/livecd-functions.sh -a -n "${CDBOOT}" ]; then
ebegin "Updating inittab"
livecd_fix_inittab
eend $?
telinit q &>/dev/null
fi
. "${RC_LIBDIR}"/sh/init-common-post.sh

View File

@@ -7,11 +7,21 @@ has_addon()
[ -e "${RC_LIBDIR}/addons/$1.sh" ] || [ -e /@LIB@/rcscripts/addons/"$1".sh ]
}
_addon_warn()
{
eindent
ewarn "${RC_SVCNAME} uses addon code which is deprecated"
ewarn "and may not be available in the future."
eoutdent
}
import_addon()
{
if [ -e "${RC_LIBDIR}/addons/$1.sh" ]; then
_addon_warn
. "${RC_LIBDIR}/addons/$1.sh"
elif [ -e /@LIB@/rcscripts/addons/"$1".sh ]; then
_addon_warn
. /@LIB@/rcscripts/addons/"$1".sh
else
return 1
@@ -58,6 +68,7 @@ get_bootparam()
set -- $(cat /proc/cmdline)
while [ -n "$1" ]; do
[ "$1" = "${match}" ] && return 0
case "$1" in
gentoo=*)
local params="${1##*=}"

View File

@@ -1,6 +1,10 @@
# Copyright 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.
# Declare this here so that no formatting doesn't affect the embedded newline
__IFS="
"
# Handy function to handle all our unmounting needs
# mountinfo is a C program to actually find our mounts on our supported OS's
# We rely on fuser being preset, so if it's not then we don't unmount anything.
@@ -15,17 +19,20 @@ do_unmount()
fi
shift
mountinfo "$@" | while read mnt; do
local IFS="$__IFS"
set -- $(mountinfo "$@")
unset IFS
for mnt; do
# Unmounting a shared mount can unmount other mounts, so
# we need to check the mount is still valid
mountinfo --quiet "${mnt}" || continue
case "${cmd}" in
umount*)
umount)
ebegin "Unmounting ${mnt}"
;;
*)
ebegin "Remounting ${mnt}"
ebegin "Remounting ${mnt} read only"
;;
esac

View File

@@ -52,26 +52,20 @@
#define ERRX fprintf (stderr, "out of memory\n"); exit (1)
#define UNCONST(a) ((void *)(unsigned long)(const void *)(a))
#ifdef lint
# define _unused
#endif
#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
# define _dead __attribute__((__noreturn__))
# define _unused __attribute__((__unused__))
#else
# define _dead
# define _unused
#endif
/* Some libc implemntations don't have these */
#ifndef STAILQ_CONCAT
#define STAILQ_CONCAT(head1, head2) do { \
if (!STAILQ_EMPTY((head2))) { \
*(head1)->stqh_last = (head2)->stqh_first; \
(head1)->stqh_last = (head2)->stqh_last; \
STAILQ_INIT((head2)); \
} \
} while (0)
#endif
#ifndef TAILQ_CONCAT
#define TAILQ_CONCAT(head1, head2, field) do { \
if (!TAILQ_EMPTY(head2)) { \
@@ -83,13 +77,6 @@
} while (0)
#endif
#ifndef STAILQ_FOREACH_SAFE
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = STAILQ_FIRST((head)); \
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
(var) = (tvar))
#endif
#ifndef TAILQ_FOREACH_SAFE
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = TAILQ_FIRST((head)); \
@@ -156,7 +143,6 @@ char *rc_conf_value(const char *var);
bool rc_conf_yesno(const char *var);
void env_filter(void);
void env_config(void);
bool service_plugable(const char *service);
int signal_setup(int sig, void (*handler)(int));
pid_t exec_service(const char *, const char *);
@@ -174,4 +160,5 @@ _unused static const char *basename_c(const char *path)
return (path);
}
int parse_mode(mode_t *, char *);
#endif

View File

@@ -1,7 +0,0 @@
.depend
libeinfo.o
libeinfo.So
libeinfo.a
libeinfo.so.1
libeinfo.so
.depend

View File

@@ -4,7 +4,7 @@ SRCS= libeinfo.c
INCS= einfo.h
VERSION_MAP= einfo.map
CFLAGS+= -I../includes
CPPFLAGS+= -I../includes
MK= ../../mk
include ${MK}/lib.mk

View File

@@ -28,13 +28,11 @@
#define __EINFO_H__
#if defined(__GNUC__)
# define __EINFO_PRINTF __attribute__ ((__format__ (__printf__, 1, 2)))
# define __EINFO_XPRINTF __attribute__ ((__noreturn__, __format__ (__printf__, 1, 2)))
# define __EEND_PRINTF __attribute__ ((__format__ (__printf__, 2, 3)))
# define EINFO_PRINTF(a, b) __attribute__((__format__(__printf__, a, b)))
# define EINFO_XPRINTF(a, b) __attribute__((__noreturn__,__format__(__printf__, a, b)))
#else
# define __EINFO_PRINTF
# define __EINFO_XPRINTF
# define __EEND_PRINTF
# define EINFO_PRINTF(a, b)
# define EINFO_XPRINTF(a, b)
#endif
#include <sys/types.h>
@@ -42,12 +40,12 @@
/* Although OpenRC requires C99, linking to us should not. */
#ifdef restrict
# define __EINFO_RESTRICT restrict
# define EINFO_RESTRICT restrict
#else
# ifdef __restrict
# define __EINFO_RESTRICT __restrict
# define EINFO_RESTRICT __restrict
# else
# define __EINFO_RESTRICT
# define EINFO_RESTRICT
# endif
#endif
@@ -68,7 +66,7 @@ typedef enum
const char *ecolor(ECOLOR);
/*! @brief Writes to syslog. */
void elog(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
void elog(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
/*!
* @brief Display informational messages.
@@ -86,22 +84,22 @@ void elog(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
* The v suffix means only print if EINFO_VERBOSE is yes.
*/
/*@{*/
int einfon(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
int ewarnn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
int eerrorn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
int einfo(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
int ewarn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
void ewarnx(const char * __EINFO_RESTRICT, ...) __EINFO_XPRINTF;
int eerror(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
void eerrorx(const char * __EINFO_RESTRICT, ...) __EINFO_XPRINTF;
int einfon(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarnn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int eerrorn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int einfo(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
void ewarnx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
int eerror(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
void eerrorx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
int einfovn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
int ewarnvn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
int ebeginvn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
int eendvn(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
int ewendvn(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
int einfov(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
int ewarnv(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
int einfovn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarnvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ebeginvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int eendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
int ewendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
int einfov(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ewarnv(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
/*@}*/
/*! @ingroup ebegin
@@ -109,8 +107,8 @@ int ewarnv(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
*
* Similar to einfo, but we add ... to the end of the message */
/*@{*/
int ebeginv(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
int ebegin(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
int ebeginv(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
int ebegin(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
/*@}*/
/*! @ingroup eend
@@ -122,12 +120,12 @@ int ebegin(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF;
*
* ebracket allows you to specifiy the position, color and message */
/*@{*/
int eend(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
int ewend(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
void ebracket(int, ECOLOR, const char * __EINFO_RESTRICT);
int eend(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
int ewend(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
void ebracket(int, ECOLOR, const char * EINFO_RESTRICT);
int eendv(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
int ewendv(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF;
int eendv(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
int ewendv(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
/*@}*/
/*! @ingroup eindent
@@ -141,7 +139,7 @@ void eindentv(void);
void eoutdentv(void);
/*! @brief Prefix each einfo line with something */
void eprefix(const char * __EINFO_RESTRICT);
void eprefix(const char * EINFO_RESTRICT);
__END_DECLS
#endif

View File

@@ -199,7 +199,8 @@ static const char *const color_terms[] = {
/* strlcat and strlcpy are nice, shame glibc does not define them */
#ifdef __GLIBC__
# if ! defined (__UCLIBC__) && ! defined (__dietlibc__)
static size_t strlcat(char *dst, const char *src, size_t size)
static size_t
strlcat(char *dst, const char *src, size_t size)
{
char *d = dst;
const char *s = src;
@@ -226,18 +227,19 @@ static size_t strlcat(char *dst, const char *src, size_t size)
return dst_n + (s - src);
}
static size_t strlcpy(char *dst, const char *src, size_t size)
static size_t
strlcpy(char *dst, const char *src, size_t size)
{
const char *s = src;
size_t n = size;
if (n && --n)
do {
if (! (*dst++ = *src++))
if (!(*dst++ = *src++))
break;
} while (--n);
if (! n) {
if (!n) {
if (size)
*dst = '\0';
while (*src++);
@@ -248,9 +250,10 @@ static size_t strlcpy(char *dst, const char *src, size_t size)
# endif
#endif
static bool yesno(const char *value)
static bool
yesno(const char *value)
{
if (! value) {
if (!value) {
errno = ENOENT;
return false;
}
@@ -272,7 +275,8 @@ static bool yesno(const char *value)
return false;
}
static bool noyes(const char *value)
static bool
noyes(const char *value)
{
int serrno = errno;
bool retval;
@@ -280,50 +284,107 @@ static bool noyes(const char *value)
errno = 0;
retval = yesno(value);
if (errno == 0) {
retval = ! retval;
retval = !retval;
errno = serrno;
}
return retval;
}
static bool is_quiet(void)
static bool
is_quiet(void)
{
return yesno(getenv("EINFO_QUIET"));
}
static bool is_verbose(void)
static bool
is_verbose(void)
{
return yesno(getenv ("EINFO_VERBOSE"));
}
/* Fake tgoto call - very crapy, but works for our needs */
#ifndef HAVE_TERMCAP
static char *tgoto(const char *cap, int a, int b)
static char *
tgoto(const char *cap, int col, int line)
{
static char buf[20];
char *p, *e, c, dbuf[6];
int oncol = 0, which = line, i;
snprintf(buf, sizeof(buf), cap, b, a);
p = buf;
e = p + sizeof(buf);
while ((c = *cap++)) {
if (c != '%' || ((c = *cap++) == '%')) {
*p++ = c;
if (p >= e) {
errno = E2BIG;
return NULL;
}
continue;
}
switch (c) {
case '3':
case '2':
case 'd':
i = 0;
do
dbuf[i++] = which % 10 | '0';
while ((which /= 10));
if (c != 'd') {
c -= '0';
if (i > c) {
errno = EINVAL;
return NULL;
}
while (i < c)
dbuf[i++] = '0';
}
if (p + i >= e) {
errno = E2BIG;
return NULL;
}
do
*p++ = dbuf[--i];
while (i);
break;
case 'r':
oncol = 0;
break;
case 'i':
col++;
line++;
which++;
continue;
default:
errno = EINVAL;
return NULL;
}
oncol = 1 - oncol;
which = oncol ? col : line;
}
*p = '\0';
return buf;
}
#endif
static bool colour_terminal(FILE * __EINFO_RESTRICT f)
static bool
colour_terminal(FILE * EINFO_RESTRICT f)
{
static int in_colour = -1;
char *e;
char *e, *ee, *end, *d, *p;
int c;
const char *_af = NULL;
const char *_ce = NULL;
const char *_ch = NULL;
const char *_md = NULL;
const char *_me = NULL;
const char *_up = NULL;
const char *_af = NULL, *_ce = NULL, *_ch = NULL;
const char *_md = NULL, *_me = NULL, *_up = NULL;
const char *bold;
char tmp[100];
char *p;
unsigned int i = 0;
#ifdef HAVE_TERMCAP
char *bp;
#endif
if (f && ! isatty(fileno(f)))
if (f && !isatty(fileno(f)))
return false;
if (noyes(getenv("EINFO_COLOR")))
@@ -335,26 +396,23 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f)
return true;
term_is_cons25 = false;
if (! term) {
if (!term) {
term = getenv("TERM");
if (! term)
if (!term)
return false;
}
if (strcmp(term, "cons25") == 0)
term_is_cons25 = true;
#ifdef HAVE_TERMCAP
/* Check termcap to see if we can do colour or not */
if (tgetent(termcapbuf, term) == 1) {
char *bp = tcapbuf;
bp = tcapbuf;
_af = tgetstr("AF", &bp);
_ce = tgetstr("ce", &bp);
_ch = tgetstr("ch", &bp);
/* Our ch use also works with RI .... for now */
if (! _ch)
if (!_ch)
_ch = tgetstr("RI", &bp);
_md = tgetstr("md", &bp);
_me = tgetstr("me", &bp);
@@ -377,29 +435,29 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f)
return false;
}
#endif
if (! _af)
if (!_af)
_af = AF;
if (! _ce)
if (!_ce)
_ce = CE;
if (! _ch)
if (!_ch)
_ch = CH;
if (! _md)
if (!_md)
_md = MD;
if (! _me)
if (!_me)
_me = ME;
if (! _up)
if (!_up)
_up = UP;
#ifdef HAVE_TERMCAP
}
if (! _af || ! _ce || ! _me || !_md || ! _up) {
if (!_af || !_ce || !_me || !_md || !_up) {
in_colour = 0;
return false;
}
/* Many termcap databases don't have ch or RI even though they
* do work */
if (! _ch)
if (!_ch)
_ch = CH;
#endif
@@ -407,33 +465,28 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f)
p = ebuffer;
for (i = 0; i < sizeof(ecolors) / sizeof(ecolors[0]); i++) {
tmp[0] = '\0';
if (ecolors[i].name) {
const char *bold = _md;
bold = _md;
c = ecolors[i].def;
/* See if the user wants to override the colour
* We use a :col;bold: format like 2;1: for bold green
* and 1;0: for a normal red */
if ((e = getenv("EINFO_COLOR"))) {
char *ee = strstr(e, ecolors[i].name);
ee = strstr(e, ecolors[i].name);
if (ee)
ee += strlen(ecolors[i].name);
if (ee && *ee == '=') {
char *d = strdup(ee + 1);
d = strdup(ee + 1);
if (d) {
char *end = strchr(d, ':');
end = strchr(d, ':');
if (end)
*end = '\0';
c = atoi(d);
end = strchr(d, ';');
if (end && *++end == '0')
bold = _me;
free(d);
}
}
@@ -460,7 +513,8 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f)
return true;
}
static int get_term_columns(FILE * __EINFO_RESTRICT stream)
static int
get_term_columns(FILE * EINFO_RESTRICT stream)
{
struct winsize ws;
char *env = getenv("COLUMNS");
@@ -469,7 +523,7 @@ static int get_term_columns(FILE * __EINFO_RESTRICT stream)
if (env) {
i = strtoimax(env, &p, 10);
if (! *p)
if (!*p)
return i;
}
@@ -479,13 +533,15 @@ static int get_term_columns(FILE * __EINFO_RESTRICT stream)
return DEFAULT_COLS;
}
void eprefix(const char *__EINFO_RESTRICT prefix)
void
eprefix(const char *EINFO_RESTRICT prefix)
{
_eprefix = prefix;
}
hidden_def(eprefix)
static void elogv(int level, const char *__EINFO_RESTRICT fmt, va_list ap)
static void EINFO_PRINTF(2, 0)
elogv(int level, const char *EINFO_RESTRICT fmt, va_list ap)
{
char *e = getenv("EINFO_LOG");
va_list apc;
@@ -500,7 +556,8 @@ static void elogv(int level, const char *__EINFO_RESTRICT fmt, va_list ap)
}
}
void elog(int level, const char *__EINFO_RESTRICT fmt, ...)
void
elog(int level, const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;
@@ -510,7 +567,8 @@ void elog(int level, const char *__EINFO_RESTRICT fmt, ...)
}
hidden_def(elog)
static int _eindent(FILE * __EINFO_RESTRICT stream)
static int
_eindent(FILE * EINFO_RESTRICT stream)
{
char *env = getenv("EINFO_INDENT");
int amount = 0;
@@ -525,7 +583,7 @@ static int _eindent(FILE * __EINFO_RESTRICT stream)
amount = INDENT_MAX;
if (amount > 0)
memset(indent, ' ', (size_t) amount);
memset(indent, ' ', (size_t)amount);
}
/* Terminate it */
@@ -533,32 +591,32 @@ static int _eindent(FILE * __EINFO_RESTRICT stream)
return fprintf(stream, "%s", indent);
}
static const char *_ecolor(FILE * __EINFO_RESTRICT f, ECOLOR color)
static const char *
_ecolor(FILE * EINFO_RESTRICT f, ECOLOR color)
{
unsigned int i;
if (! colour_terminal(f))
if (!colour_terminal(f))
return "";
for (i = 0; i < sizeof(ecolors) / sizeof(ecolors[0]); i++) {
for (i = 0; i < sizeof(ecolors) / sizeof(ecolors[0]); i++)
if (ecolors[i].color == color)
return ecolors_str[i];
}
return "";
}
hidden_def(ecolor)
const char *ecolor(ECOLOR color)
const char *
ecolor(ECOLOR color)
{
FILE *f = stdout;
/* Try and guess a valid tty */
if (! isatty(fileno(f))) {
if (!isatty(fileno(f))) {
f = stderr;
if (! isatty(fileno(f))) {
if (!isatty(fileno(f))) {
f = stdin;
if (! isatty(fileno(f)))
if (!isatty(fileno(f)))
f = NULL;
}
}
@@ -571,87 +629,68 @@ const char *ecolor(ECOLOR color)
setenv("EINFO_LASTCMD", _cmd, 1); \
}
#define EINFOVN(_file, _color) \
{ \
char *_e = getenv("EINFO_LASTCMD"); \
if (_e && ! colour_terminal(_file) && strcmp(_e, "ewarn") != 0 && \
_e[strlen (_e) - 1] == 'n') \
fprintf(_file, "\n"); \
if (_eprefix) \
fprintf(_file, "%s%s%s|", _ecolor(_file, _color), _eprefix, _ecolor(_file, ECOLOR_NORMAL)); \
fprintf(_file, " %s*%s ", _ecolor(_file, _color), _ecolor(_file, ECOLOR_NORMAL)); \
retval += _eindent(_file); \
{ \
va_list _ap; \
va_copy(_ap, ap); \
retval += vfprintf(_file, fmt, _ap) + 3; \
va_end(_ap); \
} \
if (colour_terminal(_file)) \
fprintf(_file, "%s", flush); \
}
static int _einfovn(const char *__EINFO_RESTRICT fmt, va_list ap)
static int EINFO_PRINTF(3, 0)
_einfo(FILE *f, ECOLOR color, const char *EINFO_RESTRICT fmt, va_list va)
{
int retval = 0;
char *last = getenv("EINFO_LASTCMD");
va_list ap;
EINFOVN(stdout, ECOLOR_GOOD);
if (last &&
!colour_terminal(f) &&
strcmp(last, "ewarn") != 0 &&
last[strlen(last) - 1] == 'n')
fprintf(f, "\n");
if (_eprefix)
fprintf(f, "%s%s%s|", _ecolor(f, color), _eprefix, _ecolor(f, ECOLOR_NORMAL));
fprintf(f, "%s*%s ", _ecolor(f, color), _ecolor(f, ECOLOR_NORMAL));
retval += _eindent(f);
va_copy(ap, va);
retval += vfprintf(f, fmt, ap) + 3;
va_end(ap); \
if (colour_terminal(f))
fprintf(f, "%s", flush);
return retval;
}
static int _ewarnvn(const char *__EINFO_RESTRICT fmt, va_list ap)
{
int retval = 0;
#define _einfovn(fmt, ap) _einfo(stdout, ECOLOR_GOOD, fmt, ap)
#define _ewarnvn(fmt, ap) _einfo(stderr, ECOLOR_WARN, fmt, ap)
#define _eerrorvn(fmt, ap) _einfo(stderr, ECOLOR_BAD, fmt, ap)
EINFOVN(stderr, ECOLOR_WARN);
return retval;
}
static int _eerrorvn(const char *__EINFO_RESTRICT fmt, va_list ap)
{
int retval = 0;
EINFOVN(stderr, ECOLOR_BAD);
return retval;
}
int einfon(const char *__EINFO_RESTRICT fmt, ...)
int
einfon(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (! fmt || is_quiet())
if (!fmt || is_quiet())
return 0;
va_start(ap, fmt);
retval = _einfovn(fmt, ap);
va_end(ap);
LASTCMD("einfon");
return retval;
}
hidden_def(einfon)
int ewarnn(const char *__EINFO_RESTRICT fmt, ...)
int
ewarnn(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (! fmt || is_quiet())
if (!fmt || is_quiet())
return 0;
va_start(ap, fmt);
retval = _ewarnvn(fmt, ap);
va_end(ap);
LASTCMD("ewarnn");
return retval;
}
hidden_def(ewarnn)
int eerrorn(const char *__EINFO_RESTRICT fmt, ...)
int
eerrorn(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
@@ -659,58 +698,53 @@ int eerrorn(const char *__EINFO_RESTRICT fmt, ...)
va_start(ap, fmt);
retval = _eerrorvn(fmt, ap);
va_end(ap);
LASTCMD("errorn");
return retval;
}
hidden_def(eerrorn)
int einfo(const char *__EINFO_RESTRICT fmt, ...)
int
einfo(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (! fmt || is_quiet())
if (!fmt || is_quiet())
return 0;
va_start(ap, fmt);
retval = _einfovn(fmt, ap);
retval += printf("\n");
va_end(ap);
LASTCMD("einfo");
return retval;
}
hidden_def(einfo)
int ewarn(const char *__EINFO_RESTRICT fmt, ...)
int
ewarn(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (! fmt || is_quiet())
if (!fmt || is_quiet())
return 0;
va_start(ap, fmt);
elogv(LOG_WARNING, fmt, ap);
retval = _ewarnvn(fmt, ap);
retval += fprintf(stderr, "\n");
va_end(ap);
LASTCMD("ewarn");
return retval;
}
hidden_def(ewarn)
void ewarnx(const char *__EINFO_RESTRICT fmt, ...)
void
ewarnx(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (fmt && ! is_quiet()) {
if (fmt && !is_quiet()) {
va_start(ap, fmt);
elogv(LOG_WARNING, fmt, ap);
retval = _ewarnvn(fmt, ap);
@@ -721,27 +755,26 @@ void ewarnx(const char *__EINFO_RESTRICT fmt, ...)
}
hidden_def(ewarnx)
int eerror(const char *__EINFO_RESTRICT fmt, ...)
int
eerror(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (! fmt)
if (!fmt)
return 0;
va_start(ap, fmt);
elogv(LOG_ERR, fmt, ap);
retval = _eerrorvn(fmt, ap);
va_end(ap);
retval += fprintf(stderr, "\n");
LASTCMD("eerror");
return retval;
}
hidden_def(eerror)
void eerrorx(const char *__EINFO_RESTRICT fmt, ...)
void
eerrorx(const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;
@@ -752,46 +785,43 @@ void eerrorx(const char *__EINFO_RESTRICT fmt, ...)
va_end(ap);
fprintf(stderr, "\n");
}
exit(EXIT_FAILURE);
}
hidden_def(eerrorx)
int ebegin(const char *__EINFO_RESTRICT fmt, ...)
int
ebegin(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (! fmt || is_quiet())
if (!fmt || is_quiet())
return 0;
va_start(ap, fmt);
retval = _einfovn(fmt, ap);
va_end(ap);
retval += printf(" ...");
retval += printf("...");
if (colour_terminal(stdout))
retval += printf("\n");
LASTCMD("ebegin");
return retval;
}
hidden_def(ebegin)
static void _eend(FILE * __EINFO_RESTRICT fp, int col, ECOLOR color,
const char *msg)
static void
_eend(FILE * EINFO_RESTRICT fp, int col, ECOLOR color, const char *msg)
{
int i;
int cols;
if (! msg)
if (!msg)
return;
cols = get_term_columns(fp) - (strlen(msg) + 3);
/* cons25 is special - we need to remove one char, otherwise things
* do not align properly at all. */
if (! term) {
if (!term) {
term = getenv("TERM");
if (term && strcmp(term, "cons25") == 0)
term_is_cons25 = true;
@@ -816,7 +846,8 @@ static void _eend(FILE * __EINFO_RESTRICT fp, int col, ECOLOR color,
}
}
static int _do_eend(const char *cmd, int retval, const char *__EINFO_RESTRICT fmt, va_list ap)
static int EINFO_PRINTF(3, 0)
_do_eend(const char *cmd, int retval, const char *EINFO_RESTRICT fmt, va_list ap)
{
int col = 0;
FILE *fp = stdout;
@@ -832,54 +863,51 @@ static int _do_eend(const char *cmd, int retval, const char *__EINFO_RESTRICT fm
col += fprintf(fp, "\n");
va_end(apc);
}
_eend(fp, col,
retval == 0 ? ECOLOR_GOOD : ECOLOR_BAD,
retval == 0 ? OK : NOT_OK);
return retval;
}
int eend(int retval, const char *__EINFO_RESTRICT fmt, ...)
int
eend(int retval, const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;
if (is_quiet())
return retval;
va_start(ap, fmt);
_do_eend("eend", retval, fmt, ap);
va_end(ap);
LASTCMD("eend");
return retval;
}
hidden_def(eend)
int ewend(int retval, const char *__EINFO_RESTRICT fmt, ...)
int
ewend(int retval, const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;
if (is_quiet())
return retval;
va_start(ap, fmt);
_do_eend("ewend", retval, fmt, ap);
va_end(ap);
LASTCMD("ewend");
return retval;
}
hidden_def(ewend)
void ebracket(int col, ECOLOR color, const char *msg)
void
ebracket(int col, ECOLOR color, const char *msg)
{
_eend(stdout, col, color, msg);
}
hidden_def(ebracket)
void eindent(void)
void
eindent(void)
{
char *env = getenv("EINFO_INDENT");
int amount = 0;
@@ -891,11 +919,9 @@ void eindent(void)
if (errno != 0)
amount = 0;
}
amount += INDENT_WIDTH;
if (amount > INDENT_MAX)
amount = INDENT_MAX;
snprintf(num, 10, "%08d", amount);
setenv("EINFO_INDENT", num, 1);
}
@@ -908,16 +934,14 @@ void eoutdent(void)
char num[10];
int serrno = errno;
if (! env)
if (!env)
return;
errno = 0;
amount = strtoimax(env, NULL, 0);
if (errno != 0)
amount = 0;
else
amount -= INDENT_WIDTH;
if (amount <= 0)
unsetenv("EINFO_INDENT");
else {
@@ -928,143 +952,132 @@ void eoutdent(void)
}
hidden_def(eoutdent)
int einfovn(const char *__EINFO_RESTRICT fmt, ...)
int
einfovn(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (! fmt || ! is_verbose())
if (!fmt || !is_verbose())
return 0;
va_start(ap, fmt);
retval = _einfovn(fmt, ap);
va_end(ap);
LASTCMD("einfovn");
return retval;
}
hidden_def(einfovn)
int ewarnvn(const char *__EINFO_RESTRICT fmt, ...)
int
ewarnvn(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (! fmt || ! is_verbose())
if (!fmt || !is_verbose())
return 0;
va_start(ap, fmt);
retval = _ewarnvn(fmt, ap);
va_end(ap);
LASTCMD("ewarnvn");
return retval;
}
hidden_def(ewarnvn)
int einfov(const char *__EINFO_RESTRICT fmt, ...)
int
einfov(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (! fmt || ! is_verbose())
if (!fmt || !is_verbose())
return 0;
va_start(ap, fmt);
retval = _einfovn(fmt, ap);
retval += printf("\n");
va_end(ap);
LASTCMD("einfov");
return retval;
}
hidden_def(einfov)
int ewarnv(const char *__EINFO_RESTRICT fmt, ...)
int
ewarnv(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (! fmt || ! is_verbose())
if (!fmt || !is_verbose())
return 0;
va_start(ap, fmt);
retval = _ewarnvn(fmt, ap);
retval += printf("\n");
va_end(ap);
LASTCMD("ewarnv");
return retval;
}
hidden_def(ewarnv)
int ebeginv(const char *__EINFO_RESTRICT fmt, ...)
int
ebeginv(const char *EINFO_RESTRICT fmt, ...)
{
int retval;
va_list ap;
if (! fmt || ! is_verbose())
if (!fmt || !is_verbose())
return 0;
va_start(ap, fmt);
retval = _einfovn(fmt, ap);
retval += printf(" ...");
retval += printf("...");
if (colour_terminal(stdout))
retval += printf("\n");
va_end(ap);
LASTCMD("ebeginv");
return retval;
}
hidden_def(ebeginv)
int eendv(int retval, const char *__EINFO_RESTRICT fmt, ...)
int
eendv(int retval, const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;
if (! is_verbose())
if (!is_verbose())
return 0;
va_start(ap, fmt);
_do_eend("eendv", retval, fmt, ap);
va_end(ap);
LASTCMD("eendv");
return retval;
}
hidden_def(eendv)
int ewendv(int retval, const char *__EINFO_RESTRICT fmt, ...)
int
ewendv(int retval, const char *EINFO_RESTRICT fmt, ...)
{
va_list ap;
if (! is_verbose())
if (!is_verbose())
return 0;
va_start(ap, fmt);
_do_eend("ewendv", retval, fmt, ap);
va_end(ap);
LASTCMD("ewendv");
return retval;
}
hidden_def(ewendv)
void eindentv(void)
void
eindentv(void)
{
if (is_verbose())
eindent ();
eindent();
}
hidden_def(eindentv)
void eoutdentv(void)
void
eoutdentv(void)
{
if (is_verbose())
eoutdent();

16
src/librc/.gitignore vendored
View File

@@ -1,16 +0,0 @@
.depend
librc.o
librc-daemon.o
librc-depend.o
librc-misc.o
librc-stringlist.o
librc.So
librc-daemon.So
librc-depend.So
librc-misc.So
librc-stringlist.So
librc.a
librc.so.1
librc.so
.depend
rc.h

View File

@@ -7,7 +7,7 @@ VERSION_MAP= rc.map
LDADD+= ${LIBKVM}
CFLAGS+= -I../includes
CPPFLAGS+= -I../includes
MK= ../../mk
include ${MK}/lib.mk

View File

@@ -40,11 +40,11 @@ static size_t strlcpy(char *dst, const char *src, size_t size)
if (n && --n)
do {
if (! (*dst++ = *src++))
if (!(*dst++ = *src++))
break;
} while (--n);
if (! n) {
if (!n) {
if (size)
*dst = '\0';
while (*src++);
@@ -57,21 +57,22 @@ static size_t strlcpy(char *dst, const char *src, size_t size)
#if defined(__linux__)
static bool pid_is_cmd(pid_t pid, const char *cmd)
static bool pid_is_exec(pid_t pid, const char *exec)
{
char buffer[32];
FILE *fp;
int c;
bool retval = false;
exec = basename_c(exec);
snprintf(buffer, sizeof(buffer), "/proc/%d/stat", pid);
if ((fp = fopen(buffer, "r"))) {
while ((c = getc(fp)) != EOF && c != '(')
;
if (c == '(') {
while ((c = getc(fp)) != EOF && c == *cmd)
cmd++;
if (c == ')' && *cmd == '\0')
while ((c = getc(fp)) != EOF && c == *exec)
exec++;
if (c == ')' && *exec == '\0')
retval = true;
}
fclose(fp);
@@ -79,7 +80,7 @@ static bool pid_is_cmd(pid_t pid, const char *cmd)
return retval;
}
static bool pid_is_exec(pid_t pid, const char *const *argv)
static bool pid_is_argv(pid_t pid, const char *const *argv)
{
char cmdline[32];
int fd;
@@ -108,7 +109,7 @@ static bool pid_is_exec(pid_t pid, const char *const *argv)
return true;
}
RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd,
RC_PIDLIST *rc_find_pids(const char *exec, const char *const *argv,
uid_t uid, pid_t pid)
{
DIR *procdir;
@@ -143,27 +144,21 @@ RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd,
while ((entry = readdir(procdir)) != NULL) {
if (sscanf(entry->d_name, "%d", &p) != 1)
continue;
if (runscript_pid != 0 && runscript_pid == p)
continue;
if (pid != 0 && pid != p)
continue;
if (uid) {
snprintf(buffer, sizeof(buffer), "/proc/%d", p);
if (stat(buffer, &sb) != 0 || sb.st_uid != uid)
continue;
}
if (cmd && ! pid_is_cmd(p, cmd))
if (exec && !pid_is_exec(p, exec))
continue;
if (argv && ! cmd && !
pid_is_exec(p, (const char *const *)argv))
if (argv &&
!pid_is_argv(p, (const char *const *)argv))
continue;
if (! pids) {
if (!pids) {
pids = xmalloc(sizeof(*pids));
LIST_INIT(pids);
}
@@ -172,7 +167,6 @@ RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd,
LIST_INSERT_HEAD(pids, pi, entries);
}
closedir(procdir);
return pids;
}
librc_hidden_def(rc_find_pids)
@@ -201,7 +195,7 @@ librc_hidden_def(rc_find_pids)
# define _KVM_FLAGS O_RDONLY
# endif
RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd,
RC_PIDLIST *rc_find_pids(const char *exec, const char *const *argv,
uid_t uid, pid_t pid)
{
static kvm_t *kd = NULL;
@@ -235,39 +229,34 @@ RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd,
return NULL;
}
if (exec)
exec = basename_c(exec);
for (i = 0; i < processes; i++) {
p = _GET_KINFO_PID(kp[i]);
if (pid != 0 && pid != p)
continue;
if (uid != 0 && uid != _GET_KINFO_UID(kp[i]))
continue;
if (cmd) {
if (! _GET_KINFO_COMM(kp[i]) ||
strcmp(cmd, _GET_KINFO_COMM(kp[i])) != 0)
if (exec) {
if (!_GET_KINFO_COMM(kp[i]) ||
strcmp(exec, _GET_KINFO_COMM(kp[i])) != 0)
continue;
}
if (argv && *argv && ! cmd) {
if (argv && *argv) {
pargv = _KVM_GETARGV(kd, &kp[i], pargc);
if (! pargv || ! *pargv)
if (!pargv || !*pargv)
continue;
arg = argv;
match = 1;
while (*arg && *pargv)
if (strcmp(*arg++, *pargv++) != 0) {
match = 0;
break;
}
if (! match)
if (!match)
continue;
}
if (! pids) {
if (!pids) {
pids = xmalloc(sizeof(*pids));
LIST_INIT(pids);
}
@@ -297,7 +286,7 @@ static bool _match_daemon(const char *path, const char *file,
snprintf(ffile, sizeof(ffile), "%s/%s", path, file);
fp = fopen(ffile, "r");
if (! fp)
if (!fp)
return false;
while ((rc_getline(&line, &len, fp))) {
@@ -306,7 +295,7 @@ static bool _match_daemon(const char *path, const char *file,
TAILQ_REMOVE(match, m, entries);
break;
}
if (! TAILQ_FIRST(match))
if (!TAILQ_FIRST(match))
break;
}
fclose(fp);
@@ -316,14 +305,22 @@ static bool _match_daemon(const char *path, const char *file,
return true;
}
static RC_STRINGLIST *_match_list(const char* const* argv,
const char *name, const char *pidfile)
static RC_STRINGLIST *_match_list(const char *exec, const char* const* argv,
const char *pidfile)
{
RC_STRINGLIST *match = rc_stringlist_new();
int i = 0;
size_t l;
char *m;
if (exec) {
l = strlen(exec) + 6;
m = xmalloc(sizeof(char) * l);
snprintf(m, l, "exec=%s", exec);
rc_stringlist_add(match, m);
free(m);
}
while (argv && argv[i]) {
l = strlen(*argv) + strlen("argv_=") + 16;
m = xmalloc(sizeof(char) * l);
@@ -332,14 +329,6 @@ static RC_STRINGLIST *_match_list(const char* const* argv,
free(m);
}
if (name) {
l = strlen(name) + 6;
m = xmalloc(sizeof (char) * l);
snprintf(m, l, "name=%s", name);
rc_stringlist_add(match, m);
free(m);
}
if (pidfile) {
l = strlen(pidfile) + 9;
m = xmalloc(sizeof (char) * l);
@@ -351,8 +340,9 @@ static RC_STRINGLIST *_match_list(const char* const* argv,
return match;
}
bool rc_service_daemon_set(const char *service, const char *const *argv,
const char *name, const char *pidfile, bool started)
bool rc_service_daemon_set(const char *service, const char *exec,
const char *const *argv,
const char *pidfile, bool started)
{
char dirpath[PATH_MAX];
char file[PATH_MAX];
@@ -365,7 +355,7 @@ bool rc_service_daemon_set(const char *service, const char *const *argv,
int i = 0;
FILE *fp;
if (!(argv && *argv) && ! name && ! pidfile) {
if (!exec && !pidfile) {
errno = EINVAL;
return false;
}
@@ -375,7 +365,7 @@ bool rc_service_daemon_set(const char *service, const char *const *argv,
/* Regardless, erase any existing daemon info */
if ((dp = opendir(dirpath))) {
match = _match_list(argv, name, pidfile);
match = _match_list(exec, argv, pidfile);
while ((d = readdir(dp))) {
if (d->d_name[0] == '.')
continue;
@@ -384,7 +374,7 @@ bool rc_service_daemon_set(const char *service, const char *const *argv,
dirpath, d->d_name);
nfiles++;
if (! *oldfile) {
if (!*oldfile) {
if (_match_daemon(dirpath, d->d_name, match)) {
unlink(file);
strlcpy(oldfile, file, sizeof(oldfile));
@@ -405,13 +395,13 @@ bool rc_service_daemon_set(const char *service, const char *const *argv,
snprintf(file, sizeof(file), "%s/%03d",
dirpath, nfiles + 1);
if ((fp = fopen(file, "w"))) {
fprintf(fp, "exec=");
if (exec)
fprintf(fp, "%s", exec);
while (argv && argv[i]) {
fprintf(fp, "argv_%d=%s\n", i, argv[i]);
fprintf(fp, "\nargv_%d=%s", i, argv[i]);
i++;
}
fprintf(fp, "name=");
if (name)
fprintf(fp, "%s", name);
fprintf(fp, "\npidfile=");
if (pidfile)
fprintf(fp, "%s", pidfile);
@@ -427,7 +417,8 @@ bool rc_service_daemon_set(const char *service, const char *const *argv,
}
librc_hidden_def(rc_service_daemon_set)
bool rc_service_started_daemon(const char *service, const char *const *argv,
bool rc_service_started_daemon(const char *service,
const char *exec, const char *const *argv,
int indx)
{
char dirpath[PATH_MAX];
@@ -437,12 +428,12 @@ bool rc_service_started_daemon(const char *service, const char *const *argv,
DIR *dp;
struct dirent *d;
if (!service || !(argv && *argv))
if (!service || !exec)
return false;
snprintf(dirpath, sizeof(dirpath), RC_SVCDIR "/daemons/%s",
basename_c(service));
match = _match_list(argv, NULL, NULL);
match = _match_list(exec, argv, NULL);
if (indx > 0) {
snprintf(file, sizeof(file), "%03d", indx);
@@ -492,7 +483,7 @@ bool rc_service_daemons_crashed(const char *service)
path += snprintf(dirpath, sizeof(dirpath), RC_SVCDIR "/daemons/%s",
basename_c(service));
if (! (dp = opendir(dirpath)))
if (!(dp = opendir(dirpath)))
return false;
while ((d = readdir(dp))) {
@@ -502,25 +493,25 @@ bool rc_service_daemons_crashed(const char *service)
snprintf(path, sizeof(dirpath) - (path - dirpath), "/%s",
d->d_name);
fp = fopen(dirpath, "r");
if (! fp)
if (!fp)
break;
while ((rc_getline(&line, &len, fp))) {
p = line;
if ((token = strsep(&p, "=")) == NULL || ! p)
if ((token = strsep(&p, "=")) == NULL || !p)
continue;
if (! *p)
if (!*p)
continue;
if (strncmp(token, "argv_", 5) == 0) {
if (! list)
list = rc_stringlist_new();
rc_stringlist_add(list, p);
} else if (strcmp(token, "exec") == 0) {
if (strcmp(token, "exec") == 0) {
if (exec)
free(exec);
exec = xstrdup(p);
} else if (strncmp(token, "argv_", 5) == 0) {
if (!list)
list = rc_stringlist_new();
rc_stringlist_add(list, p);
} else if (strcmp(token, "name") == 0) {
if (name)
free(name);
@@ -543,14 +534,16 @@ bool rc_service_daemons_crashed(const char *service)
free(pidfile);
pidfile = NULL;
/* We have the pid, so no need to match on name */
/* We have the pid, so no need to match on exec or name */
free(exec);
exec = NULL;
free(name);
name = NULL;
} else {
if (exec) {
if (! list)
if (!list)
list = rc_stringlist_new();
if (! TAILQ_FIRST(list))
if (!TAILQ_FIRST(list))
rc_stringlist_add(list, exec);
free(exec);
@@ -570,9 +563,10 @@ bool rc_service_daemons_crashed(const char *service)
}
}
if (! retval) {
if ((pids = rc_find_pids((const char *const *)argv,
name, 0, pid)))
if (!retval) {
if ((pids = rc_find_pids(exec,
(const char *const *)argv,
0, pid)))
{
p1 = LIST_FIRST(pids);
while (p1) {

File diff suppressed because it is too large Load Diff

View File

@@ -84,10 +84,10 @@ RC_STRINGLIST *rc_config_list(const char *file)
size_t len = 0;
char *p;
char *token;
RC_STRINGLIST *list = NULL;
RC_STRINGLIST *list = rc_stringlist_new();
if (!(fp = fopen(file, "r")))
return NULL;
return list;
while ((rc_getline(&buffer, &len, fp))) {
p = buffer;
@@ -104,8 +104,6 @@ RC_STRINGLIST *rc_config_list(const char *file)
if (token[strlen(token) - 1] == '\n')
token[strlen(token) - 1] = 0;
if (!list)
list = rc_stringlist_new();
rc_stringlist_add(list, token);
}
}
@@ -131,17 +129,18 @@ RC_STRINGLIST *rc_config_load(const char *file)
char *p;
list = rc_config_list(file);
if (!list)
return NULL;
config = rc_stringlist_new();
TAILQ_FOREACH(line, list, entries) {
/* Get entry */
p = line->value;
if (! p)
continue;
if (strncmp(p, "export ", 7) == 0)
p += 7;
if (! (token = strsep(&p, "=")))
continue;
entry = xstrdup (token);
entry = xstrdup(token);
/* Preserve shell coloring */
if (*p == '$')
token = line->value;
@@ -199,9 +198,6 @@ char *rc_config_value(RC_STRINGLIST *list, const char *entry)
RC_STRING *line;
char *p;
if (!list)
return NULL;
TAILQ_FOREACH(line, list, entries) {
p = strchr(line->value, '=');
if (p &&

Some files were not shown because too many files have changed in this diff Show More