Compare commits
	
		
			190 Commits
		
	
	
		
			openrc-0.2
			...
			openrc-0.4
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 0298e4ffa0 | ||
|   | a063035b37 | ||
|   | 213cef1739 | ||
|   | 386ee57432 | ||
|   | 631acff7aa | ||
|   | 877a328179 | ||
|   | 1efa64cae8 | ||
|   | 22959c3963 | ||
|   | 2464f9e93b | ||
|   | d91201cb94 | ||
|   | 1c5ec9d161 | ||
|   | f4b8366942 | ||
|   | 438665357b | ||
|   | 7ad40abf64 | ||
|   | 7e12abe035 | ||
|   | 4dba5b1ff1 | ||
|   | 1ff289e305 | ||
|   | 53e2bec385 | ||
|   | 9d9f17aa52 | ||
|   | 803dbbf0c8 | ||
|   | 9e5e60f257 | ||
|   | 6bf0289f33 | ||
|   | bdb3485b49 | ||
|   | eb6daeca43 | ||
|   | 10e88090f6 | ||
|   | 8cce75925f | ||
|   | e72aeebbcd | ||
|   | dc712a109e | ||
|   | 1acbfcf5ca | ||
|   | f8210050e5 | ||
|   | 38e6c9ba5c | ||
|   | 2c98c5326a | ||
|   | 57f90a42ba | ||
|   | bde35d03ed | ||
|   | 8b76e1d2e0 | ||
|   | b859710cc8 | ||
|   | c064393f08 | ||
|   | e84f71596e | ||
|   | 23e73957a0 | ||
|   | 2537a07e10 | ||
|   | 5403e70313 | ||
|   | fe12134a5b | ||
|   | 1deaa0fae0 | ||
|   | 0cca768b82 | ||
|   | df22978de9 | ||
|   | fe509db660 | ||
|   | 937b1b2abf | ||
|   | eafbed0366 | ||
|   | 0786141026 | ||
|   | 90d175ae27 | ||
|   | a178fd0f32 | ||
|   | 03e8e0cb68 | ||
|   | a3d266e741 | ||
|   | 42e6a95b1d | ||
|   | 45044c9239 | ||
|   | 5fc6f21169 | ||
|   | 2cf24fe793 | ||
|   | cc14b55414 | ||
|   | 33d4fba5be | ||
|   | 32e17af92f | ||
|   | 77d56f5489 | ||
|   | c520d4a23a | ||
|   | 8a76c27325 | ||
|   | 7467440a29 | ||
|   | 282ad4bae6 | ||
|   | 1e5a6f40e5 | ||
|   | 0af7d5bc20 | ||
|   | 895c4f4149 | ||
|   | 20380d3144 | ||
|   | e1341e372b | ||
|   | 1c73f2967c | ||
|   | 2ff0838abb | ||
|   | 53ddd6ca96 | ||
|   | 9ec6ff02bb | ||
|   | aa991a3c99 | ||
|   | 0d98d56188 | ||
|   | ae692e294e | ||
|   | f6e3c167ae | ||
|   | 1d96620b84 | ||
|   | d12bb5cf3c | ||
|   | 9c76b077d6 | ||
|   | 0a39145a5e | ||
|   | 734e60608a | ||
|   | 66ae6e38a7 | ||
|   | 8d47d6c022 | ||
|   | c18c74e816 | ||
|   | da94fad3f5 | ||
|   | 10cb4c18df | ||
|   | 50b8aba8d9 | ||
|   | 72dcac8c55 | ||
|   | d6da8e8c48 | ||
|   | 247766695c | ||
|   | 1a88a43aa5 | ||
|   | c4e673edbc | ||
|   | a872fe5590 | ||
|   | 8c8751fa60 | ||
|   | 5cdc489573 | ||
|   | 4d74e94c39 | ||
|   | d117b2d644 | ||
|   | cb44b0a46c | ||
|   | 4e4c4a5bf4 | ||
|   | 09a1a5ecd4 | ||
|   | 84f6bf4bff | ||
|   | 5f76c1121a | ||
|   | 41c1e170d6 | ||
|   | f53197818b | ||
|   | bb41d2cc80 | ||
|   | 4291b9140e | ||
|   | 28d7fb9430 | ||
|   | abe94bec6f | ||
|   | c3e192a834 | ||
|   | 13d88731b7 | ||
|   | ffc79a50c2 | ||
|   | 6748c0e04e | ||
|   | 27805de20a | ||
|   | 53693367df | ||
|   | 554d2fea19 | ||
|   | a63303971a | ||
|   | 5610c8560c | ||
|   | 2c62d095c8 | ||
|   | a72dc1194a | ||
|   | dcc4aa131c | ||
|   | 6b3d8cf598 | ||
|   | 600d1f62fb | ||
|   | 2de401bca1 | ||
|   | e368a4b4f8 | ||
|   | 354fb96ee9 | ||
|   | 312d6f3e57 | ||
|   | 39ea0cb84d | ||
|   | 17bf78a539 | ||
|   | 072328ff60 | ||
|   | e0dfa472d1 | ||
|   | ccc24d1086 | ||
|   | c4c024fc9d | ||
|   | 223015920c | ||
|   | aa02a5516a | ||
|   | 80a17eb596 | ||
|   | 39304745d4 | ||
|   | 93a3b2dd02 | ||
|   | 00d010fbe0 | ||
|   | 01de348ede | ||
|   | fabee4dc2d | ||
|   | 1ab1e9328a | ||
|   | a9f7d2d5e5 | ||
|   | a3c8706618 | ||
|   | 1f227d62bf | ||
|   | cdace75539 | ||
|   | 15678263d5 | ||
|   | cea206014d | ||
|   | 46a74f244e | ||
|   | c67233f15c | ||
|   | b15c4758f8 | ||
|   | 289889ebf0 | ||
|   | 7183cb1b18 | ||
|   | b83108cd2e | ||
|   | 1ca63447c9 | ||
|   | c2781c209e | ||
|   | 5983add0f2 | ||
|   | a566493eb8 | ||
|   | bdd8b150cd | ||
|   | 53401cd35f | ||
|   | 7a6112d3b0 | ||
|   | 157db50df7 | ||
|   | a88a177f99 | ||
|   | d61f831896 | ||
|   | 28a65393ca | ||
|   | aa57dd1ff6 | ||
|   | e0968a1c2e | ||
|   | 2f5d2855ba | ||
|   | db9bf18587 | ||
|   | feac5ea1d5 | ||
|   | 64dbae7f61 | ||
|   | 11e4059b05 | ||
|   | 5510451bac | ||
|   | 11acce3c7d | ||
|   | 4f2bb5ceaf | ||
|   | bf8f0da921 | ||
|   | 9b1cb4e246 | ||
|   | 2adc99a8f5 | ||
|   | fc747f9894 | ||
|   | 76063daee5 | ||
|   | dc891b0647 | ||
|   | 3525e602d6 | ||
|   | 79ebd89d19 | ||
|   | ba8008fb05 | ||
|   | 5e2c3fb5fe | ||
|   | e6aed12328 | ||
|   | 83ade5b701 | ||
|   | 587051ec67 | ||
|   | f2ea7ca514 | 
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,3 +0,0 @@ | |||||||
| openrc-0.1.tar.bz2 |  | ||||||
| .gdb_history |  | ||||||
| .gdbinit |  | ||||||
							
								
								
									
										3
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								Makefile
									
									
									
									
									
								
							| @@ -3,7 +3,7 @@ | |||||||
| # All rights reserved. Released under the 2-clause BSD license. | # All rights reserved. Released under the 2-clause BSD license. | ||||||
|  |  | ||||||
| NAME=		openrc | NAME=		openrc | ||||||
| VERSION=	0.2.5 | VERSION=	0.4.1 | ||||||
| PKG=		${NAME}-${VERSION} | PKG=		${NAME}-${VERSION} | ||||||
|  |  | ||||||
| SUBDIR=		conf.d doc etc init.d man net sh src | 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}/os.mk | ||||||
| include ${MK}/subdir.mk | include ${MK}/subdir.mk | ||||||
| include ${MK}/dist.mk | include ${MK}/dist.mk | ||||||
| include ${MK}/gitignore.mk |  | ||||||
|  |  | ||||||
| _installafter: | _installafter: | ||||||
| 	${INSTALL} -d ${DESTDIR}/${PREFIX}/${RC_LIB}/init.d | 	${INSTALL} -d ${DESTDIR}/${PREFIX}/${RC_LIB}/init.d | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								README
									
									
									
									
									
								
							| @@ -19,6 +19,8 @@ PREFIX=/usr/local | |||||||
|  |  | ||||||
| We don't support building a static OpenRC with PAM. | We don't support building a static OpenRC with PAM. | ||||||
| You may need to use PROGLDFLAGS=-Wl,-Bstatic on glibc instead of just -static. | 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 | You can also brand OpenRC if you so wish like so | ||||||
| BRANDING=\"Gentoo/$(uname -s)\" | BRANDING=\"Gentoo/$(uname -s)\" | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| DIR=	${CONFDIR} | DIR=	${CONFDIR} | ||||||
| CONF=	bootmisc fsck hostname local net urandom | CONF=	bootmisc fsck hostname local localmount net urandom | ||||||
|  |  | ||||||
| MK=	../mk | MK=	../mk | ||||||
| include ${MK}/os.mk | include ${MK}/os.mk | ||||||
|   | |||||||
| @@ -1 +1 @@ | |||||||
| CONF+=	moused powerd rarpd savecore syscons | CONF+=	ipfw moused powerd rarpd savecore syscons | ||||||
|   | |||||||
| @@ -1 +1 @@ | |||||||
| CONF+=	consolefont hwclock keymaps modules | CONF+=	consolefont dmesg hwclock keymaps modules | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								conf.d/dmesg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								conf.d/dmesg
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										14
									
								
								conf.d/ipfw
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										3
									
								
								conf.d/localmount
									
									
									
									
									
										Normal 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" | ||||||
| @@ -5,6 +5,10 @@ | |||||||
| #modules_2_6="tun" | #modules_2_6="tun" | ||||||
| #modules="ohci1394" | #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. | # Give the modules some arguments if needed, per version if necessary. | ||||||
| #module_ieee1394_args="debug" | #module_ieee1394_args="debug" | ||||||
| #module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394" | #module_ieee1394_args_2_6_23_gentoo_r5="ieee1394 ohci1394" | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								doc/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								doc/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1 +0,0 @@ | |||||||
| net.example |  | ||||||
| @@ -569,12 +569,18 @@ | |||||||
|  |  | ||||||
| #----------------------------------------------------------------------------- | #----------------------------------------------------------------------------- | ||||||
| # Bonding | # 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 | # To bond interfaces together | ||||||
| #slaves_bond0="eth0 eth1 eth2" | #slaves_bond0="eth0 eth1 eth2" | ||||||
| #config_bond0="null" # You may not want to assign an IP the the bond | #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 | # If any of the slaves require extra configuration - for example wireless or | ||||||
| # ppp devices - we need to depend function on the bonded interfaces | # ppp devices - we need to depend function on the bonded interfaces | ||||||
| #rc_need_bond0="net.eth0 net.eth1" | #rc_need_bond0="net.eth0 net.eth1" | ||||||
| @@ -1010,7 +1016,7 @@ | |||||||
|  |  | ||||||
| #postdown() { | #postdown() { | ||||||
| #	# Enable Wake-On-LAN for every interface except for lo | #	# 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 ;) | #	# as well ;) | ||||||
| #	[ "${IFACE}" != "lo" ] && ethtool -s "${IFACE}" wol g | #	[ "${IFACE}" != "lo" ] && ethtool -s "${IFACE}" wol g | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								etc/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								etc/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,3 +0,0 @@ | |||||||
| rc.conf |  | ||||||
| rc |  | ||||||
| rc.shutdown |  | ||||||
| @@ -1,6 +1,8 @@ | |||||||
| DIR=	${SYSCONFDIR} | DIR=	${SYSCONFDIR} | ||||||
| CONF=	rc.conf | CONF=	rc.conf | ||||||
|  |  | ||||||
|  | CLEANFILES+=	rc.conf | ||||||
|  |  | ||||||
| MK=	../mk | MK=	../mk | ||||||
| include ${MK}/os.mk | include ${MK}/os.mk | ||||||
| include Makefile.${OS} | include Makefile.${OS} | ||||||
|   | |||||||
| @@ -6,20 +6,3 @@ | |||||||
| # consolefont, numlock, etc ...) | # consolefont, numlock, etc ...) | ||||||
| rc_tty_number=12 | 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" |  | ||||||
|   | |||||||
| @@ -4,6 +4,9 @@ | |||||||
| # in parallel for a slight speed improvement. When running in parallel we | # 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 | # prefix the service output with it's name as the output will get | ||||||
| # jumbled up. | # 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" | rc_parallel="NO" | ||||||
|  |  | ||||||
| # Set rc_interactive to "YES" and you'll be able to press the I key during | # 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. | # come up. | ||||||
| rc_depend_strict="YES" | rc_depend_strict="YES" | ||||||
|  |  | ||||||
| # Do we allow services to be hotplugged? If not, set to rc_hotplug="NO" | # rc_hotplug is a list of services that we allow to be hotplugged. | ||||||
| # NOTE: This does not affect anything hotplug/udev/devd related, just the | # By default we do not allow hotplugging. | ||||||
| # starting/stopping of the init.d service triggered by it. | # A hotplugged service is one started by a dynamic dev manager when a matching | ||||||
| rc_hotplug="YES" | # hardware device is found. | ||||||
|  | # This service is intrinsically included in the boot runlevel. | ||||||
| # Dynamic /dev managers can trigger coldplug events which cause services to | # To disable services, prefix with a ! | ||||||
| # start before we are ready for them. If this happens, we can defer these | # Example - rc_hotplug="net.wlan !net.*" | ||||||
| # 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.*" |  | ||||||
| # This allows net.wlan and any service not matching net.* to be plugged. | # 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 | # rc_logger launches a logging daemon to log the entire rc process to | ||||||
| # /var/log/rc.log | # /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" | rc_logger="NO" | ||||||
|  |  | ||||||
| # By default we filter the environment for our running scripts. To allow other | # 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. | # variables through, add them here. Use a * to allow all variables through. | ||||||
| # rc_env_allow="VAR1 VAR2" | # 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 | # MISC CONFIGURATION VARIABLES | ||||||
| # There variables are shared between many init scripts | # There variables are shared between many init scripts | ||||||
|   | |||||||
| @@ -10,12 +10,9 @@ | |||||||
| trap : SIGINT | trap : SIGINT | ||||||
| trap "echo 'Boot interrupted'; exit 1" SIGQUIT | trap "echo 'Boot interrupted'; exit 1" SIGQUIT | ||||||
|  |  | ||||||
| # BSD's init works somewhat differently to sysvinit. | /sbin/rc sysinit || exit 1 | ||||||
| # This block should 'translate' from the way init calls it to the way it would | /sbin/rc boot || exit 1 | ||||||
| # be called by sysvinit on linux. | /sbin/rc default | ||||||
| RUNLEVEL="1" /sbin/rc sysinit || exit 1 |  | ||||||
| RUNLEVEL="1" /sbin/rc boot || exit 1 |  | ||||||
| PREVLEVEL="1" /sbin/rc default |  | ||||||
|  |  | ||||||
| # We don't actually care if rc default worked or not, we should exit 0 | # We don't actually care if rc default worked or not, we should exit 0 | ||||||
| # to allow logins | # to allow logins | ||||||
|   | |||||||
| @@ -14,13 +14,4 @@ export LD_LIBRARY_PATH="/lib${LD_LIBRARY_PATH:+:}${LDLIBRARY_PATH}" | |||||||
| [ -z "$TERM" -o "$TERM" = "dumb" ] && export TERM="@TERM@" | [ -z "$TERM" -o "$TERM" = "dumb" ] && export TERM="@TERM@" | ||||||
|  |  | ||||||
| action=${1:-shutdown} | 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}" | exec /sbin/rc "${action}" | ||||||
|   | |||||||
							
								
								
									
										9
									
								
								init.d.misc/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								init.d.misc/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,9 +0,0 @@ | |||||||
| avahi-dnsconfd |  | ||||||
| avahid |  | ||||||
| dbus |  | ||||||
| hald |  | ||||||
| named |  | ||||||
| ntpd |  | ||||||
| openvpn |  | ||||||
| polkitd |  | ||||||
| sshd |  | ||||||
							
								
								
									
										41
									
								
								init.d/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										41
									
								
								init.d/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -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 |  | ||||||
| @@ -1,6 +1,6 @@ | |||||||
| DIR=	${INITDIR} | DIR=	${INITDIR} | ||||||
| SRCS=	bootmisc.in fsck.in halt.sh.in hostname.in local.in localmount.in \ | SRCS=	bootmisc.in fsck.in hostname.in local.in localmount.in \ | ||||||
| 	netmount.in root.in swap.in sysctl.in urandom.in | 	netmount.in root.in savecache.in swap.in sysctl.in urandom.in | ||||||
| BIN=	${OBJS} | BIN=	${OBJS} | ||||||
|  |  | ||||||
| INSTALLAFTER=	_installafter | INSTALLAFTER=	_installafter | ||||||
|   | |||||||
| @@ -1,7 +1,8 @@ | |||||||
| NET_LO=	net.lo | NET_LO=	net.lo | ||||||
|  |  | ||||||
| SRCS+=	hwclock.in consolefont.in keymaps.in modules.in mtab.in numlock.in \ | SRCS+=	devfs.in dmesg.in hwclock.in consolefont.in keymaps.in killprocs.in \ | ||||||
| 	procfs.in termencoding.in | 	modules.in mount-ro.in mtab.in numlock.in procfs.in sysfs.in \ | ||||||
|  | 	termencoding.in | ||||||
|  |  | ||||||
| .SUFFIXES:	.Linux.in | .SUFFIXES:	.Linux.in | ||||||
| .Linux.in: | .Linux.in: | ||||||
|   | |||||||
| @@ -77,10 +77,13 @@ start() | |||||||
| 	if dir_writeable /var/run; then | 	if dir_writeable /var/run; then | ||||||
| 		ebegin "Creating user login records" | 		ebegin "Creating user login records" | ||||||
| 		cp /dev/null /var/run/utmp | 		cp /dev/null /var/run/utmp | ||||||
|  | 		chgrp utmp /var/run/utmp | ||||||
|  | 		chmod 0664 /var/run/utmp | ||||||
| 		if dir_writeable /var/log; then | 		if dir_writeable /var/log; then | ||||||
| 			logw=true | 			logw=true | ||||||
| 			[ -e /var/log/wtmp ] || cp /dev/null /var/log/wtmp | 			[ -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 | 		fi | ||||||
| 		eend 0 | 		eend 0 | ||||||
|  |  | ||||||
| @@ -88,7 +91,15 @@ start() | |||||||
| 		for x in $(find /var/run ! -type d ! -name utmp \ | 		for x in $(find /var/run ! -type d ! -name utmp \ | ||||||
| 			! -name random-seed ! -name dev.db \ | 			! -name random-seed ! -name dev.db \ | ||||||
| 			! -name ld-elf.so.hints ! -name ld.so.hints); | 			! -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 | 			[ ! -f "${x}" ] && continue | ||||||
| 			# Do not remove pidfiles of already running daemons | 			# Do not remove pidfiles of already running daemons | ||||||
| 			case "${x}" in | 			case "${x}" in | ||||||
|   | |||||||
							
								
								
									
										36
									
								
								init.d/devfs.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								init.d/devfs.in
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										18
									
								
								init.d/dmesg.in
									
									
									
									
									
										Normal 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 | ||||||
|  | } | ||||||
| @@ -8,7 +8,7 @@ _IFS=" | |||||||
|  |  | ||||||
| depend() | depend() | ||||||
| { | { | ||||||
| 	after clock modules | 	use dev clock modules | ||||||
| 	keyword nojail noopenvz noprefix notimeout novserver | 	keyword nojail noopenvz noprefix notimeout novserver | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -25,15 +25,20 @@ _reboot() { | |||||||
| 	fi | 	fi | ||||||
| } | } | ||||||
|  |  | ||||||
|  | _forcefsck() | ||||||
|  | { | ||||||
|  | 	[ -e /forcefsck ] || get_bootparam forcefsck | ||||||
|  | } | ||||||
|  |  | ||||||
| start() | start() | ||||||
| { | { | ||||||
| 	local reboot_opts= fsck_opts= p= check_extra= | 	local fsck_opts= p= check_extra= | ||||||
|  |  | ||||||
| 	if [ -e /fastboot ]; then | 	if [ -e /fastboot ]; then | ||||||
| 		ewarn "Skipping fsck due to /fastboot" | 		ewarn "Skipping fsck due to /fastboot" | ||||||
| 		return 0 | 		return 0 | ||||||
| 	fi | 	fi | ||||||
| 	if [ -e /forcefsck ]; then | 	if _forcefsck; then | ||||||
| 		fsck_opts="${fsck_opts} -f" | 		fsck_opts="${fsck_opts} -f" | ||||||
| 		check_extra="(check forced)" | 		check_extra="(check forced)" | ||||||
| 	fi | 	fi | ||||||
| @@ -60,21 +65,31 @@ start() | |||||||
| 				fsck_opts="${fsck_opts} -R" | 				fsck_opts="${fsck_opts} -R" | ||||||
| 			fi | 			fi | ||||||
| 		fi | 		fi | ||||||
| 		reboot_opts="-f" |  | ||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
| 	trap : INT QUIT | 	trap : INT QUIT | ||||||
| 	fsck ${fsck_args--p} ${fsck_opts} "$@" | 	fsck ${fsck_args--p} ${fsck_opts} "$@" | ||||||
| 	case $? in | 	case $? in | ||||||
| 		0)       eend 0; return 0;; | 	0)	eend 0; return 0;; | ||||||
| 		1)       ewend 1 "Filesystems repaired"; return 0;; | 	1)	ewend 1 "Filesystems repaired"; return 0;; | ||||||
| 		2|3|4)   ewend 1 "Filesystems repaired, but reboot needed" | 	2|3)	if [ "${RC_UNAME}" = "Linux" ]; then | ||||||
| 		         _reboot ${reboot_opts} || return 1;; | 		 	ewend 1 "Filesystems repaired, but reboot needed" | ||||||
| 		8)       ewend 1 "Operational error"; return 0;; | 	         	_reboot -f | ||||||
| 		12)      ewend 1 "fsck interupted"; return 1;; | 		else | ||||||
| 		*)       eend 2 "Filesystems couldn't be fixed" | 			ewend 1 "Filesystems still have errors; manual fsck required" | ||||||
| 		         _abort || return 1;; | 		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 | 	esac | ||||||
|  | 	_abort || return 1 | ||||||
| } | } | ||||||
|  |  | ||||||
| stop() | stop() | ||||||
| @@ -82,6 +97,7 @@ stop() | |||||||
| 	# Fake function so we always shutdown correctly. | 	# Fake function so we always shutdown correctly. | ||||||
| 	_abort() { return 0; } | 	_abort() { return 0; } | ||||||
| 	_reboot() { return 0; } | 	_reboot() { return 0; } | ||||||
|  | 	_forcefsck() { return 1; } | ||||||
|  |  | ||||||
| 	yesno "${fsck_shutdown}" && start | 	yesno "${fsck_shutdown}" && start | ||||||
| 	return 0 | 	return 0 | ||||||
|   | |||||||
| @@ -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 |  | ||||||
| @@ -38,9 +38,11 @@ _set() | |||||||
| # otherwise we generate a random UUID. | # otherwise we generate a random UUID. | ||||||
| reset() | reset() | ||||||
| { | { | ||||||
| 	local uuid=$(kenv smbios.system.uuid 2>/dev/null) | 	local uuid= x="[0-9a-f]" y="${x}${x}${x}${x}" | ||||||
| 	local x="[0-9a-f]" |  | ||||||
| 	local 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 | 	case "${uuid}" in | ||||||
| 		${y}${y}-${y}-${y}-${y}-${y}${y}${y});; | 		${y}${y}-${y}-${y}-${y}-${y}${y}${y});; | ||||||
| 		*) uuid=;; | 		*) uuid=;; | ||||||
|   | |||||||
| @@ -74,8 +74,14 @@ start() | |||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
| 	ebegin "Setting system clock using the hardware clock [${utc}]" | 	ebegin "Setting system clock using the hardware clock [${utc}]" | ||||||
| 	if [ -e /proc/modules -a ! -e /dev/rtc ]; then | 	if [ -e /proc/modules ]; then | ||||||
| 		modprobe -q rtc || modprobe -q genrtc | 		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 | 	fi | ||||||
|  |  | ||||||
| 	if [ -e /etc/adjtime ] && yesno ${clock_adjfile}; then | 	if [ -e /etc/adjtime ] && yesno ${clock_adjfile}; then | ||||||
|   | |||||||
| @@ -20,6 +20,10 @@ ipfw() { | |||||||
| 	/sbin/ipfw -f -q "$@" | 	/sbin/ipfw -f -q "$@" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | have_ip6() { | ||||||
|  | 	sysctl net.ipv6 2>/dev/null | ||||||
|  | } | ||||||
|  |  | ||||||
| init() { | init() { | ||||||
| 	# Load the kernel module | 	# Load the kernel module | ||||||
| 	if ! sysctl net.inet.ip.fw.enable=1 >/dev/null 2>&1; then | 	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 all from any to 127.0.0.0/8 | ||||||
| 	ipfw add deny ip from 127.0.0.0/8 to any | 	ipfw add deny ip from 127.0.0.0/8 to any | ||||||
|  |  | ||||||
| 	ipfw add pass ip6 from any to any via lo0 | 	if have_ip6; then  | ||||||
| 	ipfw add deny ip6 from any to ::1 | 		ipfw add pass ip6 from any to any via lo0 | ||||||
| 	ipfw add deny ip6 from ::1 to any | 		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 :: 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 fe80::/10 proto ipv6-icmp | ||||||
| 	ipfw add pass ip6 from fe80::/10 to ff02::/16 proto ipv6-icmp | 		ipfw add pass ip6 from fe80::/10 to ff02::/16 proto ipv6-icmp | ||||||
|  | 	fi | ||||||
| } | } | ||||||
|  |  | ||||||
| start() { | start() { | ||||||
| @@ -62,9 +68,11 @@ start() { | |||||||
| 	ipfw add pass udp  from me  to any       keep-state | 	ipfw add pass udp  from me  to any       keep-state | ||||||
| 	ipfw add pass icmp 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 | 	if have_ip6; then | ||||||
| 	ipfw add pass udp  from me6 to any       keep-state | 		ipfw add pass tcp  from me6 to any setup keep-state | ||||||
| 	ipfw add pass icmp from me6 to any       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. | 	# Allow DHCP. | ||||||
| 	ipfw add pass udp  from 0.0.0.0 68 to 255.255.255.255 67 out | 	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. | 	# Allow "mandatory" ICMP in. | ||||||
| 	ipfw add pass icmp from any to any icmptype 3,4,11 | 	ipfw add pass icmp from any to any icmptype 3,4,11 | ||||||
|  |  | ||||||
| 	# Allow ICMPv6 destination unreach | 	if have_ip6; then | ||||||
| 	ipfw add pass ip6 from any to any icmp6types 1 proto ipv6-icmp | 		# 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 | 		# 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 | 	# Add permits for this workstations published services below | ||||||
| 	# Only IPs and nets in firewall_allowservices is allowed in. | 	# Only IPs and nets in firewall_allowservices is allowed in. | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								init.d/killprocs.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								init.d/killprocs.in
									
									
									
									
									
										Normal 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 | ||||||
|  | } | ||||||
| @@ -39,5 +39,5 @@ stop() | |||||||
| 		. @SYSCONFDIR@/conf.d/local.stop | 		. @SYSCONFDIR@/conf.d/local.stop | ||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
| 	eend $? $"Failed to stop local" | 	eend $? "Failed to stop local" | ||||||
| } | } | ||||||
|   | |||||||
| @@ -30,13 +30,13 @@ start() | |||||||
| stop() | stop() | ||||||
| { | { | ||||||
| 	# We never unmount / or /dev or $RC_SVCDIR | 	# 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 | 	# RC_NO_UMOUNTS is an env var that can be set by plugins | ||||||
| 	OIFS=${IFS} SIFS=${IFS-y} | 	OIFS=${IFS} SIFS=${IFS-y} | ||||||
| 	IFS=$IFS: | 	IFS=$IFS: | ||||||
| 	for x in ${no_umounts} ${RC_NO_UMOUNTS}; do | 	for x in ${no_umounts} ${RC_NO_UMOUNTS}; do | ||||||
| 		no_umounts="${no_umounts}|${x}" | 		no_umounts_r="${no_umounts_r}|${x}" | ||||||
| 	done | 	done | ||||||
| 	if [ "${SIFS}" = "y" ]; then | 	if [ "${SIFS}" = "y" ]; then | ||||||
| 		IFS=$OIFS | 		IFS=$OIFS | ||||||
| @@ -45,9 +45,9 @@ stop() | |||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
| 	if [ "${RC_UNAME}" = "Linux" ]; then | 	if [ "${RC_UNAME}" = "Linux" ]; then | ||||||
| 		no_umounts="${no_umounts}|/proc|/proc/.*|/sys|/sys/.*" | 		no_umounts_r="${no_umounts_r}|/proc|/proc/.*|/sys|/sys/.*" | ||||||
| 	fi | 	fi | ||||||
| 	no_umounts="^(${no_umounts})$" | 	no_umounts_r="^(${no_umounts_r})$" | ||||||
|  |  | ||||||
| 	# Flush all pending disk writes now | 	# Flush all pending disk writes now | ||||||
| 	sync; sync | 	sync; sync | ||||||
| @@ -63,7 +63,7 @@ stop() | |||||||
| 	# Umount loopback devices | 	# Umount loopback devices | ||||||
| 	einfo "Unmounting loopback devices" | 	einfo "Unmounting loopback devices" | ||||||
| 	eindent | 	eindent | ||||||
| 	do_unmount "umount -d" --skip-point-regex "${no_umounts}" \ | 	do_unmount "umount -d" --skip-point-regex "${no_umounts_r}" \ | ||||||
| 		--node-regex "^/dev/loop" | 		--node-regex "^/dev/loop" | ||||||
| 	eoutdent | 	eoutdent | ||||||
|  |  | ||||||
| @@ -76,7 +76,7 @@ stop() | |||||||
| 		fs="${fs}${fs:+|}${x}" | 		fs="${fs}${fs:+|}${x}" | ||||||
| 	done | 	done | ||||||
| 	[ -n "${fs}" ] && fs="^(${fs})$" | 	[ -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 | 		${fs:+--skip-fstype-regex} ${fs} --nonetdev | ||||||
| 	eoutdent | 	eoutdent | ||||||
|  |  | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ start() | |||||||
| 	x=${KV#*.*.} | 	x=${KV#*.*.} | ||||||
| 	local KV_MICRO=${x%%-*} | 	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}" \ | 	for x in "${KV}" \ | ||||||
| 		${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \ | 		${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \ | ||||||
| 		${KV_MAJOR}.${KV_MINOR} \ | 		${KV_MAJOR}.${KV_MINOR} \ | ||||||
| @@ -34,25 +34,30 @@ start() | |||||||
| 	[ -z "${list}" ] && list=${modules} | 	[ -z "${list}" ] && list=${modules} | ||||||
|  |  | ||||||
| 	for x in ${list}; do | 	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}") | 		xx=$(shell_var "${x}") | ||||||
| 		for y in "${KV}" \ | 		for y in "${KV}" \ | ||||||
| 			${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \ | 			${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} \ | ||||||
| 			${KV_MAJOR}.${KV_MINOR} \ | 			${KV_MAJOR}.${KV_MINOR} \ | ||||||
| 		; do | 		; do | ||||||
|  | 			eval args=\$module_${aa}_args_$(shell_var "${y}") | ||||||
|  | 			[ -n "${args}" ] && break | ||||||
| 			eval args=\$module_${xx}_args_$(shell_var "${y}") | 			eval args=\$module_${xx}_args_$(shell_var "${y}") | ||||||
| 			[ -n "${args}" ] && break | 			[ -n "${args}" ] && break | ||||||
| 		done | 		done | ||||||
|  | 		[ -z "${args}" ] && eval args=\$module_${aa}_args | ||||||
| 		[ -z "${args}" ] && eval args=\$module_${xx}_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)) | 		eend $? "Failed to load ${x}" && cnt=$((${cnt} + 1)) | ||||||
| 	done | 	done | ||||||
| 	einfo "Autoloaded ${cnt} module(s)" | 	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
									
								
							
							
						
						
									
										45
									
								
								init.d/mount-ro.in
									
									
									
									
									
										Normal 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 $? | ||||||
|  | } | ||||||
| @@ -445,6 +445,35 @@ _load_config() | |||||||
| 	config_index=-1 | 	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() | start() | ||||||
| { | { | ||||||
| 	local IFACE=${RC_SVCNAME#*.} oneworked=false module= | 	local IFACE=${RC_SVCNAME#*.} oneworked=false module= | ||||||
| @@ -566,7 +595,7 @@ ${routes}" | |||||||
| 		fi | 		fi | ||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
| 	local OIFS="${IFS}" SIFS=${IFS-y} | 	local OIFS="${IFS}" SIFS="${IFS-y}" | ||||||
| 	local IFS="$__IFS" | 	local IFS="$__IFS" | ||||||
| 	for cmd in ${routes}; do | 	for cmd in ${routes}; do | ||||||
| 		unset IFS | 		unset IFS | ||||||
| @@ -581,7 +610,8 @@ ${routes}" | |||||||
| 			-net" "*|-host" "*);; | 			-net" "*|-host" "*);; | ||||||
| 			*" "netmask" "*)                   cmd="-net ${cmd}";; | 			*" "netmask" "*)                   cmd="-net ${cmd}";; | ||||||
| 			*.*.*.*/32*)                       cmd="-host ${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}";; | 			*)                                 cmd="-host ${cmd}";; | ||||||
| 		esac | 		esac | ||||||
| 		if ${hidefirstroute}; then | 		if ${hidefirstroute}; then | ||||||
| @@ -668,7 +698,7 @@ stop() | |||||||
| 	if ! yesno ${IN_BACKGROUND} && \ | 	if ! yesno ${IN_BACKGROUND} && \ | ||||||
| 	[ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then | 	[ "${IFACE}" != "lo" -a "${IFACE}" != "lo0" ]; then | ||||||
| 		eval module=\$ifdown_${IFVAR} | 		eval module=\$ifdown_${IFVAR} | ||||||
| 		module=${module:-YES} | 		module=${module:-${ifdown:-YES}} | ||||||
| 		yesno ${module} && _down 2>/dev/null | 		yesno ${module} && _down 2>/dev/null | ||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
|   | |||||||
| @@ -34,8 +34,8 @@ depend() | |||||||
| 	config /etc/fstab | 	config /etc/fstab | ||||||
| 	need net ${pmap} | 	need net ${pmap} | ||||||
| 	use afc-client amd autofs openvpn | 	use afc-client amd autofs openvpn | ||||||
| 	use dns nfs nfsmount portmap rpcbind rpc.statd | 	use dns nfs nfsmount portmap rpcbind rpc.statd rpc.lockd | ||||||
| 	keyword nojail noopenvz noprefix novserver | 	keyword nojail noprefix novserver | ||||||
| } | } | ||||||
|  |  | ||||||
| start() | start() | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ description="Mounts misc filesystems in /proc." | |||||||
|  |  | ||||||
| depend() | depend() | ||||||
| { | { | ||||||
|  | 	use devfs | ||||||
| 	need localmount | 	need localmount | ||||||
| 	keyword noopenvz noprefix novserver | 	keyword noopenvz noprefix novserver | ||||||
| } | } | ||||||
| @@ -39,7 +40,7 @@ start() | |||||||
| 	# Setup Kernel Support for the NFS daemon status | 	# Setup Kernel Support for the NFS daemon status | ||||||
| 	if [ -d /proc/fs/nfsd ] && ! mountinfo -q /proc/fs/nfsd; then | 	if [ -d /proc/fs/nfsd ] && ! mountinfo -q /proc/fs/nfsd; then | ||||||
| 		if grep -qs nfsd /proc/filesystems; then | 		if grep -qs nfsd /proc/filesystems; then | ||||||
| 			ebegin "Mounting nfsd filesystem" | 			ebegin "Mounting NFS filesystem" | ||||||
| 			mount -t nfsd -o nodev,noexec,nosuid \ | 			mount -t nfsd -o nodev,noexec,nosuid \ | ||||||
| 				nfsd /proc/fs/nfsd | 				nfsd /proc/fs/nfsd | ||||||
| 			eend $? | 			eend $? | ||||||
| @@ -56,26 +57,6 @@ start() | |||||||
| 		fi | 		fi | ||||||
| 	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 | 	# Setup Kernel Support for SELinux | ||||||
| 	if [ -d /selinux ] && ! mountinfo -q /selinux; then | 	if [ -d /selinux ] && ! mountinfo -q /selinux; then | ||||||
| 		if grep -qs selinuxfs /proc/filesystems; then | 		if grep -qs selinuxfs /proc/filesystems; then | ||||||
|   | |||||||
							
								
								
									
										25
									
								
								init.d/savecache.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								init.d/savecache.in
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										63
									
								
								init.d/sysfs.in
									
									
									
									
									
										Normal 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} | ||||||
|  | } | ||||||
| @@ -18,7 +18,7 @@ MAKE_LINKS=	suffix=$${man\#*.}; \ | |||||||
|  |  | ||||||
| MK=		../mk | MK=		../mk | ||||||
| include ${MK}/sys.mk | include ${MK}/sys.mk | ||||||
| include ${MK}/gitignore.mk | include ${MK}/svnignore.mk | ||||||
|  |  | ||||||
| all: | all: | ||||||
|  |  | ||||||
|   | |||||||
| @@ -202,4 +202,4 @@ Rinse and repeat for the other verbose functions. | |||||||
| .Sh SEE ALSO | .Sh SEE ALSO | ||||||
| .Xr printf 3 , | .Xr printf 3 , | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -61,4 +61,4 @@ does the same and also prints the full path of the service to stdout. | |||||||
| .Xr rc 8 , | .Xr rc 8 , | ||||||
| .Xr stdout 3 | .Xr stdout 3 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -61,4 +61,4 @@ Show information only for the named | |||||||
| .Xr rc 8 , | .Xr rc 8 , | ||||||
| .Xr rc-update 8 | .Xr rc-update 8 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -77,4 +77,4 @@ Show all services. | |||||||
| .Xr rc 8 , | .Xr rc 8 , | ||||||
| .Xr rc-status 8 | .Xr rc-status 8 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
							
								
								
									
										25
									
								
								man/rc.8
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								man/rc.8
									
									
									
									
									
								
							| @@ -22,7 +22,7 @@ | |||||||
| .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||||
| .\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||||
| .\" | .\" | ||||||
| .Dd Feb 22, 2008 | .Dd November 03, 2008 | ||||||
| .Dt RC 8 SMM | .Dt RC 8 SMM | ||||||
| .Os OpenRC | .Os OpenRC | ||||||
| .Sh NAME | .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 | 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 | which deal with the mounting of filesystems, set the initial state of attached | ||||||
| peripherals and logging. | peripherals and logging. | ||||||
| Coldplugged services are added to the boot runlevel by the system. | Hotplugged services are added to the boot runlevel by the system. | ||||||
| All services in the boot runlevel are automatically included in all other | All services in the boot and sysinit runlevels are automatically included | ||||||
| runlevels except for those listed here. | in all other runlevels except for those listed here. | ||||||
| .It Ar single | .It Ar single | ||||||
| Stops all services and enters single user mode. | Stops all services except for those in the sysinit runlevel. | ||||||
| .It Ar reboot |  | ||||||
| Changes to the single runlevel and then reboots the host. |  | ||||||
| .It Ar shutdown | .It Ar shutdown | ||||||
| Changes to the single runlevel and then halts the host. | Changes to the single runlevel and then halts the host. | ||||||
| .El | .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 | .Sh SEE ALSO | ||||||
| .Xr rc-status 8 , | .Xr rc-status 8 , | ||||||
| .Xr rc-update 8 | .Xr rc-update 8 , | ||||||
|  | .Xr init 8 , | ||||||
|  | .Xr shutdown 8 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -70,4 +70,4 @@ is set to | |||||||
| .Xr rc_stringlist_free 3 , | .Xr rc_stringlist_free 3 , | ||||||
| .Xr sh 1 | .Xr sh 1 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -110,4 +110,4 @@ when done. | |||||||
| .Xr rc_stringlist_free 3 , | .Xr rc_stringlist_free 3 , | ||||||
| .Xr runscript 8 | .Xr runscript 8 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -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 free 3 , | ||||||
| .Xr queue 3 | .Xr queue 3 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -48,4 +48,4 @@ Plugins can affect the parent environemnt by writing NULL separated strings to | |||||||
| .Xr rc 8 , | .Xr rc 8 , | ||||||
| .Xr runscript 8 | .Xr runscript 8 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -63,4 +63,4 @@ Rinse and repeat for the other verbose functions. | |||||||
| .Xr free 3 | .Xr free 3 | ||||||
| .Xr rc_stringlist_free 3 | .Xr rc_stringlist_free 3 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -227,4 +227,4 @@ normally holds the volatile state data for services on a RAM backed disk. | |||||||
| .Xr rc_stringlist_free 3 , | .Xr rc_stringlist_free 3 , | ||||||
| .Xr start-stop-daemon 8 | .Xr start-stop-daemon 8 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -85,4 +85,4 @@ itself. | |||||||
| .Xr queue 3 , | .Xr queue 3 , | ||||||
| .Xr strcmp 3 | .Xr strcmp 3 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -22,7 +22,7 @@ | |||||||
| .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||||
| .\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||||
| .\" | .\" | ||||||
| .Dd Mar 19, 2008 | .Dd September 19, 2008 | ||||||
| .Dt RUNSCRIPT 8 SMM | .Dt RUNSCRIPT 8 SMM | ||||||
| .Os OpenRC | .Os OpenRC | ||||||
| .Sh NAME | .Sh NAME | ||||||
| @@ -111,11 +111,11 @@ You should define a | |||||||
| function for the service so that | function for the service so that | ||||||
| .Nm | .Nm | ||||||
| will start and stop it in the right order in relation to other services. | 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 | Here is a list of the functions you can use in a | ||||||
| .Ic depend | .Ic depend | ||||||
| function. You simply pass the names of the services to it to add to that | 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"  | .Bl -tag -width "RC_DEFAULTLEVEL"  | ||||||
| .It Ic need | .It Ic need | ||||||
| The service will refuse to start until needed services have started and it | 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 | does not equal 0 then output the string using | ||||||
| .Ic eerror | .Ic eerror | ||||||
| and !! in square brackets | and !! in square brackets | ||||||
| at the end of the line. Otherwise output ok in square brackets at the end of | at the end of the line. | ||||||
| the line. The value of | Otherwise output ok in square brackets at the end of the line. | ||||||
|  | The value of | ||||||
| .Ar retval | .Ar retval | ||||||
| is returned. | is returned. | ||||||
| .It Ic ewend Ar retval Op Ar string | .It Ic ewend Ar retval Op Ar string | ||||||
| @@ -193,6 +194,14 @@ output when the environment variable | |||||||
| .Va EINFO_VERBOSE | .Va EINFO_VERBOSE | ||||||
| is true. | is true. | ||||||
| .Bl -tag -width indent | .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 ... | .It Ic is_newer_than Ar file1 Ar file2 ... | ||||||
| If | If | ||||||
| .Ar file1 | .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 ... | .It Ic is_older_than Ar file1 Ar file2 ... | ||||||
| If | If | ||||||
| .Ar file1 | .Ar file1 | ||||||
| is older than | is newer than | ||||||
| .Ar file2 | .Ar file2 | ||||||
| return 0, otherwise 1. | return 0, otherwise 1. | ||||||
| If | If | ||||||
| @@ -432,6 +441,16 @@ show() | |||||||
| } | } | ||||||
|  |  | ||||||
| .Ed | .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 | .Sh SEE ALSO | ||||||
| .Xr einfo 3 , | .Xr einfo 3 , | ||||||
| .Xr rc 8 , | .Xr rc 8 , | ||||||
| @@ -442,4 +461,4 @@ show() | |||||||
| .Xr start-stop-daemon 8 , | .Xr start-stop-daemon 8 , | ||||||
| .Xr uname 1 | .Xr uname 1 | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| .\" Copyright 2007-2008 Roy Marples | .\" Copyright 2007-2009 Roy Marples | ||||||
| .\" All rights reserved | .\" All rights reserved | ||||||
| .\" | .\" | ||||||
| .\" Redistribution and use in source and binary forms, with or without | .\" 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 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||||
| .\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||||
| .\" | .\" | ||||||
| .Dd Feb 24, 2008 | .Dd January 1, 2009 | ||||||
| .Dt START-STOP-DAEMON 8 SMM | .Dt START-STOP-DAEMON 8 SMM | ||||||
| .Os OpenRC | .Os OpenRC | ||||||
| .Sh NAME | .Sh NAME | ||||||
| @@ -44,6 +44,11 @@ | |||||||
| .Sh DESCRIPTION | .Sh DESCRIPTION | ||||||
| .Nm | .Nm | ||||||
| provides a consistent method of starting, stopping and signalling daemons. | 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, | If a daemon cannot background by itself, nor create a pidfile, | ||||||
| .Nm | .Nm | ||||||
| can do it for the daemon in a secure fashion. | 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 | The | ||||||
| .Ar daemon | .Ar daemon | ||||||
| we start or stop. | we start or stop. | ||||||
| If the | If this option is not specified, then the first non option argument | ||||||
| .Ar daemon | is used. | ||||||
| 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 |  | ||||||
| .It Fl p , -pidfile Ar pidfile | .It Fl p , -pidfile Ar pidfile | ||||||
| When starting, we expect the daemon to create a valid | When starting, we expect the daemon to create a valid | ||||||
| .Ar pidfile | .Ar pidfile | ||||||
| @@ -97,10 +94,17 @@ name here also. | |||||||
| .It Fl t , -test | .It Fl t , -test | ||||||
| Print the action(s) that would be taken, but don't actually do anything. | 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. | 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 | .El | ||||||
| .Pp | .Pp | ||||||
| These options are only used for starting daemons: | These options are only used for starting daemons: | ||||||
| .Bl -tag -width indent | .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 | .It Fl b , -background | ||||||
| Force the daemon into the background. Some daemons don't create pidfiles, so a | 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 | 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 | .It Fl r , -chroot Ar path | ||||||
| chroot to this directory before starting the daemon. All other paths, such | 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. | 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 | .It Fl e , -env Ar VAR=VALUE | ||||||
| Set the environment variable VAR to VALUE. | Set the environment variable VAR to VALUE. | ||||||
| .It Fl g , -group Ar group | .It Fl g , -group Ar group | ||||||
| Start the daemon as in the 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 | .It Fl m , -make-pidfile | ||||||
| Saves the pid of the daemon in the file specified by the | Saves the pid of the daemon in the file specified by the | ||||||
| .Fl p , -pidfile | .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 | forced into the background with the | ||||||
| .Fl -b , -background | .Fl -b , -background | ||||||
| option. | option. | ||||||
| .It Fl n , -nice Ar level | .It Fl N , -nice Ar level | ||||||
| Modifies the scheduling priority of the daemon. | Modifies the scheduling priority of the daemon. | ||||||
| .It Fl 1 , -stdout Ar logfile | .It Fl 1 , -stdout Ar logfile | ||||||
| Redirect the standard output of the process to logfile when started with | 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 | .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 | You can either specify a timeout or a multiple signal/timeout pairs as a | ||||||
| stopping schedule. | 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. | assumed. | ||||||
| .El | .El | ||||||
| .Sh ENVIRONMENT | .Sh ENVIRONMENT | ||||||
| .Va SSD_NICELEVEL | .Va SSD_NICELEVEL | ||||||
| can also set the scheduling priority of the daemon, but the command line | can also set the scheduling priority of the daemon, but the command line | ||||||
| option takes precedence. | 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 | .Sh NOTE | ||||||
| .Nm | .Nm | ||||||
| uses | uses | ||||||
| @@ -163,6 +179,9 @@ to stop or signal. | |||||||
| .Xr getopt 3 , | .Xr getopt 3 , | ||||||
| .Xr nice 2 , | .Xr nice 2 , | ||||||
| .Xr rc_find_pids 3 | .Xr rc_find_pids 3 | ||||||
|  | .Sh BUGS | ||||||
|  | .Nm | ||||||
|  | cannot stop an interpreted daemon that no longer exists without a pidfile. | ||||||
| .Sh HISTORY | .Sh HISTORY | ||||||
| .Nm | .Nm | ||||||
| first appeared in Debian. | 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 | 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. | OpenRC library (librc, -lrc) so other programs can make use of it. | ||||||
| .Sh AUTHORS | .Sh AUTHORS | ||||||
| .An "Roy Marples" Aq roy@marples.name | .An Roy Marples <roy@marples.name> | ||||||
|   | |||||||
							
								
								
									
										31
									
								
								mk/cc.mk
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								mk/cc.mk
									
									
									
									
									
								
							| @@ -1,5 +1,4 @@ | |||||||
| # Copyright 2008 Roy Marples <roy@marples.name> | # Copyright 2008 Roy Marples <roy@marples.name> | ||||||
| # All rights reserved. Released under the 2-clause BSD license. |  | ||||||
|  |  | ||||||
| # Setup some good default CFLAGS | # Setup some good default CFLAGS | ||||||
| CFLAGS?=	-O2 | CFLAGS?=	-O2 | ||||||
| @@ -10,15 +9,25 @@ _CSTD_SH=	if test -n "${CSTD}"; then echo "-std=${CSTD}"; else echo ""; fi | |||||||
| _CSTD!=		${_CSTD_SH} | _CSTD!=		${_CSTD_SH} | ||||||
| CFLAGS+=	${_CSTD}$(shell ${_CSTD_SH}) | CFLAGS+=	${_CSTD}$(shell ${_CSTD_SH}) | ||||||
|  |  | ||||||
| # Try and use some good cc flags | # Try and use some good cc flags if we're building from git | ||||||
| _CC_FLAGS=	-pedantic -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \ | # We don't use -pedantic as it will warn about our perfectly valid | ||||||
| 		-Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \ | # use of %m in our logger. | ||||||
| 		-Wbad-function-cast -Wnested-externs -Wcomment -Winline \ | _CCFLAGS=	-Wall -Wextra -Wimplicit -Wshadow -Wformat=2 \ | ||||||
| 		-Wchar-subscripts -Wcast-align -Wno-format-nonliteral \ | 		-Wmissing-prototypes -Wmissing-declarations \ | ||||||
| 		-Wdeclaration-after-statement -Wsequence-point -Wextra | 		-Wmissing-noreturn -Wmissing-format-attribute \ | ||||||
| _CC_FLAGS_SH=	for f in ${_CC_FLAGS}; do \ | 		-Wnested-externs \ | ||||||
| 		if ${CC} $$f -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ | 		-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 \ | 		then printf "%s" "$$f "; fi \ | ||||||
| 		done | 		done; | ||||||
| _CC_FLAGS!=	${_CC_FLAGS_SH} | _CC_FLAGS!=	${_CC_FLAGS_SH} | ||||||
| CFLAGS+=	${_CC_FLAGS}$(shell ${CC_FLAGS_SH}) | CFLAGS+=	${_CC_FLAGS}$(shell ${_CC_FLAGS_SH}) | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ | |||||||
|  |  | ||||||
| _RC_DEBUG_SH=	case "${DEBUG}" in "") echo "";; *) echo "-DRC_DEBUG";; esac | _RC_DEBUG_SH=	case "${DEBUG}" in "") echo "";; *) echo "-DRC_DEBUG";; esac | ||||||
| _RC_DEBUG!=	${_RC_DEBUG_SH} | _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? | # Should we enable this with a different flag? | ||||||
| _LD_DEBUG_SH=	case "${DEBUG}" in "") echo "";; *) echo "-Wl,--rpath=../librc -Wl,--rpath=../libeinfo";; esac | _LD_DEBUG_SH=	case "${DEBUG}" in "") echo "";; *) echo "-Wl,--rpath=../librc -Wl,--rpath=../libeinfo";; esac | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								mk/depend-.mk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								mk/depend-.mk
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										3
									
								
								mk/depend-gmake.mk
									
									
									
									
									
										Normal 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 | ||||||
							
								
								
									
										16
									
								
								mk/depend.mk
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								mk/depend.mk
									
									
									
									
									
								
							| @@ -1,13 +1,17 @@ | |||||||
| # This only works for make implementations that always include a .depend if | # Generate .depend | ||||||
| # it exists. Only GNU make does not do this. |  | ||||||
|  |  | ||||||
| # Copyright 2008 Roy Marples <roy@marples.name> | # Copyright 2008 Roy Marples <roy@marples.name> | ||||||
| # All rights reserved. Released under the 2-clause BSD license. |  | ||||||
|  |  | ||||||
| CLEANFILES+=	.depend | CLEANFILES+=	.depend | ||||||
| IGNOREFILES+=	.depend | IGNOREFILES+=	.depend | ||||||
|  |  | ||||||
| .depend: ${SRCS} | .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 | ||||||
|   | |||||||
| @@ -2,11 +2,12 @@ | |||||||
| # Copyright 2008 Roy Marples <roy@marples.name> | # Copyright 2008 Roy Marples <roy@marples.name> | ||||||
| # All rights reserved. Released under the 2-clause BSD license. | # All rights reserved. Released under the 2-clause BSD license. | ||||||
|  |  | ||||||
| GITREF?=	HEAD |  | ||||||
| DISTPREFIX?=	${NAME}-${VERSION} | DISTPREFIX?=	${NAME}-${VERSION} | ||||||
| DISTFILE?=	${DISTPREFIX}.tar.bz2 | DISTFILE?=	${DISTPREFIX}.tar.bz2 | ||||||
|  |  | ||||||
| CLEANFILES+=	${DISTFILE} | CLEANFILES+=	${DISTFILE} | ||||||
|  |  | ||||||
| dist: | dist: | ||||||
| 	git archive --prefix=${DISTPREFIX}/ ${GITREF} | bzip2 > ${DISTFILE} | 	svn export . ${DISTPREFIX} | ||||||
|  | 	tar cjpf ${DISTFILE} ${DISTPREFIX} | ||||||
|  | 	rm -rf ${DISTPREFIX} | ||||||
|   | |||||||
| @@ -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 |  | ||||||
							
								
								
									
										12
									
								
								mk/lib.mk
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								mk/lib.mk
									
									
									
									
									
								
							| @@ -16,8 +16,11 @@ CLEANFILES+=		${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK} | |||||||
|  |  | ||||||
| .SUFFIXES:		.So | .SUFFIXES:		.So | ||||||
|  |  | ||||||
|  | .c.o: | ||||||
|  | 	${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ | ||||||
|  |  | ||||||
| .c.So: | .c.So: | ||||||
| 	${CC} ${PICFLAG} -DPIC ${CFLAGS} -c $< -o $@ | 	${CC} ${PICFLAG} -DPIC ${CPPFLAGS} ${CFLAGS} -c $< -o $@ | ||||||
|  |  | ||||||
| all: depend ${_LIBS} | all: depend ${_LIBS} | ||||||
|  |  | ||||||
| @@ -53,7 +56,12 @@ check test:: | |||||||
| clean: | clean: | ||||||
| 	rm -f ${OBJS} ${SOBJS} ${_LIBS} ${SHLIB_LINK} ${CLEANFILES} | 	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}/sys.mk | ||||||
| include ${MK}/os.mk | include ${MK}/os.mk | ||||||
| include ${MK}/depend.mk | include ${MK}/depend.mk | ||||||
| include ${MK}/gitignore.mk | include ${MK}/svnignore.mk | ||||||
|   | |||||||
| @@ -1,3 +1,3 @@ | |||||||
| LIBTERMCAP?=	-lncurses | LIBTERMCAP?=	-lncurses | ||||||
| CFLAGS+=	-DHAVE_TERMCAP | CPPFLAGS+=	-DHAVE_TERMCAP | ||||||
| LDADD+=		${LIBTERMCAP} | LDADD+=		${LIBTERMCAP} | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| # Copyright 2008 Roy Marples <roy@marples.name> | # Copyright 2008 Roy Marples <roy@marples.name> | ||||||
| # All rights reserved. Released under the 2-clause BSD license. | # 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 | LIBDL=		-Wl,-Bdynamic -ldl | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| LIBPAM?=	-lpam | LIBPAM?=	-lpam | ||||||
| CFLAGS+=	-DHAVE_PAM | CPPFLAGS+=	-DHAVE_PAM | ||||||
| LDADD+=		${LIBPAM} | LDADD+=		${LIBPAM} | ||||||
|  |  | ||||||
| PAMDIR?=	/etc/pam.d | PAMDIR?=	/etc/pam.d | ||||||
|   | |||||||
| @@ -24,13 +24,18 @@ CLEANFILES+=		${OBJS} ${PROG} | |||||||
|  |  | ||||||
| all: depend ${PROG} | all: depend ${PROG} | ||||||
|  |  | ||||||
|  | .c.o: | ||||||
|  | 	${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ | ||||||
|  |  | ||||||
| ${PROG}: ${SCRIPTS} ${OBJS} | ${PROG}: ${SCRIPTS} ${OBJS} | ||||||
| 	${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD} | 	${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD} | ||||||
|  |  | ||||||
| clean: | clean: | ||||||
| 	rm -f ${CLEANFILES} | 	rm -f ${CLEANFILES} | ||||||
|  |  | ||||||
|  | extra_depend: | ||||||
|  |  | ||||||
| include ${MK}/sys.mk | include ${MK}/sys.mk | ||||||
| include ${MK}/os.mk | include ${MK}/os.mk | ||||||
| include ${MK}/depend.mk | include ${MK}/depend.mk | ||||||
| include ${MK}/gitignore.mk | include ${MK}/svnignore.mk | ||||||
|   | |||||||
| @@ -56,4 +56,4 @@ CLEANFILES+=	${OBJS} | |||||||
| clean: | clean: | ||||||
| 	@if test -n "${CLEANFILES}"; then echo "rm -f ${CLEANFILES}"; rm -f ${CLEANFILES}; fi  | 	@if test -n "${CLEANFILES}"; then echo "rm -f ${CLEANFILES}"; rm -f ${CLEANFILES}; fi  | ||||||
|  |  | ||||||
| include ${MK}/gitignore.mk | include ${MK}/svnignore.mk | ||||||
|   | |||||||
| @@ -27,5 +27,5 @@ check test:: | |||||||
| 	${_SUBDIR} | 	${_SUBDIR} | ||||||
| depend: | depend: | ||||||
| 	${_SUBDIR} | 	${_SUBDIR} | ||||||
| gitignore: | ignore: | ||||||
| 	${_SUBDIR} | 	${_SUBDIR} | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								mk/svnignore.mk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								mk/svnignore.mk
									
									
									
									
									
										Normal 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 | ||||||
| @@ -1,3 +1,3 @@ | |||||||
| LIBTERMCAP?=	-ltermcap | LIBTERMCAP?=	-ltermcap | ||||||
| CFLAGS+=	-DHAVE_TERMCAP | CPPFLAGS+=	-DHAVE_TERMCAP | ||||||
| LDADD+=		${LIBTERMCAP} | LDADD+=		${LIBTERMCAP} | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								net/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								net/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,2 +0,0 @@ | |||||||
| ifconfig.sh |  | ||||||
| iwconfig.sh |  | ||||||
| @@ -4,7 +4,6 @@ | |||||||
| bonding_depend() | bonding_depend() | ||||||
| { | { | ||||||
| 	before interface macchanger | 	before interface macchanger | ||||||
| 	program /sbin/ifenslave |  | ||||||
| } | } | ||||||
|  |  | ||||||
| _config_vars="$_config_vars slaves" | _config_vars="$_config_vars slaves" | ||||||
| @@ -16,7 +15,7 @@ _is_bond() | |||||||
|  |  | ||||||
| bonding_pre_start() | bonding_pre_start() | ||||||
| { | { | ||||||
| 	local s= slaves="$(_get_array "slaves_${IFVAR}")"  | 	local x= s= slaves="$(_get_array "slaves_${IFVAR}")"  | ||||||
|  |  | ||||||
| 	[ -z "${slaves}" ] && return 0 | 	[ -z "${slaves}" ] && return 0 | ||||||
|  |  | ||||||
| @@ -40,6 +39,16 @@ bonding_pre_start() | |||||||
| 		return 1 | 		return 1 | ||||||
| 	fi | 	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}" | 	ebegin "Adding slaves to ${IFACE}" | ||||||
| 	eindent | 	eindent | ||||||
| 	einfo "${slaves}" | 	einfo "${slaves}" | ||||||
| @@ -53,7 +62,7 @@ bonding_pre_start() | |||||||
| 	# Must force the slaves to a particular state before adding them | 	# Must force the slaves to a particular state before adding them | ||||||
| 	for IFACE in ${slaves}; do | 	for IFACE in ${slaves}; do | ||||||
| 		_delete_addresses | 		_delete_addresses | ||||||
| 		_up | 		_down | ||||||
| 	done | 	done | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
| @@ -62,7 +71,13 @@ bonding_pre_start() | |||||||
|  |  | ||||||
| 	# finally add in slaves | 	# finally add in slaves | ||||||
| 	eoutdent | 	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 $? | 	eend $? | ||||||
|  |  | ||||||
| 	return 0 #important | 	return 0 #important | ||||||
| @@ -84,7 +99,13 @@ bonding_stop() | |||||||
| 	eindent | 	eindent | ||||||
| 	einfo "${slaves}" | 	einfo "${slaves}" | ||||||
| 	eoutdent | 	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 | 	# reset all slaves | ||||||
| 	( | 	( | ||||||
|   | |||||||
| @@ -16,12 +16,15 @@ _is_bridge() | |||||||
|  |  | ||||||
| bridge_pre_start() | bridge_pre_start() | ||||||
| { | { | ||||||
| 	local ports= brif= iface="${IFACE}" e= x= | 	local brif= iface="${IFACE}" e= x= | ||||||
| 	local ports="$(_get_array "bridge_${IFVAR}")" | 	local ports="$(_get_array "bridge_${IFVAR}")" | ||||||
| 	local opts="$(_get_array "brctl_${IFVAR}")" | 	local opts="$(_get_array "brctl_${IFVAR}")" | ||||||
| 	 | 	 | ||||||
| 	eval brif=\$bridge_add_${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 | 	[ -n "${ports}" ] && bridge_post_stop | ||||||
|  |  | ||||||
|   | |||||||
| @@ -17,6 +17,7 @@ dhcpcd_start() | |||||||
| { | { | ||||||
| 	local args= opt= opts= pidfile="/var/run/dhcpcd-${IFACE}.pid" new=true | 	local args= opt= opts= pidfile="/var/run/dhcpcd-${IFACE}.pid" new=true | ||||||
| 	eval args=\$dhcpcd_${IFVAR} | 	eval args=\$dhcpcd_${IFVAR} | ||||||
|  | 	[ -z "${args}" ] && args=${dhcpcd} | ||||||
|  |  | ||||||
| 	# Get our options | 	# Get our options | ||||||
| 	eval opts=\$dhcp_${IFVAR} | 	eval opts=\$dhcp_${IFVAR} | ||||||
|   | |||||||
| @@ -278,7 +278,7 @@ ifconfig_pre_start() | |||||||
| 	metric=1000 | 	metric=1000 | ||||||
| 	 | 	 | ||||||
| 	ebegin "Creating tunnel ${IFVAR}" | 	ebegin "Creating tunnel ${IFVAR}" | ||||||
| 	iptunnel add "${tunnel}" | 	iptunnel add ${tunnel} | ||||||
| 	eend $? | 	eend $? | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -31,13 +31,13 @@ ifplugd_pre_start() | |||||||
| 	for f in bond bridge tuntap vlan wireless; do | 	for f in bond bridge tuntap vlan wireless; do | ||||||
| 		if type "_is_${f}" >/dev/null 2>&1; then | 		if type "_is_${f}" >/dev/null 2>&1; then | ||||||
| 			if _is_${f}; then | 			if _is_${f}; then | ||||||
| 				veinfo "netplug does not work with" "${f}" | 				veinfo "ifplugd does not work with ${f}" | ||||||
| 				return 0 | 				return 0 | ||||||
| 			fi | 			fi | ||||||
| 		fi | 		fi | ||||||
| 	done | 	done | ||||||
|  |  | ||||||
| 	ebegin "Starting ifplugd on" "${IFACE}" | 	ebegin "Starting ifplugd on ${IFACE}" | ||||||
|  |  | ||||||
| 	eval args=\$ifplugd_${IFVAR} | 	eval args=\$ifplugd_${IFVAR} | ||||||
|  |  | ||||||
| @@ -47,7 +47,7 @@ ifplugd_pre_start() | |||||||
| 	# Start ifplugd | 	# Start ifplugd | ||||||
| 	eval start-stop-daemon --start --exec /usr/sbin/ifplugd \ | 	eval start-stop-daemon --start --exec /usr/sbin/ifplugd \ | ||||||
| 		--pidfile "${pidfile}" -- "${args}" --iface="${IFACE}" | 		--pidfile "${pidfile}" -- "${args}" --iface="${IFACE}" | ||||||
| 	eend "$?" || return 1 | 	eend $? || return 1 | ||||||
|  |  | ||||||
| 	eindent | 	eindent | ||||||
|  |  | ||||||
| @@ -85,7 +85,7 @@ ifplugd_stop() | |||||||
| 	local pidfile="/var/run/ifplugd.${IFACE}.pid" | 	local pidfile="/var/run/ifplugd.${IFACE}.pid" | ||||||
| 	[ ! -e "${pidfile}" ] && return 0 | 	[ ! -e "${pidfile}" ] && return 0 | ||||||
| 	 | 	 | ||||||
| 	ebegin "Stopping ifplugd on" "${IFACE}" | 	ebegin "Stopping ifplugd on ${IFACE}" | ||||||
| 	start-stop-daemon --stop --quiet --exec /usr/sbin/ifplugd \ | 	start-stop-daemon --stop --quiet --exec /usr/sbin/ifplugd \ | ||||||
| 		--pidfile "${pidfile}" --signal QUIT | 		--pidfile "${pidfile}" --signal QUIT | ||||||
| 	eend $? | 	eend $? | ||||||
|   | |||||||
| @@ -54,7 +54,6 @@ ifwatchd_stop() | |||||||
| 	ebegin "Stopping ifwatchd on" "${IFACE}" | 	ebegin "Stopping ifwatchd on" "${IFACE}" | ||||||
| 	start-stop-daemon --stop --exec /usr/sbin/ifwatchd \ | 	start-stop-daemon --stop --exec /usr/sbin/ifwatchd \ | ||||||
| 		-- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \ | 		-- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \ | ||||||
| 		-n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \ | 		-n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" | ||||||
| 		&& return 0 |  | ||||||
| 	eend $? | 	eend $? | ||||||
| } | } | ||||||
|   | |||||||
| @@ -137,7 +137,7 @@ iwconfig_associate() | |||||||
| 	case "${caps}" in | 	case "${caps}" in | ||||||
| 		[EI]P*) | 		[EI]P*) | ||||||
| 		if [ "${key}" = "-" ] ; then | 		if [ "${key}" = "-" ] ; then | ||||||
| 			ewarn "WEP key is not set for \"${SSID}\"; not connecting" | 			ewarn "WEP key is not set for \"${SSID}\"" | ||||||
| 			return 1 | 			return 1 | ||||||
| 		fi | 		fi | ||||||
| 		;; | 		;; | ||||||
| @@ -145,7 +145,7 @@ iwconfig_associate() | |||||||
| 		*) | 		*) | ||||||
| 		if [ "${key}" != "-" ] ; then | 		if [ "${key}" != "-" ] ; then | ||||||
| 			key="-" | 			key="-" | ||||||
| 			ewarn "\"${SSID}\" is not WEP enabled; ignoring setting" | 			ewarn "\"${SSID}\" is not WEP enabled" | ||||||
| 		fi | 		fi | ||||||
| 		;; | 		;; | ||||||
| 	esac | 	esac | ||||||
|   | |||||||
| @@ -250,12 +250,12 @@ iwconfig_associate() | |||||||
| 		SSIDVAR=$(shell_var "${SSID}") | 		SSIDVAR=$(shell_var "${SSID}") | ||||||
| 		key="$(iwconfig_get_wep_key "${mac}")" | 		key="$(iwconfig_get_wep_key "${mac}")" | ||||||
| 		if [ "${wep_required}" = "on" -a "${key}" = "off" ]; then | 		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 | 			return 1 | ||||||
| 		fi | 		fi | ||||||
| 		if [ "${wep_required}" = "off" -a "${key}" != "off" ]; then | 		if [ "${wep_required}" = "off" -a "${key}" != "off" ]; then | ||||||
| 			key="off" | 			key="off" | ||||||
| 			ewarn "\"${SSID}\" is not WEP enabled - ignoring setting" | 			ewarn "\"${SSID}\" is not WEP enabled" | ||||||
| 		fi | 		fi | ||||||
|  |  | ||||||
| 		if ! eval iwconfig "${IFACE}" key "${key}"; then | 		if ! eval iwconfig "${IFACE}" key "${key}"; then | ||||||
| @@ -433,7 +433,7 @@ iwconfig_scan() | |||||||
| 		[ -z "${a}" ] && break | 		[ -z "${a}" ] && break | ||||||
| 		eval b=\$QUALITY_${k} | 		eval b=\$QUALITY_${k} | ||||||
| 		if [ -n "${b}" -a "${a}" -lt "${b}" ]; then | 		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 t=\$${x}_${i} | ||||||
| 			eval ${x}_${i}=\$${x}_${k} | 			eval ${x}_${i}=\$${x}_${k} | ||||||
| 			eval ${x}_${k}=\$t | 			eval ${x}_${k}=\$t | ||||||
| @@ -457,7 +457,7 @@ iwconfig_scan() | |||||||
| 				local u=${k} | 				local u=${k} | ||||||
| 				# We need to split this into two tests, otherwise bash errors  | 				# We need to split this into two tests, otherwise bash errors  | ||||||
| 				[ -n "${a}" -a -n "${b}" ] && [ "${a}" -lt "${b}" ] && u=${i} | 				[ -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 | 			fi | ||||||
| 			k=$((${k} + 1)) | 			k=$((${k} + 1)) | ||||||
| 		done | 		done | ||||||
| @@ -503,7 +503,7 @@ iwconfig_scan() | |||||||
| 		for x; do | 		for x; do | ||||||
| 			if [ "${x}" = "${s}" ]; then | 			if [ "${x}" = "${s}" ]; then | ||||||
| 				ewarn "${s} has been blacklisted - not connecting" | 				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 | 			fi | ||||||
| 		done | 		done | ||||||
| 		i=$((${i} + 1)) | 		i=$((${i} + 1)) | ||||||
| @@ -601,10 +601,8 @@ iwconfig_connect_not_preferred() | |||||||
|  |  | ||||||
| iwconfig_defaults() | iwconfig_defaults() | ||||||
| { | { | ||||||
| 	local x= | 	# Turn on the radio | ||||||
| 	for x in txpower rate rts frag; do | 	iwconfig "${IFACE}" txpower on 2>/dev/null | ||||||
| 	    iwconfig "${IFACE}" "${x}" auto 2>/dev/null |  | ||||||
| 	done |  | ||||||
|  |  | ||||||
| 	# Release the AP forced | 	# Release the AP forced | ||||||
| 	# Must do ap and then ssid otherwise scanning borks | 	# Must do ap and then ssid otherwise scanning borks | ||||||
| @@ -739,7 +737,7 @@ iwconfig_pre_start() | |||||||
| 	# which reports NOT READY! | 	# which reports NOT READY! | ||||||
| 	x="$(iwconfig_get_type)" | 	x="$(iwconfig_get_type)" | ||||||
| 	if [ "${x}" = "NOT READY!" ]; then | 	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 | 		return 1 | ||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
|   | |||||||
| @@ -105,7 +105,15 @@ wpa_supplicant_pre_start() | |||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
| 	# Work out where the ctrl_interface dir is if it's not specified | 	# 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 | 	if [ -z "${ctrl_dir}" ]; then | ||||||
| 		ctrl_dir=${opts##* -C} | 		ctrl_dir=${opts##* -C} | ||||||
| 		if [ -n "${ctrl_dir}" -a "${ctrl_dir}" != "${opts}" ]; then | 		if [ -n "${ctrl_dir}" -a "${ctrl_dir}" != "${opts}" ]; then | ||||||
| @@ -120,7 +128,6 @@ wpa_supplicant_pre_start() | |||||||
| 	fi | 	fi | ||||||
| 	service_set_value ctrl_dir "${ctrl_dir}" | 	service_set_value ctrl_dir "${ctrl_dir}" | ||||||
|  |  | ||||||
|  |  | ||||||
| 	if [ -n "${wpac}" ]; then | 	if [ -n "${wpac}" ]; then | ||||||
| 		opts="${opts} -W" | 		opts="${opts} -W" | ||||||
| 	elif service_started devd; then | 	elif service_started devd; then | ||||||
|   | |||||||
| @@ -1,22 +1,33 @@ | |||||||
| BOOT=		bootmisc fsck hostname localmount \ | BOOT=		bootmisc fsck hostname localmount \ | ||||||
| 		root swap sysctl urandom | 		root swap sysctl urandom | ||||||
| DEFAULT=	local netmount | DEFAULT=	local netmount | ||||||
|  | SHUTDOWN=	savecache | ||||||
|  |  | ||||||
| LEVELDIR=	${DESTDIR}/${SYSCONFDIR}/runlevels | LEVELDIR=	${DESTDIR}/${SYSCONFDIR}/runlevels | ||||||
|  | SYSINITDIR=	${LEVELDIR}/sysinit | ||||||
| BOOTDIR=	${LEVELDIR}/boot | BOOTDIR=	${LEVELDIR}/boot | ||||||
| DEFAULTDIR=	${LEVELDIR}/default | DEFAULTDIR=	${LEVELDIR}/default | ||||||
|  | SHUTDOWNDIR=	${LEVELDIR}/shutdown | ||||||
|  |  | ||||||
| INITDIR=	../init.d | INITDIR=	../init.d | ||||||
|  |  | ||||||
| MK=		../mk | MK=		../mk | ||||||
| include ${MK}/sys.mk | include ${MK}/sys.mk | ||||||
| include ${MK}/os.mk | include ${MK}/os.mk | ||||||
| include ${MK}/gitignore.mk | include ${MK}/svnignore.mk | ||||||
| include Makefile.${OS} | include Makefile.${OS} | ||||||
|  |  | ||||||
| all: | all: | ||||||
|  |  | ||||||
| install: | 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 \ | 	if ! test -d "${BOOTDIR}"; then \ | ||||||
| 		${INSTALL} -d ${BOOTDIR} || exit $$?; \ | 		${INSTALL} -d ${BOOTDIR} || exit $$?; \ | ||||||
| 		for x in ${BOOT}; do \ | 		for x in ${BOOT}; do \ | ||||||
| @@ -35,6 +46,14 @@ install: | |||||||
| 			fi; \ | 			fi; \ | ||||||
| 			ln -snf ${PREFIX}/etc/init.d/"$$x" ${DEFAULTDIR}/"$$x" || exit $$?; done \ | 			ln -snf ${PREFIX}/etc/init.d/"$$x" ${DEFAULTDIR}/"$$x" || exit $$?; done \ | ||||||
| 	fi | 	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:: | check test:: | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,2 +1,3 @@ | |||||||
| BOOT+=		hwclock consolefont keymaps modules mtab net.lo procfs \ | SYSINIT+=	devfs dmesg | ||||||
| 		termencoding | BOOT+=		hwclock keymaps modules mtab net.lo procfs termencoding | ||||||
|  | SHUTDOWN+=	killprocs mount-ro | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								sh/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								sh/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,8 +0,0 @@ | |||||||
| functions.sh |  | ||||||
| gendepends.sh |  | ||||||
| net.sh |  | ||||||
| rc-functions.sh |  | ||||||
| runscript.sh |  | ||||||
| init.sh |  | ||||||
| ifwatchd-carrier.sh |  | ||||||
| ifwatchd-nocarrier.sh |  | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| DIR=	${PREFIX}/${RC_LIB}/sh | 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 | 	rc-functions.sh.in runscript.sh.in | ||||||
| INC=	init-common-post.sh rc-mount.sh functions.sh rc-functions.sh | INC=	init-common-post.sh rc-mount.sh functions.sh rc-functions.sh | ||||||
| BIN=	gendepends.sh init.sh runscript.sh | BIN=	gendepends.sh init.sh runscript.sh | ||||||
|   | |||||||
| @@ -6,23 +6,18 @@ retval=0 | |||||||
| # mount $svcdir as something we can write to if it's not rw | # 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 | # On vservers, / is always rw at this point, so we need to clean out | ||||||
| # the old service state data | # the old service state data | ||||||
|  | RC_SVCDIR=${RC_SVCDIR:-/@LIB@/rc/init.d} | ||||||
| if [ "${RC_SVCDIR}" != "/" ] && mkdir "${RC_SVCDIR}/.test.$$" 2>/dev/null; then | if [ "${RC_SVCDIR}" != "/" ] && mkdir "${RC_SVCDIR}/.test.$$" 2>/dev/null; then | ||||||
| 	rmdir "${RC_SVCDIR}/.test.$$" | 	rmdir "${RC_SVCDIR}/.test.$$" | ||||||
| 	for x in ${RC_SVCDIR:-/@LIB@/rc/init.d}/*; do | 	rm -rf "${RC_SVCDIR}"/* | ||||||
| 		[ -e "${x}" ] || continue |  | ||||||
| 		case ${x##*/} in |  | ||||||
| 			depconfig|deptree|ksoftlevel|rc.log);; |  | ||||||
| 			*) rm -rf "${x}";; |  | ||||||
| 		esac |  | ||||||
| 	done |  | ||||||
| else | else | ||||||
| 	mount_svcdir | 	mount_svcdir | ||||||
| 	retval=$? | 	retval=$? | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
|  | if [ -e "${RC_LIBDIR}"/cache/deptree ]; then | ||||||
|  | 	cp -p "${RC_LIBDIR}"/cache/* "${RC_SVCDIR}" 2>/dev/null | ||||||
|  | fi | ||||||
|  | 
 | ||||||
| echo "sysinit" > "${RC_SVCDIR}/softlevel" | 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} | exit ${retval} | ||||||
| @@ -10,18 +10,6 @@ | |||||||
| # FreeBSD-7 supports tmpfs now :) | # FreeBSD-7 supports tmpfs now :) | ||||||
| mount_svcdir() | 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 ! fstabinfo --mount "${RC_SVCDIR}"; then | ||||||
| 		if ! mount -t tmpfs -o rw,noexec,nosuid none "${RC_SVCDIR}" 2>/dev/null; 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 | 			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}" | 			mount -o rw,noexec,nosuid /dev/md0 "${RC_SVCDIR}" | ||||||
| 		fi | 		fi | ||||||
| 	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 | . "${RC_LIBDIR}"/sh/functions.sh | ||||||
|   | |||||||
| @@ -3,13 +3,13 @@ | |||||||
| # Copyright 2007-2008 Roy Marples <roy@marples.name> | # Copyright 2007-2008 Roy Marples <roy@marples.name> | ||||||
| # All rights reserved. Released under the 2-clause BSD license. | # All rights reserved. Released under the 2-clause BSD license. | ||||||
|  |  | ||||||
| # This basically mounts $RC_SVCDIR as a ramdisk, but preserving its content | # This basically mounts $RC_SVCDIR as a ramdisk. | ||||||
| # which allows us to store service state and generate dependencies if needed. |  | ||||||
| # The tricky part is finding something our kernel supports | # The tricky part is finding something our kernel supports | ||||||
| # tmpfs and ramfs are easy, so force one or the other. | # tmpfs and ramfs are easy, so force one or the other. | ||||||
| mount_svcdir() | 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} | 	local svcsize=${rc_svcsize:-1024} | ||||||
|  |  | ||||||
| 	if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then | 	if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then | ||||||
| @@ -18,55 +18,29 @@ mount_svcdir() | |||||||
| 	elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then | 	elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then | ||||||
| 		fs="ramfs" | 		fs="ramfs" | ||||||
| 		# ramfs has no special options | 		# ramfs has no special options | ||||||
| 	elif [ -e /dev/ram0 -a -e /dev/ram1 ] \ | 	elif [ -e /dev/ram0 ] \ | ||||||
| 		&& grep -Eq "[[:space:]]+ext2$" /proc/filesystems; then | 		&& grep -Eq "[[:space:]]+ext2$" /proc/filesystems; then | ||||||
| 		devdir="/dev/ram0" | 		devdir="/dev/ram0" | ||||||
| 		devtmp="/dev/ram1" |  | ||||||
| 		fs="ext2" | 		fs="ext2" | ||||||
| 		for x in ${devdir} ${devtmp}; do | 		dd if=/dev/zero of="${devdir}" bs=1k count="${svcsize}" | ||||||
| 			dd if=/dev/zero of="${x}" bs=1k count="${svcsize}" | 		mkfs -t "${fs}" -i 1024 -vm0 "${devdir}" "${svcsize}" | ||||||
| 			mkfs -t "${fs}" -i 1024 -vm0 "${x}" "${svcsize}" |  | ||||||
| 		done |  | ||||||
| 	else | 	else | ||||||
| 		echo | 		echo | ||||||
| 		eerror "OpenRC requires tmpfs, ramfs or 2 ramdisks + ext2" | 		eerror "OpenRC requires tmpfs, ramfs or a ramdisk + ext2" | ||||||
| 		eerror "compiled into the kernel" | 		eerror "compiled into the kernel" | ||||||
| 		echo | 		echo | ||||||
| 		return 1 | 		return 1 | ||||||
| 	fi | 	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 we have no entry in fstab for $RC_SVCDIR, provide our own | ||||||
| 	if ! fstabinfo --mount "${RC_SVCDIR}"; then | 	if ! fstabinfo --mount "${RC_SVCDIR}"; then | ||||||
| 		mount -n -t "${fs}" ${fsopts} "${devdir}" "${RC_SVCDIR}" | 		mount -n -t "${fs}" ${fsopts} "${devdir}" "${RC_SVCDIR}" | ||||||
| 	fi | 	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 | . /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 | [ -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! | # By default VServer already has /proc mounted, but OpenVZ does not! | ||||||
| # However, some of our users have an old proc image in /proc | # 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 | # 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" | 		einfo "/proc is already mounted, skipping" | ||||||
| 		mountproc=false | 		mountproc=false | ||||||
| 	fi | 	fi | ||||||
| 	unset up |  | ||||||
| fi | fi | ||||||
|  |  | ||||||
| if ${mountproc}; then | if ${mountproc}; then | ||||||
| @@ -94,95 +67,5 @@ if ${mountproc}; then | |||||||
| 	fi | 	fi | ||||||
| 	eend $? | 	eend $? | ||||||
| fi | 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 | . "${RC_LIBDIR}"/sh/init-common-post.sh | ||||||
|   | |||||||
| @@ -7,11 +7,21 @@ has_addon() | |||||||
| 	[ -e "${RC_LIBDIR}/addons/$1.sh" ] || [ -e /@LIB@/rcscripts/addons/"$1".sh ] | 	[ -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() | import_addon() | ||||||
| { | { | ||||||
| 	if [ -e "${RC_LIBDIR}/addons/$1.sh" ]; then | 	if [ -e "${RC_LIBDIR}/addons/$1.sh" ]; then | ||||||
|  | 		_addon_warn | ||||||
| 		. "${RC_LIBDIR}/addons/$1.sh" | 		. "${RC_LIBDIR}/addons/$1.sh" | ||||||
| 	elif [ -e /@LIB@/rcscripts/addons/"$1".sh ]; then | 	elif [ -e /@LIB@/rcscripts/addons/"$1".sh ]; then | ||||||
|  | 		_addon_warn | ||||||
| 		. /@LIB@/rcscripts/addons/"$1".sh | 		. /@LIB@/rcscripts/addons/"$1".sh | ||||||
| 	else | 	else | ||||||
| 		return 1 | 		return 1 | ||||||
| @@ -58,6 +68,7 @@ get_bootparam() | |||||||
|  |  | ||||||
| 	set -- $(cat /proc/cmdline) | 	set -- $(cat /proc/cmdline) | ||||||
| 	while [ -n "$1" ]; do | 	while [ -n "$1" ]; do | ||||||
|  | 		[ "$1" = "${match}" ] && return 0 | ||||||
| 		case "$1" in | 		case "$1" in | ||||||
| 			gentoo=*) | 			gentoo=*) | ||||||
| 				local params="${1##*=}" | 				local params="${1##*=}" | ||||||
|   | |||||||
| @@ -1,6 +1,10 @@ | |||||||
| # Copyright 2007-2008 Roy Marples <roy@marples.name> | # Copyright 2007-2008 Roy Marples <roy@marples.name> | ||||||
| # All rights reserved. Released under the 2-clause BSD license. | # 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 | # Handy function to handle all our unmounting needs | ||||||
| # mountinfo is a C program to actually find our mounts on our supported OS's | # 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. | # We rely on fuser being preset, so if it's not then we don't unmount anything. | ||||||
| @@ -15,17 +19,20 @@ do_unmount() | |||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
| 	shift | 	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 | 		# Unmounting a shared mount can unmount other mounts, so | ||||||
| 		# we need to check the mount is still valid | 		# we need to check the mount is still valid | ||||||
| 		mountinfo --quiet "${mnt}" || continue | 		mountinfo --quiet "${mnt}" || continue | ||||||
|  |  | ||||||
| 		case "${cmd}" in | 		case "${cmd}" in | ||||||
| 			umount*) | 			umount) | ||||||
| 				ebegin "Unmounting ${mnt}" | 				ebegin "Unmounting ${mnt}" | ||||||
| 				;; | 				;; | ||||||
| 			*) | 			*) | ||||||
| 				ebegin "Remounting ${mnt}" | 				ebegin "Remounting ${mnt} read only" | ||||||
| 				;; | 				;; | ||||||
| 		esac | 		esac | ||||||
|  |  | ||||||
|   | |||||||
| @@ -52,26 +52,20 @@ | |||||||
|  |  | ||||||
| #define ERRX fprintf (stderr, "out of memory\n"); exit (1) | #define ERRX fprintf (stderr, "out of memory\n"); exit (1) | ||||||
|  |  | ||||||
|  | #define UNCONST(a)		((void *)(unsigned long)(const void *)(a)) | ||||||
|  |  | ||||||
| #ifdef lint | #ifdef lint | ||||||
| # define _unused | # define _unused | ||||||
| #endif | #endif | ||||||
| #if __GNUC__ > 2 || defined(__INTEL_COMPILER) | #if __GNUC__ > 2 || defined(__INTEL_COMPILER) | ||||||
|  | # define _dead __attribute__((__noreturn__)) | ||||||
| # define _unused __attribute__((__unused__)) | # define _unused __attribute__((__unused__)) | ||||||
| #else | #else | ||||||
|  | # define _dead | ||||||
| # define _unused | # define _unused | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| /* Some libc implemntations don't have these */ | /* 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 | #ifndef TAILQ_CONCAT | ||||||
| #define TAILQ_CONCAT(head1, head2, field) do {                          \ | #define TAILQ_CONCAT(head1, head2, field) do {                          \ | ||||||
| 	if (!TAILQ_EMPTY(head2)) {                                      \ | 	if (!TAILQ_EMPTY(head2)) {                                      \ | ||||||
| @@ -83,13 +77,6 @@ | |||||||
| } while (0) | } while (0) | ||||||
| #endif | #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 | #ifndef TAILQ_FOREACH_SAFE | ||||||
| #define	TAILQ_FOREACH_SAFE(var, head, field, tvar)			\ | #define	TAILQ_FOREACH_SAFE(var, head, field, tvar)			\ | ||||||
| 	for ((var) = TAILQ_FIRST((head));				\ | 	for ((var) = TAILQ_FIRST((head));				\ | ||||||
| @@ -156,7 +143,6 @@ char *rc_conf_value(const char *var); | |||||||
| bool rc_conf_yesno(const char *var); | bool rc_conf_yesno(const char *var); | ||||||
| void env_filter(void); | void env_filter(void); | ||||||
| void env_config(void); | void env_config(void); | ||||||
| bool service_plugable(const char *service); |  | ||||||
| int signal_setup(int sig, void (*handler)(int)); | int signal_setup(int sig, void (*handler)(int)); | ||||||
| pid_t exec_service(const char *, const char *); | pid_t exec_service(const char *, const char *); | ||||||
|  |  | ||||||
| @@ -174,4 +160,5 @@ _unused static const char *basename_c(const char *path) | |||||||
| 	return (path); | 	return (path); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int parse_mode(mode_t *, char *); | ||||||
| #endif | #endif | ||||||
|   | |||||||
							
								
								
									
										7
									
								
								src/libeinfo/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								src/libeinfo/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,7 +0,0 @@ | |||||||
| .depend |  | ||||||
| libeinfo.o |  | ||||||
| libeinfo.So |  | ||||||
| libeinfo.a |  | ||||||
| libeinfo.so.1 |  | ||||||
| libeinfo.so |  | ||||||
| .depend |  | ||||||
| @@ -4,7 +4,7 @@ SRCS=			libeinfo.c | |||||||
| INCS=			einfo.h | INCS=			einfo.h | ||||||
| VERSION_MAP=		einfo.map | VERSION_MAP=		einfo.map | ||||||
|  |  | ||||||
| CFLAGS+=		-I../includes | CPPFLAGS+=		-I../includes | ||||||
|  |  | ||||||
| MK=			../../mk | MK=			../../mk | ||||||
| include ${MK}/lib.mk | include ${MK}/lib.mk | ||||||
|   | |||||||
| @@ -28,13 +28,11 @@ | |||||||
| #define __EINFO_H__ | #define __EINFO_H__ | ||||||
|  |  | ||||||
| #if defined(__GNUC__) | #if defined(__GNUC__) | ||||||
| # define __EINFO_PRINTF  __attribute__ ((__format__ (__printf__, 1, 2))) | # define EINFO_PRINTF(a, b)  __attribute__((__format__(__printf__, a, b))) | ||||||
| # define __EINFO_XPRINTF __attribute__ ((__noreturn__, __format__ (__printf__, 1, 2))) | # define EINFO_XPRINTF(a, b) __attribute__((__noreturn__,__format__(__printf__, a, b))) | ||||||
| # define __EEND_PRINTF   __attribute__ ((__format__ (__printf__, 2, 3))) |  | ||||||
| #else | #else | ||||||
| # define __EINFO_PRINTF | # define EINFO_PRINTF(a, b) | ||||||
| # define __EINFO_XPRINTF | # define EINFO_XPRINTF(a, b) | ||||||
| # define __EEND_PRINTF |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
| @@ -42,12 +40,12 @@ | |||||||
|  |  | ||||||
| /* Although OpenRC requires C99, linking to us should not. */ | /* Although OpenRC requires C99, linking to us should not. */ | ||||||
| #ifdef restrict | #ifdef restrict | ||||||
| # define __EINFO_RESTRICT restrict | # define EINFO_RESTRICT restrict | ||||||
| #else | #else | ||||||
| # ifdef __restrict | # ifdef __restrict | ||||||
| #  define __EINFO_RESTRICT __restrict | #  define EINFO_RESTRICT __restrict | ||||||
| # else | # else | ||||||
| #  define __EINFO_RESTRICT | #  define EINFO_RESTRICT | ||||||
| # endif | # endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -68,7 +66,7 @@ typedef enum | |||||||
| const char *ecolor(ECOLOR); | const char *ecolor(ECOLOR); | ||||||
|  |  | ||||||
| /*! @brief Writes to syslog. */ | /*! @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. |  * @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. |  * The v suffix means only print if EINFO_VERBOSE is yes. | ||||||
|  */ |  */ | ||||||
| /*@{*/ | /*@{*/ | ||||||
| int einfon(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int einfon(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| int ewarnn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int ewarnn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| int eerrorn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int eerrorn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| int einfo(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int einfo(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| int ewarn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int ewarn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| void ewarnx(const char * __EINFO_RESTRICT, ...) __EINFO_XPRINTF; | void ewarnx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2); | ||||||
| int eerror(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int eerror(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| void eerrorx(const char * __EINFO_RESTRICT, ...) __EINFO_XPRINTF; | void eerrorx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2); | ||||||
|  |  | ||||||
| int einfovn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int einfovn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| int ewarnvn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int ewarnvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| int ebeginvn(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int ebeginvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| int eendvn(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF; | int eendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3); | ||||||
| int ewendvn(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF; | int ewendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3); | ||||||
| int einfov(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int einfov(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| int ewarnv(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int ewarnv(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| /*@}*/ | /*@}*/ | ||||||
|  |  | ||||||
| /*! @ingroup ebegin | /*! @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 */ |  * Similar to einfo, but we add ... to the end of the message */ | ||||||
| /*@{*/ | /*@{*/ | ||||||
| int ebeginv(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int ebeginv(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| int ebegin(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | int ebegin(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2); | ||||||
| /*@}*/ | /*@}*/ | ||||||
|  |  | ||||||
| /*! @ingroup eend | /*! @ingroup eend | ||||||
| @@ -122,12 +120,12 @@ int ebegin(const char * __EINFO_RESTRICT, ...) __EINFO_PRINTF; | |||||||
|  * |  * | ||||||
|  * ebracket allows you to specifiy the position, color and message */ |  * ebracket allows you to specifiy the position, color and message */ | ||||||
| /*@{*/ | /*@{*/ | ||||||
| int eend(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF; | int eend(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3); | ||||||
| int ewend(int, const char * __EINFO_RESTRICT, ...) __EEND_PRINTF; | int ewend(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3); | ||||||
| void ebracket(int, ECOLOR, const char * __EINFO_RESTRICT); | void ebracket(int, ECOLOR, const char * EINFO_RESTRICT); | ||||||
|  |  | ||||||
| int eendv(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, ...) __EEND_PRINTF; | int ewendv(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3); | ||||||
| /*@}*/ | /*@}*/ | ||||||
|  |  | ||||||
| /*! @ingroup eindent | /*! @ingroup eindent | ||||||
| @@ -141,7 +139,7 @@ void eindentv(void); | |||||||
| void eoutdentv(void); | void eoutdentv(void); | ||||||
|  |  | ||||||
| /*! @brief Prefix each einfo line with something */ | /*! @brief Prefix each einfo line with something */ | ||||||
| void eprefix(const char * __EINFO_RESTRICT); | void eprefix(const char * EINFO_RESTRICT); | ||||||
|  |  | ||||||
| __END_DECLS | __END_DECLS | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -199,7 +199,8 @@ static const char *const color_terms[] = { | |||||||
| /* strlcat and strlcpy are nice, shame glibc does not define them */ | /* strlcat and strlcpy are nice, shame glibc does not define them */ | ||||||
| #ifdef __GLIBC__ | #ifdef __GLIBC__ | ||||||
| #  if ! defined (__UCLIBC__) && ! defined (__dietlibc__) | #  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; | 	char *d = dst; | ||||||
| 	const char *s = src; | 	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); | 	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; | 	const char *s = src; | ||||||
| 	size_t n = size; | 	size_t n = size; | ||||||
|  |  | ||||||
| 	if (n && --n) | 	if (n && --n) | ||||||
| 		do { | 		do { | ||||||
| 			if (! (*dst++ = *src++)) | 			if (!(*dst++ = *src++)) | ||||||
| 				break; | 				break; | ||||||
| 		} while (--n); | 		} while (--n); | ||||||
|  |  | ||||||
| 	if (! n) { | 	if (!n) { | ||||||
| 		if (size) | 		if (size) | ||||||
| 			*dst = '\0'; | 			*dst = '\0'; | ||||||
| 		while (*src++); | 		while (*src++); | ||||||
| @@ -248,9 +250,10 @@ static size_t strlcpy(char *dst, const char *src, size_t size) | |||||||
| #  endif | #  endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| static bool yesno(const char *value) | static bool | ||||||
|  | yesno(const char *value) | ||||||
| { | { | ||||||
| 	if (! value) { | 	if (!value) { | ||||||
| 		errno = ENOENT; | 		errno = ENOENT; | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| @@ -272,7 +275,8 @@ static bool yesno(const char *value) | |||||||
| 	return false; | 	return false; | ||||||
| } | } | ||||||
|  |  | ||||||
| static bool noyes(const char *value) | static bool | ||||||
|  | noyes(const char *value) | ||||||
| { | { | ||||||
| 	int serrno = errno; | 	int serrno = errno; | ||||||
| 	bool retval; | 	bool retval; | ||||||
| @@ -280,50 +284,107 @@ static bool noyes(const char *value) | |||||||
| 	errno = 0; | 	errno = 0; | ||||||
| 	retval = yesno(value); | 	retval = yesno(value); | ||||||
| 	if (errno == 0) { | 	if (errno == 0) { | ||||||
| 		retval = ! retval; | 		retval = !retval; | ||||||
| 		errno = serrno; | 		errno = serrno; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| static bool is_quiet(void) | static bool | ||||||
|  | is_quiet(void) | ||||||
| { | { | ||||||
| 	return yesno(getenv("EINFO_QUIET")); | 	return yesno(getenv("EINFO_QUIET")); | ||||||
| } | } | ||||||
|  |  | ||||||
| static bool is_verbose(void) | static bool | ||||||
|  | is_verbose(void) | ||||||
| { | { | ||||||
| 	return yesno(getenv ("EINFO_VERBOSE")); | 	return yesno(getenv ("EINFO_VERBOSE")); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* Fake tgoto call - very crapy, but works for our needs */ | /* Fake tgoto call - very crapy, but works for our needs */ | ||||||
| #ifndef HAVE_TERMCAP | #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]; | 	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; | 	return buf; | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| static bool colour_terminal(FILE * __EINFO_RESTRICT f) | static bool | ||||||
|  | colour_terminal(FILE * EINFO_RESTRICT f) | ||||||
| { | { | ||||||
| 	static int in_colour = -1; | 	static int in_colour = -1; | ||||||
| 	char *e; | 	char *e, *ee, *end, *d, *p; | ||||||
| 	int c; | 	int c; | ||||||
| 	const char *_af = NULL; | 	const char *_af = NULL, *_ce = NULL, *_ch = NULL; | ||||||
| 	const char *_ce = NULL; | 	const char *_md = NULL, *_me = NULL, *_up = NULL; | ||||||
| 	const char *_ch = NULL; | 	const char *bold; | ||||||
| 	const char *_md = NULL; |  | ||||||
| 	const char *_me = NULL; |  | ||||||
| 	const char *_up = NULL; |  | ||||||
| 	char tmp[100]; | 	char tmp[100]; | ||||||
| 	char *p; |  | ||||||
| 	unsigned int i = 0; | 	unsigned int i = 0; | ||||||
|  | #ifdef HAVE_TERMCAP | ||||||
|  | 	char *bp; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| 	if (f && ! isatty(fileno(f))) | 	if (f && !isatty(fileno(f))) | ||||||
| 		return false; | 		return false; | ||||||
|  |  | ||||||
| 	if (noyes(getenv("EINFO_COLOR"))) | 	if (noyes(getenv("EINFO_COLOR"))) | ||||||
| @@ -335,26 +396,23 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f) | |||||||
| 		return true; | 		return true; | ||||||
|  |  | ||||||
| 	term_is_cons25 = false; | 	term_is_cons25 = false; | ||||||
|  | 	if (!term) { | ||||||
| 	if (! term) { |  | ||||||
| 		term = getenv("TERM"); | 		term = getenv("TERM"); | ||||||
| 		if (! term) | 		if (!term) | ||||||
| 			return false; | 			return false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (strcmp(term, "cons25") == 0) | 	if (strcmp(term, "cons25") == 0) | ||||||
| 		term_is_cons25 = true; | 		term_is_cons25 = true; | ||||||
|  |  | ||||||
| #ifdef HAVE_TERMCAP | #ifdef HAVE_TERMCAP | ||||||
| 	/* Check termcap to see if we can do colour or not */ | 	/* Check termcap to see if we can do colour or not */ | ||||||
| 	if (tgetent(termcapbuf, term) == 1) { | 	if (tgetent(termcapbuf, term) == 1) { | ||||||
| 		char *bp = tcapbuf; | 		bp = tcapbuf; | ||||||
|  |  | ||||||
| 		_af = tgetstr("AF", &bp); | 		_af = tgetstr("AF", &bp); | ||||||
| 		_ce = tgetstr("ce", &bp); | 		_ce = tgetstr("ce", &bp); | ||||||
| 		_ch = tgetstr("ch", &bp); | 		_ch = tgetstr("ch", &bp); | ||||||
| 		/* Our ch use also works with RI .... for now */ | 		/* Our ch use also works with RI .... for now */ | ||||||
| 		if (! _ch) | 		if (!_ch) | ||||||
| 			_ch = tgetstr("RI", &bp); | 			_ch = tgetstr("RI", &bp); | ||||||
| 		_md = tgetstr("md", &bp); | 		_md = tgetstr("md", &bp); | ||||||
| 		_me = tgetstr("me", &bp); | 		_me = tgetstr("me", &bp); | ||||||
| @@ -377,29 +435,29 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f) | |||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
| #endif | #endif | ||||||
| 		if (! _af) | 		if (!_af) | ||||||
| 			_af = AF; | 			_af = AF; | ||||||
| 		if (! _ce) | 		if (!_ce) | ||||||
| 			_ce = CE; | 			_ce = CE; | ||||||
| 		if (! _ch) | 		if (!_ch) | ||||||
| 			_ch = CH; | 			_ch = CH; | ||||||
| 		if (! _md) | 		if (!_md) | ||||||
| 			_md = MD; | 			_md = MD; | ||||||
| 		if (! _me) | 		if (!_me) | ||||||
| 			_me = ME; | 			_me = ME; | ||||||
| 		if (! _up) | 		if (!_up) | ||||||
| 			_up = UP; | 			_up = UP; | ||||||
| #ifdef HAVE_TERMCAP | #ifdef HAVE_TERMCAP | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (! _af || ! _ce || ! _me || !_md || ! _up) { | 	if (!_af || !_ce || !_me || !_md || !_up) { | ||||||
| 		in_colour = 0; | 		in_colour = 0; | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/* Many termcap databases don't have ch or RI even though they | 	/* Many termcap databases don't have ch or RI even though they | ||||||
| 	 * do work */ | 	 * do work */ | ||||||
| 	if (! _ch) | 	if (!_ch) | ||||||
| 		_ch = CH; | 		_ch = CH; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -407,33 +465,28 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f) | |||||||
| 	p = ebuffer; | 	p = ebuffer; | ||||||
| 	for (i = 0; i < sizeof(ecolors) / sizeof(ecolors[0]); i++) { | 	for (i = 0; i < sizeof(ecolors) / sizeof(ecolors[0]); i++) { | ||||||
| 		tmp[0] = '\0'; | 		tmp[0] = '\0'; | ||||||
|  |  | ||||||
| 		if (ecolors[i].name) { | 		if (ecolors[i].name) { | ||||||
| 			const char *bold = _md; | 			bold = _md; | ||||||
| 			c = ecolors[i].def; | 			c = ecolors[i].def; | ||||||
|  |  | ||||||
| 			/* See if the user wants to override the colour | 			/* See if the user wants to override the colour | ||||||
| 			 * We use a :col;bold: format like 2;1: for bold green | 			 * We use a :col;bold: format like 2;1: for bold green | ||||||
| 			 * and 1;0: for a normal red */ | 			 * and 1;0: for a normal red */ | ||||||
| 			if ((e = getenv("EINFO_COLOR"))) { | 			if ((e = getenv("EINFO_COLOR"))) { | ||||||
| 				char *ee = strstr(e, ecolors[i].name); | 				ee = strstr(e, ecolors[i].name); | ||||||
|  |  | ||||||
| 				if (ee) | 				if (ee) | ||||||
| 					ee += strlen(ecolors[i].name); | 					ee += strlen(ecolors[i].name); | ||||||
|  |  | ||||||
| 				if (ee && *ee == '=') { | 				if (ee && *ee == '=') { | ||||||
| 					char *d = strdup(ee + 1); | 					d = strdup(ee + 1); | ||||||
| 					if (d) { | 					if (d) { | ||||||
| 						char *end = strchr(d, ':'); | 						end = strchr(d, ':'); | ||||||
| 						if (end) | 						if (end) | ||||||
| 							*end = '\0'; | 							*end = '\0'; | ||||||
|  |  | ||||||
| 						c = atoi(d); | 						c = atoi(d); | ||||||
|  |  | ||||||
| 						end = strchr(d, ';'); | 						end = strchr(d, ';'); | ||||||
| 						if (end && *++end == '0') | 						if (end && *++end == '0') | ||||||
| 							bold = _me; | 							bold = _me; | ||||||
|  |  | ||||||
| 						free(d); | 						free(d); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| @@ -460,7 +513,8 @@ static bool colour_terminal(FILE * __EINFO_RESTRICT f) | |||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int get_term_columns(FILE * __EINFO_RESTRICT stream) | static int | ||||||
|  | get_term_columns(FILE * EINFO_RESTRICT stream) | ||||||
| { | { | ||||||
| 	struct winsize ws; | 	struct winsize ws; | ||||||
| 	char *env = getenv("COLUMNS"); | 	char *env = getenv("COLUMNS"); | ||||||
| @@ -469,7 +523,7 @@ static int get_term_columns(FILE * __EINFO_RESTRICT stream) | |||||||
|  |  | ||||||
| 	if (env) { | 	if (env) { | ||||||
| 		i = strtoimax(env, &p, 10); | 		i = strtoimax(env, &p, 10); | ||||||
| 		if (! *p) | 		if (!*p) | ||||||
| 			return i; | 			return i; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -479,13 +533,15 @@ static int get_term_columns(FILE * __EINFO_RESTRICT stream) | |||||||
| 	return DEFAULT_COLS; | 	return DEFAULT_COLS; | ||||||
| } | } | ||||||
|  |  | ||||||
| void eprefix(const char *__EINFO_RESTRICT prefix) | void | ||||||
|  | eprefix(const char *EINFO_RESTRICT prefix) | ||||||
| { | { | ||||||
| 	_eprefix = prefix; | 	_eprefix = prefix; | ||||||
| } | } | ||||||
| hidden_def(eprefix) | 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"); | 	char *e = getenv("EINFO_LOG"); | ||||||
| 	va_list apc; | 	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; | 	va_list ap; | ||||||
|  |  | ||||||
| @@ -510,7 +567,8 @@ void elog(int level, const char *__EINFO_RESTRICT fmt, ...) | |||||||
| } | } | ||||||
| hidden_def(elog) | hidden_def(elog) | ||||||
|  |  | ||||||
| static int _eindent(FILE * __EINFO_RESTRICT stream) | static int | ||||||
|  | _eindent(FILE * EINFO_RESTRICT stream) | ||||||
| { | { | ||||||
| 	char *env = getenv("EINFO_INDENT"); | 	char *env = getenv("EINFO_INDENT"); | ||||||
| 	int amount = 0; | 	int amount = 0; | ||||||
| @@ -525,7 +583,7 @@ static int _eindent(FILE * __EINFO_RESTRICT stream) | |||||||
| 			amount = INDENT_MAX; | 			amount = INDENT_MAX; | ||||||
|  |  | ||||||
| 		if (amount > 0) | 		if (amount > 0) | ||||||
| 			memset(indent, ' ', (size_t) amount); | 			memset(indent, ' ', (size_t)amount); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/* Terminate it */ | 	/* Terminate it */ | ||||||
| @@ -533,32 +591,32 @@ static int _eindent(FILE * __EINFO_RESTRICT stream) | |||||||
| 	return fprintf(stream, "%s", indent); | 	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; | 	unsigned int i; | ||||||
|  |  | ||||||
| 	if (! colour_terminal(f)) | 	if (!colour_terminal(f)) | ||||||
| 		return ""; | 		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) | 		if (ecolors[i].color == color) | ||||||
| 			return ecolors_str[i]; | 			return ecolors_str[i]; | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	return ""; | 	return ""; | ||||||
| } | } | ||||||
| hidden_def(ecolor) | hidden_def(ecolor) | ||||||
|  |  | ||||||
| const char *ecolor(ECOLOR color) | const char * | ||||||
|  | ecolor(ECOLOR color) | ||||||
| { | { | ||||||
| 	FILE *f = stdout; | 	FILE *f = stdout; | ||||||
|  |  | ||||||
| 	/* Try and guess a valid tty */ | 	/* Try and guess a valid tty */ | ||||||
| 	if (! isatty(fileno(f))) { | 	if (!isatty(fileno(f))) { | ||||||
| 		f = stderr; | 		f = stderr; | ||||||
| 		if (! isatty(fileno(f))) { | 		if (!isatty(fileno(f))) { | ||||||
| 			f = stdin; | 			f = stdin; | ||||||
| 			if (! isatty(fileno(f))) | 			if (!isatty(fileno(f))) | ||||||
| 				f = NULL; | 				f = NULL; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -571,87 +629,68 @@ const char *ecolor(ECOLOR color) | |||||||
| 	setenv("EINFO_LASTCMD", _cmd, 1); \ | 	setenv("EINFO_LASTCMD", _cmd, 1); \ | ||||||
| } | } | ||||||
|  |  | ||||||
| #define EINFOVN(_file, _color) \ | static int EINFO_PRINTF(3, 0) | ||||||
| { \ | _einfo(FILE *f, ECOLOR color, const char *EINFO_RESTRICT fmt, va_list va) | ||||||
| 	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) |  | ||||||
| { | { | ||||||
| 	int retval = 0; | 	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; | 	return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| static int _ewarnvn(const char *__EINFO_RESTRICT fmt, va_list ap) | #define _einfovn(fmt, ap) _einfo(stdout, ECOLOR_GOOD, fmt, ap) | ||||||
| { | #define _ewarnvn(fmt, ap) _einfo(stderr, ECOLOR_WARN, fmt, ap) | ||||||
| 	int retval = 0; | #define _eerrorvn(fmt, ap) _einfo(stderr, ECOLOR_BAD, fmt, ap) | ||||||
|  |  | ||||||
| 	EINFOVN(stderr, ECOLOR_WARN); | int | ||||||
| 	return retval; | einfon(const char *EINFO_RESTRICT fmt, ...) | ||||||
| } |  | ||||||
|  |  | ||||||
| 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 retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! fmt || is_quiet()) | 	if (!fmt || is_quiet()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	retval = _einfovn(fmt, ap); | 	retval = _einfovn(fmt, ap); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("einfon"); | 	LASTCMD("einfon"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(einfon) | hidden_def(einfon) | ||||||
|  |  | ||||||
| int ewarnn(const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | ewarnn(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! fmt || is_quiet()) | 	if (!fmt || is_quiet()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	retval = _ewarnvn(fmt, ap); | 	retval = _ewarnvn(fmt, ap); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("ewarnn"); | 	LASTCMD("ewarnn"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(ewarnn) | hidden_def(ewarnn) | ||||||
|  |  | ||||||
| int eerrorn(const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | eerrorn(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
| @@ -659,58 +698,53 @@ int eerrorn(const char *__EINFO_RESTRICT fmt, ...) | |||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	retval = _eerrorvn(fmt, ap); | 	retval = _eerrorvn(fmt, ap); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("errorn"); | 	LASTCMD("errorn"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(eerrorn) | hidden_def(eerrorn) | ||||||
|  |  | ||||||
| int einfo(const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | einfo(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! fmt || is_quiet()) | 	if (!fmt || is_quiet()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	retval = _einfovn(fmt, ap); | 	retval = _einfovn(fmt, ap); | ||||||
| 	retval += printf("\n"); | 	retval += printf("\n"); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("einfo"); | 	LASTCMD("einfo"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(einfo) | hidden_def(einfo) | ||||||
|  |  | ||||||
| int ewarn(const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | ewarn(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! fmt || is_quiet()) | 	if (!fmt || is_quiet()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	elogv(LOG_WARNING, fmt, ap); | 	elogv(LOG_WARNING, fmt, ap); | ||||||
| 	retval = _ewarnvn(fmt, ap); | 	retval = _ewarnvn(fmt, ap); | ||||||
| 	retval += fprintf(stderr, "\n"); | 	retval += fprintf(stderr, "\n"); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("ewarn"); | 	LASTCMD("ewarn"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(ewarn) | hidden_def(ewarn) | ||||||
|  |  | ||||||
| void ewarnx(const char *__EINFO_RESTRICT fmt, ...) | void | ||||||
|  | ewarnx(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (fmt && ! is_quiet()) { | 	if (fmt && !is_quiet()) { | ||||||
| 		va_start(ap, fmt); | 		va_start(ap, fmt); | ||||||
| 		elogv(LOG_WARNING, fmt, ap); | 		elogv(LOG_WARNING, fmt, ap); | ||||||
| 		retval = _ewarnvn(fmt, ap); | 		retval = _ewarnvn(fmt, ap); | ||||||
| @@ -721,27 +755,26 @@ void ewarnx(const char *__EINFO_RESTRICT fmt, ...) | |||||||
| } | } | ||||||
| hidden_def(ewarnx) | hidden_def(ewarnx) | ||||||
|  |  | ||||||
| int eerror(const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | eerror(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! fmt) | 	if (!fmt) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	elogv(LOG_ERR, fmt, ap); | 	elogv(LOG_ERR, fmt, ap); | ||||||
| 	retval = _eerrorvn(fmt, ap); | 	retval = _eerrorvn(fmt, ap); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
| 	retval += fprintf(stderr, "\n"); | 	retval += fprintf(stderr, "\n"); | ||||||
|  |  | ||||||
| 	LASTCMD("eerror"); | 	LASTCMD("eerror"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(eerror) | hidden_def(eerror) | ||||||
|  |  | ||||||
| void eerrorx(const char *__EINFO_RESTRICT fmt, ...) | void | ||||||
|  | eerrorx(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| @@ -752,46 +785,43 @@ void eerrorx(const char *__EINFO_RESTRICT fmt, ...) | |||||||
| 		va_end(ap); | 		va_end(ap); | ||||||
| 		fprintf(stderr, "\n"); | 		fprintf(stderr, "\n"); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	exit(EXIT_FAILURE); | 	exit(EXIT_FAILURE); | ||||||
| } | } | ||||||
| hidden_def(eerrorx) | hidden_def(eerrorx) | ||||||
|  |  | ||||||
| int ebegin(const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | ebegin(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! fmt || is_quiet()) | 	if (!fmt || is_quiet()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	retval = _einfovn(fmt, ap); | 	retval = _einfovn(fmt, ap); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
| 	retval += printf(" ..."); | 	retval += printf("..."); | ||||||
| 	if (colour_terminal(stdout)) | 	if (colour_terminal(stdout)) | ||||||
| 		retval += printf("\n"); | 		retval += printf("\n"); | ||||||
|  |  | ||||||
| 	LASTCMD("ebegin"); | 	LASTCMD("ebegin"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(ebegin) | hidden_def(ebegin) | ||||||
|  |  | ||||||
| static void _eend(FILE * __EINFO_RESTRICT fp, int col, ECOLOR color, | static void | ||||||
| 		  const char *msg) | _eend(FILE * EINFO_RESTRICT fp, int col, ECOLOR color, const char *msg) | ||||||
| { | { | ||||||
| 	int i; | 	int i; | ||||||
| 	int cols; | 	int cols; | ||||||
|  |  | ||||||
| 	if (! msg) | 	if (!msg) | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	cols = get_term_columns(fp) - (strlen(msg) + 3); | 	cols = get_term_columns(fp) - (strlen(msg) + 3); | ||||||
|  |  | ||||||
| 	/* cons25 is special - we need to remove one char, otherwise things | 	/* cons25 is special - we need to remove one char, otherwise things | ||||||
| 	 * do not align properly at all. */ | 	 * do not align properly at all. */ | ||||||
| 	if (! term) { | 	if (!term) { | ||||||
| 		term = getenv("TERM"); | 		term = getenv("TERM"); | ||||||
| 		if (term && strcmp(term, "cons25") == 0) | 		if (term && strcmp(term, "cons25") == 0) | ||||||
| 			term_is_cons25 = true; | 			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; | 	int col = 0; | ||||||
| 	FILE *fp = stdout; | 	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"); | 		col += fprintf(fp, "\n"); | ||||||
| 		va_end(apc); | 		va_end(apc); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	_eend(fp, col, | 	_eend(fp, col, | ||||||
| 	      retval == 0 ? ECOLOR_GOOD : ECOLOR_BAD, | 	      retval == 0 ? ECOLOR_GOOD : ECOLOR_BAD, | ||||||
| 	      retval == 0 ? OK : NOT_OK); | 	      retval == 0 ? OK : NOT_OK); | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| int eend(int retval, const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | eend(int retval, const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (is_quiet()) | 	if (is_quiet()) | ||||||
| 		return retval; | 		return retval; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	_do_eend("eend", retval, fmt, ap); | 	_do_eend("eend", retval, fmt, ap); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("eend"); | 	LASTCMD("eend"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(eend) | hidden_def(eend) | ||||||
|  |  | ||||||
| int ewend(int retval, const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | ewend(int retval, const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (is_quiet()) | 	if (is_quiet()) | ||||||
| 		return retval; | 		return retval; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	_do_eend("ewend", retval, fmt, ap); | 	_do_eend("ewend", retval, fmt, ap); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("ewend"); | 	LASTCMD("ewend"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(ewend) | 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); | 	_eend(stdout, col, color, msg); | ||||||
| } | } | ||||||
| hidden_def(ebracket) | hidden_def(ebracket) | ||||||
|  |  | ||||||
| void eindent(void) | void | ||||||
|  | eindent(void) | ||||||
| { | { | ||||||
| 	char *env = getenv("EINFO_INDENT"); | 	char *env = getenv("EINFO_INDENT"); | ||||||
| 	int amount = 0; | 	int amount = 0; | ||||||
| @@ -891,11 +919,9 @@ void eindent(void) | |||||||
| 		if (errno != 0) | 		if (errno != 0) | ||||||
| 			amount = 0; | 			amount = 0; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	amount += INDENT_WIDTH; | 	amount += INDENT_WIDTH; | ||||||
| 	if (amount > INDENT_MAX) | 	if (amount > INDENT_MAX) | ||||||
| 		amount = INDENT_MAX; | 		amount = INDENT_MAX; | ||||||
|  |  | ||||||
| 	snprintf(num, 10, "%08d", amount); | 	snprintf(num, 10, "%08d", amount); | ||||||
| 	setenv("EINFO_INDENT", num, 1); | 	setenv("EINFO_INDENT", num, 1); | ||||||
| } | } | ||||||
| @@ -908,16 +934,14 @@ void eoutdent(void) | |||||||
| 	char num[10]; | 	char num[10]; | ||||||
| 	int serrno = errno; | 	int serrno = errno; | ||||||
|  |  | ||||||
| 	if (! env) | 	if (!env) | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	errno = 0; | 	errno = 0; | ||||||
| 	amount = strtoimax(env, NULL, 0); | 	amount = strtoimax(env, NULL, 0); | ||||||
| 	if (errno != 0) | 	if (errno != 0) | ||||||
| 		amount = 0; | 		amount = 0; | ||||||
| 	else | 	else | ||||||
| 		amount -= INDENT_WIDTH; | 		amount -= INDENT_WIDTH; | ||||||
|  |  | ||||||
| 	if (amount <= 0) | 	if (amount <= 0) | ||||||
| 		unsetenv("EINFO_INDENT"); | 		unsetenv("EINFO_INDENT"); | ||||||
| 	else { | 	else { | ||||||
| @@ -928,143 +952,132 @@ void eoutdent(void) | |||||||
| } | } | ||||||
| hidden_def(eoutdent) | hidden_def(eoutdent) | ||||||
|  |  | ||||||
| int einfovn(const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | einfovn(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! fmt || ! is_verbose()) | 	if (!fmt || !is_verbose()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	retval = _einfovn(fmt, ap); | 	retval = _einfovn(fmt, ap); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("einfovn"); | 	LASTCMD("einfovn"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(einfovn) | hidden_def(einfovn) | ||||||
|  |  | ||||||
| int ewarnvn(const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | ewarnvn(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! fmt || ! is_verbose()) | 	if (!fmt || !is_verbose()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	retval = _ewarnvn(fmt, ap); | 	retval = _ewarnvn(fmt, ap); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("ewarnvn"); | 	LASTCMD("ewarnvn"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(ewarnvn) | hidden_def(ewarnvn) | ||||||
|  |  | ||||||
| int einfov(const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | einfov(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! fmt || ! is_verbose()) | 	if (!fmt || !is_verbose()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	retval = _einfovn(fmt, ap); | 	retval = _einfovn(fmt, ap); | ||||||
| 	retval += printf("\n"); | 	retval += printf("\n"); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("einfov"); | 	LASTCMD("einfov"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(einfov) | hidden_def(einfov) | ||||||
|  |  | ||||||
| int ewarnv(const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | ewarnv(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! fmt || ! is_verbose()) | 	if (!fmt || !is_verbose()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	retval = _ewarnvn(fmt, ap); | 	retval = _ewarnvn(fmt, ap); | ||||||
| 	retval += printf("\n"); | 	retval += printf("\n"); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("ewarnv"); | 	LASTCMD("ewarnv"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(ewarnv) | hidden_def(ewarnv) | ||||||
|  |  | ||||||
| int ebeginv(const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | ebeginv(const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	int retval; | 	int retval; | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! fmt || ! is_verbose()) | 	if (!fmt || !is_verbose()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	retval = _einfovn(fmt, ap); | 	retval = _einfovn(fmt, ap); | ||||||
| 	retval += printf(" ..."); | 	retval += printf("..."); | ||||||
| 	if (colour_terminal(stdout)) | 	if (colour_terminal(stdout)) | ||||||
| 		retval += printf("\n"); | 		retval += printf("\n"); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("ebeginv"); | 	LASTCMD("ebeginv"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(ebeginv) | hidden_def(ebeginv) | ||||||
|  |  | ||||||
| int eendv(int retval, const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | eendv(int retval, const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! is_verbose()) | 	if (!is_verbose()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	_do_eend("eendv", retval, fmt, ap); | 	_do_eend("eendv", retval, fmt, ap); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("eendv"); | 	LASTCMD("eendv"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(eendv) | hidden_def(eendv) | ||||||
|  |  | ||||||
| int ewendv(int retval, const char *__EINFO_RESTRICT fmt, ...) | int | ||||||
|  | ewendv(int retval, const char *EINFO_RESTRICT fmt, ...) | ||||||
| { | { | ||||||
| 	va_list ap; | 	va_list ap; | ||||||
|  |  | ||||||
| 	if (! is_verbose()) | 	if (!is_verbose()) | ||||||
| 		return 0; | 		return 0; | ||||||
|  |  | ||||||
| 	va_start(ap, fmt); | 	va_start(ap, fmt); | ||||||
| 	_do_eend("ewendv", retval, fmt, ap); | 	_do_eend("ewendv", retval, fmt, ap); | ||||||
| 	va_end(ap); | 	va_end(ap); | ||||||
|  |  | ||||||
| 	LASTCMD("ewendv"); | 	LASTCMD("ewendv"); | ||||||
|  |  | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| hidden_def(ewendv) | hidden_def(ewendv) | ||||||
|  |  | ||||||
| void eindentv(void) | void | ||||||
|  | eindentv(void) | ||||||
| { | { | ||||||
| 	if (is_verbose()) | 	if (is_verbose()) | ||||||
| 		eindent (); | 		eindent(); | ||||||
| } | } | ||||||
| hidden_def(eindentv) | hidden_def(eindentv) | ||||||
|  |  | ||||||
| void eoutdentv(void) | void | ||||||
|  | eoutdentv(void) | ||||||
| { | { | ||||||
| 	if (is_verbose()) | 	if (is_verbose()) | ||||||
| 		eoutdent(); | 		eoutdent(); | ||||||
|   | |||||||
							
								
								
									
										16
									
								
								src/librc/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								src/librc/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -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 |  | ||||||
| @@ -7,7 +7,7 @@ VERSION_MAP=	rc.map | |||||||
|  |  | ||||||
| LDADD+=		${LIBKVM} | LDADD+=		${LIBKVM} | ||||||
|  |  | ||||||
| CFLAGS+=	-I../includes | CPPFLAGS+=	-I../includes | ||||||
|  |  | ||||||
| MK=		../../mk | MK=		../../mk | ||||||
| include ${MK}/lib.mk | include ${MK}/lib.mk | ||||||
|   | |||||||
| @@ -40,11 +40,11 @@ static size_t strlcpy(char *dst, const char *src, size_t size) | |||||||
|  |  | ||||||
| 	if (n && --n) | 	if (n && --n) | ||||||
| 		do { | 		do { | ||||||
| 			if (! (*dst++ = *src++)) | 			if (!(*dst++ = *src++)) | ||||||
| 				break; | 				break; | ||||||
| 		} while (--n); | 		} while (--n); | ||||||
|  |  | ||||||
| 	if (! n) { | 	if (!n) { | ||||||
| 		if (size) | 		if (size) | ||||||
| 			*dst = '\0'; | 			*dst = '\0'; | ||||||
| 		while (*src++); | 		while (*src++); | ||||||
| @@ -57,21 +57,22 @@ static size_t strlcpy(char *dst, const char *src, size_t size) | |||||||
|  |  | ||||||
| #if defined(__linux__) | #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]; | 	char buffer[32]; | ||||||
| 	FILE *fp; | 	FILE *fp; | ||||||
| 	int c; | 	int c; | ||||||
| 	bool retval = false; | 	bool retval = false; | ||||||
|  |  | ||||||
|  | 	exec = basename_c(exec);  | ||||||
| 	snprintf(buffer, sizeof(buffer), "/proc/%d/stat", pid); | 	snprintf(buffer, sizeof(buffer), "/proc/%d/stat", pid); | ||||||
| 	if ((fp = fopen(buffer, "r"))) { | 	if ((fp = fopen(buffer, "r"))) { | ||||||
| 		while ((c = getc(fp)) != EOF && c != '(') | 		while ((c = getc(fp)) != EOF && c != '(') | ||||||
| 			; | 			; | ||||||
| 		if (c == '(') { | 		if (c == '(') { | ||||||
| 			while ((c = getc(fp)) != EOF && c == *cmd) | 			while ((c = getc(fp)) != EOF && c == *exec) | ||||||
| 				cmd++; | 				exec++; | ||||||
| 			if (c == ')' && *cmd == '\0') | 			if (c == ')' && *exec == '\0') | ||||||
| 				retval = true; | 				retval = true; | ||||||
| 		} | 		} | ||||||
| 		fclose(fp); | 		fclose(fp); | ||||||
| @@ -79,7 +80,7 @@ static bool pid_is_cmd(pid_t pid, const char *cmd) | |||||||
| 	return retval; | 	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]; | 	char cmdline[32]; | ||||||
| 	int fd; | 	int fd; | ||||||
| @@ -108,7 +109,7 @@ static bool pid_is_exec(pid_t pid, const char *const *argv) | |||||||
| 	return true; | 	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) | 			 uid_t uid, pid_t pid) | ||||||
| { | { | ||||||
| 	DIR *procdir; | 	DIR *procdir; | ||||||
| @@ -143,27 +144,21 @@ RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd, | |||||||
| 	while ((entry = readdir(procdir)) != NULL) { | 	while ((entry = readdir(procdir)) != NULL) { | ||||||
| 		if (sscanf(entry->d_name, "%d", &p) != 1) | 		if (sscanf(entry->d_name, "%d", &p) != 1) | ||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
| 		if (runscript_pid != 0 && runscript_pid == p) | 		if (runscript_pid != 0 && runscript_pid == p) | ||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
| 		if (pid != 0 && pid != p) | 		if (pid != 0 && pid != p) | ||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
| 		if (uid) { | 		if (uid) { | ||||||
| 			snprintf(buffer, sizeof(buffer), "/proc/%d", p); | 			snprintf(buffer, sizeof(buffer), "/proc/%d", p); | ||||||
| 			if (stat(buffer, &sb) != 0 || sb.st_uid != uid) | 			if (stat(buffer, &sb) != 0 || sb.st_uid != uid) | ||||||
| 				continue; | 				continue; | ||||||
| 		} | 		} | ||||||
|  | 		if (exec && !pid_is_exec(p, exec)) | ||||||
| 		if (cmd && ! pid_is_cmd(p, cmd)) |  | ||||||
| 			continue; | 			continue; | ||||||
|  | 		if (argv && | ||||||
| 		if (argv && ! cmd && ! | 		    !pid_is_argv(p, (const char *const *)argv)) | ||||||
| 		    pid_is_exec(p, (const char *const *)argv)) |  | ||||||
| 			continue; | 			continue; | ||||||
|  | 		if (!pids) { | ||||||
| 		if (! pids) { |  | ||||||
| 			pids = xmalloc(sizeof(*pids)); | 			pids = xmalloc(sizeof(*pids)); | ||||||
| 			LIST_INIT(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); | 		LIST_INSERT_HEAD(pids, pi, entries); | ||||||
| 	} | 	} | ||||||
| 	closedir(procdir); | 	closedir(procdir); | ||||||
|  |  | ||||||
| 	return pids; | 	return pids; | ||||||
| } | } | ||||||
| librc_hidden_def(rc_find_pids) | librc_hidden_def(rc_find_pids) | ||||||
| @@ -201,7 +195,7 @@ librc_hidden_def(rc_find_pids) | |||||||
| #  define _KVM_FLAGS O_RDONLY | #  define _KVM_FLAGS O_RDONLY | ||||||
| # endif | # 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) | 			 uid_t uid, pid_t pid) | ||||||
| { | { | ||||||
| 	static kvm_t *kd = NULL; | 	static kvm_t *kd = NULL; | ||||||
| @@ -235,39 +229,34 @@ RC_PIDLIST *rc_find_pids(const char *const *argv, const char *cmd, | |||||||
| 		return NULL; | 		return NULL; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if (exec) | ||||||
|  | 		exec = basename_c(exec); | ||||||
| 	for (i = 0; i < processes; i++) { | 	for (i = 0; i < processes; i++) { | ||||||
| 		p = _GET_KINFO_PID(kp[i]); | 		p = _GET_KINFO_PID(kp[i]); | ||||||
| 		if (pid != 0 && pid != p) | 		if (pid != 0 && pid != p) | ||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
| 		if (uid != 0 && uid != _GET_KINFO_UID(kp[i])) | 		if (uid != 0 && uid != _GET_KINFO_UID(kp[i])) | ||||||
| 			continue; | 			continue; | ||||||
|  | 		if (exec) { | ||||||
| 		if (cmd) { | 			if (!_GET_KINFO_COMM(kp[i]) || | ||||||
| 			if (! _GET_KINFO_COMM(kp[i]) || | 			    strcmp(exec, _GET_KINFO_COMM(kp[i])) != 0) | ||||||
| 			    strcmp(cmd, _GET_KINFO_COMM(kp[i])) != 0) |  | ||||||
| 				continue; | 				continue; | ||||||
| 		} | 		} | ||||||
|  | 		if (argv && *argv) { | ||||||
| 		if (argv && *argv && ! cmd) { |  | ||||||
| 			pargv = _KVM_GETARGV(kd, &kp[i], pargc); | 			pargv = _KVM_GETARGV(kd, &kp[i], pargc); | ||||||
| 			if (! pargv || ! *pargv) | 			if (!pargv || !*pargv) | ||||||
| 				continue; | 				continue; | ||||||
|  |  | ||||||
| 			arg = argv; | 			arg = argv; | ||||||
| 			match = 1; | 			match = 1; | ||||||
|  |  | ||||||
| 			while (*arg && *pargv) | 			while (*arg && *pargv) | ||||||
| 				if (strcmp(*arg++, *pargv++) != 0) { | 				if (strcmp(*arg++, *pargv++) != 0) { | ||||||
| 					match = 0; | 					match = 0; | ||||||
| 					break; | 					break; | ||||||
| 				} | 				} | ||||||
|  | 			if (!match) | ||||||
| 			if (! match) |  | ||||||
| 				continue; | 				continue; | ||||||
| 		} | 		} | ||||||
|  | 		if (!pids) { | ||||||
| 		if (! pids) { |  | ||||||
| 			pids = xmalloc(sizeof(*pids)); | 			pids = xmalloc(sizeof(*pids)); | ||||||
| 			LIST_INIT(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); | 	snprintf(ffile, sizeof(ffile), "%s/%s", path, file); | ||||||
| 	fp = fopen(ffile, "r"); | 	fp = fopen(ffile, "r"); | ||||||
|  |  | ||||||
| 	if (! fp) | 	if (!fp) | ||||||
| 		return false; | 		return false; | ||||||
|  |  | ||||||
| 	while ((rc_getline(&line, &len, fp))) { | 	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); | 				TAILQ_REMOVE(match, m, entries); | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
| 		if (! TAILQ_FIRST(match)) | 		if (!TAILQ_FIRST(match)) | ||||||
| 			break; | 			break; | ||||||
| 	} | 	} | ||||||
| 	fclose(fp); | 	fclose(fp); | ||||||
| @@ -316,14 +305,22 @@ static bool _match_daemon(const char *path, const char *file, | |||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| static RC_STRINGLIST *_match_list(const char* const* argv, | static RC_STRINGLIST *_match_list(const char *exec, const char* const* argv, | ||||||
| 				  const char *name, const char *pidfile) | 				  const char *pidfile) | ||||||
| { | { | ||||||
| 	RC_STRINGLIST *match = rc_stringlist_new(); | 	RC_STRINGLIST *match = rc_stringlist_new(); | ||||||
| 	int i = 0; | 	int i = 0; | ||||||
| 	size_t l; | 	size_t l; | ||||||
| 	char *m; | 	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]) { | 	while (argv && argv[i]) { | ||||||
| 		l = strlen(*argv) + strlen("argv_=") + 16; | 		l = strlen(*argv) + strlen("argv_=") + 16; | ||||||
| 		m = xmalloc(sizeof(char) * l); | 		m = xmalloc(sizeof(char) * l); | ||||||
| @@ -332,14 +329,6 @@ static RC_STRINGLIST *_match_list(const char* const* argv, | |||||||
| 		free(m); | 		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) { | 	if (pidfile) { | ||||||
| 		l = strlen(pidfile) + 9; | 		l = strlen(pidfile) + 9; | ||||||
| 		m = xmalloc(sizeof (char) * l); | 		m = xmalloc(sizeof (char) * l); | ||||||
| @@ -351,8 +340,9 @@ static RC_STRINGLIST *_match_list(const char* const* argv, | |||||||
| 	return match; | 	return match; | ||||||
| } | } | ||||||
|  |  | ||||||
| bool rc_service_daemon_set(const char *service, const char *const *argv, | bool rc_service_daemon_set(const char *service, const char *exec, | ||||||
| 			   const char *name, const char *pidfile, bool started) | 			   const char *const *argv, | ||||||
|  | 			   const char *pidfile, bool started) | ||||||
| { | { | ||||||
| 	char dirpath[PATH_MAX]; | 	char dirpath[PATH_MAX]; | ||||||
| 	char file[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; | 	int i = 0; | ||||||
| 	FILE *fp; | 	FILE *fp; | ||||||
|  |  | ||||||
| 	if (!(argv && *argv) && ! name && ! pidfile) { | 	if (!exec && !pidfile) { | ||||||
| 		errno = EINVAL; | 		errno = EINVAL; | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| @@ -375,7 +365,7 @@ bool rc_service_daemon_set(const char *service, const char *const *argv, | |||||||
|  |  | ||||||
| 	/* Regardless, erase any existing daemon info */ | 	/* Regardless, erase any existing daemon info */ | ||||||
| 	if ((dp = opendir(dirpath))) { | 	if ((dp = opendir(dirpath))) { | ||||||
| 		match = _match_list(argv, name, pidfile); | 		match = _match_list(exec, argv, pidfile); | ||||||
| 		while ((d = readdir(dp))) { | 		while ((d = readdir(dp))) { | ||||||
| 			if (d->d_name[0] == '.') | 			if (d->d_name[0] == '.') | ||||||
| 				continue; | 				continue; | ||||||
| @@ -384,7 +374,7 @@ bool rc_service_daemon_set(const char *service, const char *const *argv, | |||||||
| 				 dirpath, d->d_name); | 				 dirpath, d->d_name); | ||||||
| 			nfiles++; | 			nfiles++; | ||||||
|  |  | ||||||
| 			if (! *oldfile) { | 			if (!*oldfile) { | ||||||
| 				if (_match_daemon(dirpath, d->d_name, match)) { | 				if (_match_daemon(dirpath, d->d_name, match)) { | ||||||
| 					unlink(file); | 					unlink(file); | ||||||
| 					strlcpy(oldfile, file, sizeof(oldfile)); | 					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", | 			snprintf(file, sizeof(file), "%s/%03d", | ||||||
| 				 dirpath, nfiles + 1); | 				 dirpath, nfiles + 1); | ||||||
| 			if ((fp = fopen(file, "w"))) { | 			if ((fp = fopen(file, "w"))) { | ||||||
|  | 				fprintf(fp, "exec="); | ||||||
|  | 				if (exec) | ||||||
|  | 					fprintf(fp, "%s", exec); | ||||||
| 				while (argv && argv[i]) { | 				while (argv && argv[i]) { | ||||||
| 					fprintf(fp, "argv_%d=%s\n", i, argv[i]); | 					fprintf(fp, "\nargv_%d=%s", i, argv[i]); | ||||||
| 					i++; | 					i++; | ||||||
| 				} | 				} | ||||||
| 				fprintf(fp, "name="); |  | ||||||
| 				if (name) |  | ||||||
| 					fprintf(fp, "%s", name); |  | ||||||
| 				fprintf(fp, "\npidfile="); | 				fprintf(fp, "\npidfile="); | ||||||
| 				if (pidfile) | 				if (pidfile) | ||||||
| 					fprintf(fp, "%s", 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) | 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) | 			       int indx) | ||||||
| { | { | ||||||
| 	char dirpath[PATH_MAX]; | 	char dirpath[PATH_MAX]; | ||||||
| @@ -437,12 +428,12 @@ bool rc_service_started_daemon(const char *service, const char *const *argv, | |||||||
| 	DIR *dp; | 	DIR *dp; | ||||||
| 	struct dirent *d; | 	struct dirent *d; | ||||||
|  |  | ||||||
| 	if (!service || !(argv && *argv)) | 	if (!service || !exec) | ||||||
| 		return false; | 		return false; | ||||||
|  |  | ||||||
| 	snprintf(dirpath, sizeof(dirpath), RC_SVCDIR "/daemons/%s", | 	snprintf(dirpath, sizeof(dirpath), RC_SVCDIR "/daemons/%s", | ||||||
| 		 basename_c(service)); | 		 basename_c(service)); | ||||||
| 	match = _match_list(argv, NULL, NULL); | 	match = _match_list(exec, argv, NULL); | ||||||
|  |  | ||||||
| 	if (indx > 0) { | 	if (indx > 0) { | ||||||
| 		snprintf(file, sizeof(file), "%03d", indx); | 		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", | 	path += snprintf(dirpath, sizeof(dirpath), RC_SVCDIR "/daemons/%s", | ||||||
| 			 basename_c(service)); | 			 basename_c(service)); | ||||||
|  |  | ||||||
| 	if (! (dp = opendir(dirpath))) | 	if (!(dp = opendir(dirpath))) | ||||||
| 		return false; | 		return false; | ||||||
|  |  | ||||||
| 	while ((d = readdir(dp))) { | 	while ((d = readdir(dp))) { | ||||||
| @@ -502,25 +493,25 @@ bool rc_service_daemons_crashed(const char *service) | |||||||
| 		snprintf(path, sizeof(dirpath) - (path - dirpath), "/%s", | 		snprintf(path, sizeof(dirpath) - (path - dirpath), "/%s", | ||||||
| 			 d->d_name); | 			 d->d_name); | ||||||
| 		fp = fopen(dirpath, "r"); | 		fp = fopen(dirpath, "r"); | ||||||
| 		if (! fp) | 		if (!fp) | ||||||
| 			break; | 			break; | ||||||
|  |  | ||||||
| 		while ((rc_getline(&line, &len, fp))) { | 		while ((rc_getline(&line, &len, fp))) { | ||||||
| 			p = line; | 			p = line; | ||||||
| 			if ((token = strsep(&p, "=")) == NULL || ! p) | 			if ((token = strsep(&p, "=")) == NULL || !p) | ||||||
| 				continue; | 				continue; | ||||||
|  |  | ||||||
| 			if (! *p) | 			if (!*p) | ||||||
| 				continue; | 				continue; | ||||||
|  |  | ||||||
| 			if (strncmp(token, "argv_", 5) == 0) { | 			if (strcmp(token, "exec") == 0) { | ||||||
| 				if (! list) |  | ||||||
| 					list = rc_stringlist_new(); |  | ||||||
| 				rc_stringlist_add(list, p); |  | ||||||
| 			} else if (strcmp(token, "exec") == 0) { |  | ||||||
| 				if (exec) | 				if (exec) | ||||||
| 					free(exec); | 					free(exec); | ||||||
| 				exec = xstrdup(p); | 				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) { | 			} else if (strcmp(token, "name") == 0) { | ||||||
| 				if (name) | 				if (name) | ||||||
| 					free(name); | 					free(name); | ||||||
| @@ -543,14 +534,16 @@ bool rc_service_daemons_crashed(const char *service) | |||||||
| 			free(pidfile); | 			free(pidfile); | ||||||
| 			pidfile = NULL; | 			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); | 			free(name); | ||||||
| 			name = NULL; | 			name = NULL; | ||||||
| 		} else { | 		} else { | ||||||
| 			if (exec) { | 			if (exec) { | ||||||
| 				if (! list) | 				if (!list) | ||||||
| 					list = rc_stringlist_new(); | 					list = rc_stringlist_new(); | ||||||
| 				if (! TAILQ_FIRST(list)) | 				if (!TAILQ_FIRST(list)) | ||||||
| 					rc_stringlist_add(list, exec); | 					rc_stringlist_add(list, exec); | ||||||
|  |  | ||||||
| 				free(exec); | 				free(exec); | ||||||
| @@ -570,9 +563,10 @@ bool rc_service_daemons_crashed(const char *service) | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (! retval) { | 		if (!retval) { | ||||||
| 			if ((pids = rc_find_pids((const char *const *)argv, | 			if ((pids = rc_find_pids(exec, | ||||||
| 						 name, 0, pid))) | 						 (const char *const *)argv, | ||||||
|  | 						 0, pid))) | ||||||
| 			{ | 			{ | ||||||
| 				p1 = LIST_FIRST(pids); | 				p1 = LIST_FIRST(pids); | ||||||
| 				while (p1) { | 				while (p1) { | ||||||
|   | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -84,10 +84,10 @@ RC_STRINGLIST *rc_config_list(const char *file) | |||||||
| 	size_t len = 0; | 	size_t len = 0; | ||||||
| 	char *p; | 	char *p; | ||||||
| 	char *token; | 	char *token; | ||||||
| 	RC_STRINGLIST *list = NULL; | 	RC_STRINGLIST *list = rc_stringlist_new(); | ||||||
|  |  | ||||||
| 	if (!(fp = fopen(file, "r"))) | 	if (!(fp = fopen(file, "r"))) | ||||||
| 		return NULL; | 		return list; | ||||||
|  |  | ||||||
| 	while ((rc_getline(&buffer, &len, fp))) { | 	while ((rc_getline(&buffer, &len, fp))) { | ||||||
| 		p = buffer; | 		p = buffer; | ||||||
| @@ -104,8 +104,6 @@ RC_STRINGLIST *rc_config_list(const char *file) | |||||||
| 				if (token[strlen(token) - 1] == '\n') | 				if (token[strlen(token) - 1] == '\n') | ||||||
| 					token[strlen(token) - 1] = 0; | 					token[strlen(token) - 1] = 0; | ||||||
|  |  | ||||||
| 				if (!list) |  | ||||||
| 					list = rc_stringlist_new(); |  | ||||||
| 				rc_stringlist_add(list, token); | 				rc_stringlist_add(list, token); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @@ -131,17 +129,18 @@ RC_STRINGLIST *rc_config_load(const char *file) | |||||||
| 	char *p; | 	char *p; | ||||||
|  |  | ||||||
| 	list = rc_config_list(file); | 	list = rc_config_list(file); | ||||||
| 	if (!list) |  | ||||||
| 		return NULL; |  | ||||||
|  |  | ||||||
| 	config = rc_stringlist_new(); | 	config = rc_stringlist_new(); | ||||||
| 	TAILQ_FOREACH(line, list, entries) { | 	TAILQ_FOREACH(line, list, entries) { | ||||||
| 		/* Get entry */ | 		/* Get entry */ | ||||||
| 		p = line->value; | 		p = line->value; | ||||||
|  | 		if (! p) | ||||||
|  | 			continue; | ||||||
|  | 		if (strncmp(p, "export ", 7) == 0) | ||||||
|  | 			p += 7; | ||||||
| 		if (! (token = strsep(&p, "="))) | 		if (! (token = strsep(&p, "="))) | ||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
| 		entry = xstrdup (token); | 		entry = xstrdup(token); | ||||||
| 		/* Preserve shell coloring */ | 		/* Preserve shell coloring */ | ||||||
| 		if (*p == '$') | 		if (*p == '$') | ||||||
| 			token = line->value; | 			token = line->value; | ||||||
| @@ -199,9 +198,6 @@ char *rc_config_value(RC_STRINGLIST *list, const char *entry) | |||||||
| 	RC_STRING *line; | 	RC_STRING *line; | ||||||
| 	char *p; | 	char *p; | ||||||
|  |  | ||||||
| 	if (!list) |  | ||||||
| 		return NULL; |  | ||||||
|  |  | ||||||
| 	TAILQ_FOREACH(line, list, entries) { | 	TAILQ_FOREACH(line, list, entries) { | ||||||
| 		p = strchr(line->value, '='); | 		p = strchr(line->value, '='); | ||||||
| 		if (p && | 		if (p && | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user