Compare commits
	
		
			28 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					7a66bdb5b9 | ||
| 
						 | 
					670861da88 | ||
| 
						 | 
					bd4b217607 | ||
| 
						 | 
					cded32f748 | ||
| 
						 | 
					f93396793a | ||
| 
						 | 
					c79b6d4730 | ||
| 
						 | 
					3f8eb261ac | ||
| 
						 | 
					505af695d8 | ||
| 
						 | 
					f419d8b03a | ||
| 
						 | 
					fd699ddf2f | ||
| 
						 | 
					66651180a7 | ||
| 
						 | 
					7d63dc928c | ||
| 
						 | 
					8e16828bd3 | ||
| 
						 | 
					3a30710916 | ||
| 
						 | 
					290a91e8e9 | ||
| 
						 | 
					04d94be766 | ||
| 
						 | 
					fa6707e5b3 | ||
| 
						 | 
					3286a98fe6 | ||
| 
						 | 
					dc0ab571a2 | ||
| 
						 | 
					fb37e1aa96 | ||
| 
						 | 
					8769cca710 | ||
| 
						 | 
					506f2887e1 | ||
| 
						 | 
					83223a6e97 | ||
| 
						 | 
					2747f40f82 | ||
| 
						 | 
					933972da53 | ||
| 
						 | 
					dbcb8ba3fe | ||
| 
						 | 
					e462c3223e | ||
| 
						 | 
					06f195ce37 | 
							
								
								
									
										256
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										256
									
								
								ChangeLog
									
									
									
									
									
								
							@@ -1,3 +1,211 @@
 | 
			
		||||
commit 670861da88322722860eae26b3fb786928295704
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    Fix rc_env_allow wildcard usage
 | 
			
		||||
    
 | 
			
		||||
    Before this commit, using * in rc_env_allow did not work.
 | 
			
		||||
    
 | 
			
		||||
    This fixes #60.
 | 
			
		||||
 | 
			
		||||
commit bd4b217607e808139ef5ccefd77ab6182d5068c1
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    start 0.20.5
 | 
			
		||||
 | 
			
		||||
commit cded32f748fcbdb00c4d13b6bda8b799f5884065
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    update changelog
 | 
			
		||||
 | 
			
		||||
commit f93396793a384afd6d8b82744fa260dd954e0f51
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    add back deprecation warnings lost during refactoring
 | 
			
		||||
 | 
			
		||||
commit c79b6d47304e14685b3be516e203080bd77f22a4
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    fix tests
 | 
			
		||||
    
 | 
			
		||||
    X-Gentoo-Bug: 572602
 | 
			
		||||
    X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=572602
 | 
			
		||||
 | 
			
		||||
commit 3f8eb261ac46abdec3a42d4967e95d16efc3d65a
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    librc: Complain when a real and virtual service have the same name
 | 
			
		||||
 | 
			
		||||
commit 505af695d8bebdf468ada0899931554b31b4d22c
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    openrc-run: in verbose mode, log execution of the shell script
 | 
			
		||||
    
 | 
			
		||||
    This is to show when openrc-run runs the openrc-run.sh script; it is
 | 
			
		||||
    used for debugging.
 | 
			
		||||
 | 
			
		||||
commit f419d8b03aeb26739d11b79a899af2ad0a0a7b89
 | 
			
		||||
Author: Colin Booth <colin@heliocat.net>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    sh/s6.sh: update s6-svc syntax to be valid for 2.2.0.0+
 | 
			
		||||
    
 | 
			
		||||
    The s6-svc syntax changed for wait-up, wait-ready, wait-down, and
 | 
			
		||||
    wait-finished. This changes the s6 handling script to use the current
 | 
			
		||||
    valid syntax.
 | 
			
		||||
    
 | 
			
		||||
    This fixes #65.
 | 
			
		||||
 | 
			
		||||
commit fd699ddf2f266c98d7ada3409b94233eb4b23b9a
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    start 0.20.4
 | 
			
		||||
 | 
			
		||||
commit 66651180a7c9392c44f7baa4a2a11298a5f79f8a
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    update change log
 | 
			
		||||
 | 
			
		||||
commit 7d63dc928ca02dc9ab654078c5c1ed0b6bb017d9
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    localmount: Allow users to control whether errors are ignored
 | 
			
		||||
    
 | 
			
		||||
    X-Gentoo-Bug: 572138
 | 
			
		||||
    X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=572138
 | 
			
		||||
 | 
			
		||||
commit 8e16828bd3d97e6b1e40ded616a54cb8a9e7b403
 | 
			
		||||
Author: Doug Freed <dwfreed@mtu.edu>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    rc: remove use of magic constant and allow OpenVZ to drop to shell
 | 
			
		||||
    
 | 
			
		||||
    OpenVZ has had console support for a long time now; allow them to use it
 | 
			
		||||
    to drop to a shell during interactive boot.
 | 
			
		||||
 | 
			
		||||
commit 3a307109168ac82f37a9a85a81b7b527a57665e5
 | 
			
		||||
Author: Doug Freed <dwfreed@mtu.edu>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    librc: handle rc_sys="prefix" even if we weren't built with a prefix
 | 
			
		||||
    
 | 
			
		||||
    This probably isn't needed, but it mimics old behavior.
 | 
			
		||||
 | 
			
		||||
commit 290a91e8e9242582ee13c7343b630b097e2eeaf2
 | 
			
		||||
Author: Doug Freed <dwfreed@mtu.edu>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    librc: fix handling the nothing special case for rc_sys
 | 
			
		||||
 | 
			
		||||
commit 04d94be766ae2808adc709b0e4e03ce1f3a75d5d
 | 
			
		||||
Author: Doug Freed <dwfreed@mtu.edu>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    librc: move system detection code into rc_sys and use it
 | 
			
		||||
    
 | 
			
		||||
    This fixes an issue where librc code was calling code that only existed
 | 
			
		||||
    in the rc binary.
 | 
			
		||||
    
 | 
			
		||||
    This reverts commits 8addd79 and 9f6e056
 | 
			
		||||
    
 | 
			
		||||
    This fixes #75.
 | 
			
		||||
 | 
			
		||||
commit fa6707e5b33738c3416bfbad661770302aa50212
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    fix bsd build
 | 
			
		||||
    
 | 
			
		||||
    X-Gentoo-Bug: 572068
 | 
			
		||||
    X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=572068
 | 
			
		||||
 | 
			
		||||
commit 3286a98fe60d1c2617ec73ef68fc4a18f092d9da
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    start 0.20.3
 | 
			
		||||
 | 
			
		||||
commit dc0ab571a26e4c990559f4222780a26aa84bd463
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    update change log
 | 
			
		||||
 | 
			
		||||
commit fb37e1aa96df351b1bf591dc36ef332f86820a2b
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    src/rc/Makefile: fix make depend target
 | 
			
		||||
 | 
			
		||||
commit 8769cca71089983ad8a8a69cec852c6bc169248d
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    include rc.h properly in source files
 | 
			
		||||
    
 | 
			
		||||
    We were attempting to include rc.h in rc-misc.h instead of the source
 | 
			
		||||
    files where it should be included.
 | 
			
		||||
 | 
			
		||||
commit 506f2887e13eb8093bbff0915381644c4c08fc5c
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    fix selinux build
 | 
			
		||||
    
 | 
			
		||||
    X-Gentoo-Bug: 571798
 | 
			
		||||
    X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=571798
 | 
			
		||||
 | 
			
		||||
commit 83223a6e97ff2ed3a8b06c4794b55cdd1c61c657
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    version 0.20.2
 | 
			
		||||
 | 
			
		||||
commit 2747f40f823c2d31b820f0525360532287c70eea
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    update changelog
 | 
			
		||||
 | 
			
		||||
commit 933972da532bdf23accaea68bd072fc723a4065d
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    fix selinux build
 | 
			
		||||
 | 
			
		||||
commit dbcb8ba3fe2ddce1052c6e0037c47e19d7c273aa
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    Add LANG, LC_MESSAGES and TERM to the environment whitelist
 | 
			
		||||
 | 
			
		||||
commit e462c3223ec71e4567916c74b7e02ec167d91819
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    fix seg fault
 | 
			
		||||
 | 
			
		||||
commit 06f195ce37769fda1bbc2cfde13534abeb7f1176
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    increment version number
 | 
			
		||||
 | 
			
		||||
commit 04f05c30d13ec83b85164a536eb570f29a66b275
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    update ChangeLog
 | 
			
		||||
 | 
			
		||||
commit 9473ac514cb72663d5c3bac8b5473cced4a20bf7
 | 
			
		||||
Author: joe9 <joe9mail@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
@@ -1281,51 +1489,3 @@ Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
    
 | 
			
		||||
    X-Gentoo-Bug: 540006
 | 
			
		||||
    X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=540006
 | 
			
		||||
 | 
			
		||||
commit 3100114bc104741145fb6c1d4b1664759114cc5c
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    Add nfsclient to netmount use dependencies
 | 
			
		||||
    
 | 
			
		||||
    X-Gentoo-Bug: 537996
 | 
			
		||||
    X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=537996
 | 
			
		||||
 | 
			
		||||
commit 3f80f22e22ec16ed517397fd303c3df99f9340fc
 | 
			
		||||
Author: Will Miles <wmiles@sgl.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    Prioritize local includes and libraries
 | 
			
		||||
    
 | 
			
		||||
    This fixes #35.
 | 
			
		||||
 | 
			
		||||
commit 8250ac94dfc6156075081e0e2d0986cb51b3098d
 | 
			
		||||
Author: Consus <consus@gmx.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    tmpfiles.*: Follow OpenRC's message style
 | 
			
		||||
    
 | 
			
		||||
    Just to be consistent.
 | 
			
		||||
 | 
			
		||||
commit fbdd669ba7c5d1a67129236b4ffcd76198340a1b
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    Makefile: add variable for path to source tree
 | 
			
		||||
    
 | 
			
		||||
    Add a new variable, ${TOP}, to the top level makefile, which points to
 | 
			
		||||
    the path of the source tree.
 | 
			
		||||
 | 
			
		||||
commit cddb4aad08615420320f75050042d946b18d2bb5
 | 
			
		||||
Author: Will Miles <wmiles@sgl.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    Fix off-by-one error in --test argument printout in start-stop-daemon.
 | 
			
		||||
    
 | 
			
		||||
    Fixes #34.
 | 
			
		||||
 | 
			
		||||
commit 3c5dc0ec7774a72e243da43ac5180ea36a311ad8
 | 
			
		||||
Author: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
 | 
			
		||||
 | 
			
		||||
    tmpfiles.dev: pass --boot to tmpfiles.sh so kmod works properly
 | 
			
		||||
 
 | 
			
		||||
@@ -76,13 +76,3 @@ Why: The getline() function was standardized in POSIX.1-2008, so it
 | 
			
		||||
 | 
			
		||||
Who:
 | 
			
		||||
 | 
			
		||||
### rc_sys()
 | 
			
		||||
 | 
			
		||||
When: 1.0
 | 
			
		||||
 | 
			
		||||
Why: The OpenRC code now uses two internal functions, detect_container()
 | 
			
		||||
	 and detect_vm() to handle this. rc_sys() is broken because it
 | 
			
		||||
	 doesn't differentiate between containers and vm's.
 | 
			
		||||
 | 
			
		||||
Who:
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,3 @@
 | 
			
		||||
NAME=		openrc
 | 
			
		||||
VERSION=	0.20
 | 
			
		||||
VERSION=	0.20.5
 | 
			
		||||
PKG=		${NAME}-${VERSION}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,9 @@
 | 
			
		||||
# Stop the unmounting of certain points.
 | 
			
		||||
# This could be useful for some NFS related work.
 | 
			
		||||
#no_umounts="/dir1:/var/dir2"
 | 
			
		||||
#
 | 
			
		||||
# Ignore errors when mounting local file systems.
 | 
			
		||||
# This should be left alone unless you know what you are doing. If it is
 | 
			
		||||
# set to yes, not only will we allow mount failures, but we will ignore
 | 
			
		||||
# syntax errors in fstab.
 | 
			
		||||
#ignore_mount_errors="NO"
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,11 @@ start()
 | 
			
		||||
	rc=$?
 | 
			
		||||
	if [ "$RC_UNAME" != Linux ]; then
 | 
			
		||||
		rc=0
 | 
			
		||||
	elif yesno "${ignore_mount_errors:-NO}"; then
 | 
			
		||||
		if [ $rc -ne 0 ]; then
 | 
			
		||||
			ewarn "localmount: errors detected, but ignored"
 | 
			
		||||
		fi
 | 
			
		||||
		rc=0
 | 
			
		||||
	fi
 | 
			
		||||
	return $rc
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -172,9 +172,9 @@ The service will start after these services and stop before these services.
 | 
			
		||||
The service will start before these services and stop after these services.
 | 
			
		||||
.It Ic provide
 | 
			
		||||
The service provides this virtual service. For example, named provides dns.
 | 
			
		||||
Virtual services take precedence over real services, so it is highly
 | 
			
		||||
recommended that you do not have a real service that has the same name
 | 
			
		||||
as a virtual service.
 | 
			
		||||
Note that it is not legal to have a virtual and real service with the
 | 
			
		||||
same name. If you do this, you will receive an error message, and you
 | 
			
		||||
must rename either the real or virtual service.
 | 
			
		||||
.It Ic config
 | 
			
		||||
We should recalculate our dependencies if the listed files have changed.
 | 
			
		||||
.It Ic keyword
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								sh/s6.sh
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								sh/s6.sh
									
									
									
									
									
								
							@@ -41,7 +41,7 @@ s6_stop()
 | 
			
		||||
 fi
 | 
			
		||||
	s6_service_link="${RC_SVCDIR}/s6-scan/${s6_service_path##*/}"
 | 
			
		||||
	ebegin "Stopping ${name:-$RC_SVCNAME}"
 | 
			
		||||
	s6-svc -Dd -T ${s6_service_timeout_stop:-10000} "${s6_service_link}"
 | 
			
		||||
	s6-svc -wD -d -T ${s6_service_timeout_stop:-10000} "${s6_service_link}"
 | 
			
		||||
	set -- $(s6-svstat "${s6_service_link}")
 | 
			
		||||
	[ "$1" = "down" ]
 | 
			
		||||
	eend $? "Failed to stop $RC_SVCNAME"
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,6 @@
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
#include "helpers.h"
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
 | 
			
		||||
#define RC_LEVEL_BOOT           "boot"
 | 
			
		||||
#define RC_LEVEL_DEFAULT        "default"
 | 
			
		||||
@@ -61,10 +60,6 @@ int is_writable(const char *);
 | 
			
		||||
#define service_stop(service)  exec_service(service, "stop");
 | 
			
		||||
 | 
			
		||||
int parse_mode(mode_t *, char *);
 | 
			
		||||
const char *detect_prefix(void);
 | 
			
		||||
const char *get_systype(void);
 | 
			
		||||
const char *detect_container(void);
 | 
			
		||||
const char *detect_vm(void);
 | 
			
		||||
 | 
			
		||||
/* Handy function so we can wrap einfo around our deptree */
 | 
			
		||||
RC_DEPTREE *_rc_deptree_load (int, int *);
 | 
			
		||||
 
 | 
			
		||||
@@ -717,14 +717,16 @@ rc_deptree_update_needed(time_t *newest, char *file)
 | 
			
		||||
}
 | 
			
		||||
librc_hidden_def(rc_deptree_update_needed)
 | 
			
		||||
 | 
			
		||||
/* This is a 6 phase operation
 | 
			
		||||
/* This is a 7 phase operation
 | 
			
		||||
   Phase 1 is a shell script which loads each init script and config in turn
 | 
			
		||||
   and echos their dependency info to stdout
 | 
			
		||||
   Phase 2 takes that and populates a depinfo object with that data
 | 
			
		||||
   Phase 3 adds any provided services to the depinfo object
 | 
			
		||||
   Phase 4 scans that depinfo object and puts in backlinks
 | 
			
		||||
   Phase 5 removes broken before dependencies
 | 
			
		||||
   Phase 6 saves the depinfo object to disk
 | 
			
		||||
   Phase 6 looks for duplicate services indicating a real and virtual service
 | 
			
		||||
   with the same names
 | 
			
		||||
   Phase 7 saves the depinfo object to disk
 | 
			
		||||
   */
 | 
			
		||||
bool
 | 
			
		||||
rc_deptree_update(void)
 | 
			
		||||
@@ -733,15 +735,16 @@ rc_deptree_update(void)
 | 
			
		||||
	RC_DEPTREE *deptree, *providers;
 | 
			
		||||
	RC_DEPINFO *depinfo = NULL, *depinfo_np, *di;
 | 
			
		||||
	RC_DEPTYPE *deptype = NULL, *dt_np, *dt, *provide;
 | 
			
		||||
	RC_STRINGLIST *config, *types, *sorted, *visited;
 | 
			
		||||
	RC_STRINGLIST *config, *dupes, *types, *sorted, *visited;
 | 
			
		||||
	RC_STRING *s, *s2, *s2_np, *s3, *s4;
 | 
			
		||||
	char *line = NULL;
 | 
			
		||||
	size_t len = 0;
 | 
			
		||||
	char *depend, *depends, *service, *type, *nosys, *onosys;
 | 
			
		||||
	size_t i, k, l;
 | 
			
		||||
	bool retval = true;
 | 
			
		||||
	const char *sys = NULL;
 | 
			
		||||
	const char *sys = rc_sys();
 | 
			
		||||
	struct utsname uts;
 | 
			
		||||
	int serrno;
 | 
			
		||||
 | 
			
		||||
	/* Some init scripts need RC_LIBEXECDIR to source stuff
 | 
			
		||||
	   Ideally we should be setting our full env instead */
 | 
			
		||||
@@ -847,9 +850,6 @@ rc_deptree_update(void)
 | 
			
		||||
 | 
			
		||||
	/* Phase 2 - if we're a special system, remove services that don't
 | 
			
		||||
	 * work for them. This doesn't stop them from being run directly. */
 | 
			
		||||
	sys = detect_container();
 | 
			
		||||
		if (!sys)
 | 
			
		||||
			sys = detect_vm();
 | 
			
		||||
	if (sys) {
 | 
			
		||||
		len = strlen(sys);
 | 
			
		||||
		nosys = xmalloc(len + 2);
 | 
			
		||||
@@ -999,7 +999,22 @@ rc_deptree_update(void)
 | 
			
		||||
	}
 | 
			
		||||
	rc_stringlist_free(types);
 | 
			
		||||
 | 
			
		||||
	/* Phase 6 - save to disk
 | 
			
		||||
	/* Phase 6 - Print errors for duplicate services */
 | 
			
		||||
	dupes = rc_stringlist_new();
 | 
			
		||||
	TAILQ_FOREACH(depinfo, deptree, entries) {
 | 
			
		||||
		serrno = errno;
 | 
			
		||||
		errno = 0;
 | 
			
		||||
		rc_stringlist_addu(dupes,depinfo->service);
 | 
			
		||||
		if (errno == EEXIST) {
 | 
			
		||||
			fprintf(stderr,
 | 
			
		||||
					"Error: %s is the name of a real and virtual service.\n",
 | 
			
		||||
					depinfo->service);
 | 
			
		||||
		}
 | 
			
		||||
		errno = serrno;
 | 
			
		||||
	}
 | 
			
		||||
	rc_stringlist_free(dupes);
 | 
			
		||||
 | 
			
		||||
	/* Phase 7 - save to disk
 | 
			
		||||
	   Now that we're purely in C, do we need to keep a shell parseable file?
 | 
			
		||||
	   I think yes as then it stays human readable
 | 
			
		||||
	   This works and should be entirely shell parseable provided that depend
 | 
			
		||||
 
 | 
			
		||||
@@ -198,13 +198,9 @@ found:
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const char *
 | 
			
		||||
rc_sys(void)
 | 
			
		||||
static const char *
 | 
			
		||||
get_systype(void)
 | 
			
		||||
{
 | 
			
		||||
#ifdef PREFIX
 | 
			
		||||
	return RC_SYS_PREFIX;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	char *systype = rc_conf_value("rc_sys");
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		char *s = systype;
 | 
			
		||||
@@ -215,10 +211,37 @@ rc_sys(void)
 | 
			
		||||
			s++;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return systype;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const char *
 | 
			
		||||
detect_prefix(const char *systype)
 | 
			
		||||
{
 | 
			
		||||
#ifdef PREFIX
 | 
			
		||||
	return RC_SYS_PREFIX;
 | 
			
		||||
#else
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_NONE) == 0)
 | 
			
		||||
			return NULL;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_PREFIX) == 0)
 | 
			
		||||
			return RC_SYS_PREFIX;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const char *
 | 
			
		||||
detect_container(const char *systype)
 | 
			
		||||
{
 | 
			
		||||
#ifdef __FreeBSD__
 | 
			
		||||
	if (systype && strcmp(systype, RC_SYS_JAIL) == 0)
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_NONE) == 0)
 | 
			
		||||
		       return NULL;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_JAIL) == 0)
 | 
			
		||||
			return RC_SYS_JAIL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	int jailed = 0;
 | 
			
		||||
	size_t len = sizeof(jailed);
 | 
			
		||||
 | 
			
		||||
@@ -227,25 +250,10 @@ rc_sys(void)
 | 
			
		||||
			return RC_SYS_JAIL;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __NetBSD__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if(strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
				return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/kern/xen/privcmd"))
 | 
			
		||||
		return RC_SYS_XEN0;
 | 
			
		||||
	if (exists("/kern/xen"))
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_NONE) == 0)
 | 
			
		||||
			return NULL;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_UML) == 0)
 | 
			
		||||
			return RC_SYS_UML;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_VSERVER) == 0)
 | 
			
		||||
@@ -261,11 +269,7 @@ rc_sys(void)
 | 
			
		||||
		if (strcmp(systype, RC_SYS_DOCKER) == 0)
 | 
			
		||||
				return RC_SYS_DOCKER;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/proc/xen")) {
 | 
			
		||||
		if (file_regex("/proc/xen/capabilities", "control_d"))
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
	} else if (file_regex("/proc/cpuinfo", "UML"))
 | 
			
		||||
	if (file_regex("/proc/cpuinfo", "UML"))
 | 
			
		||||
		return RC_SYS_UML;
 | 
			
		||||
	else if (file_regex("/proc/self/status",
 | 
			
		||||
		"(s_context|VxID):[[:space:]]*[1-9]"))
 | 
			
		||||
@@ -287,6 +291,61 @@ rc_sys(void)
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const char *
 | 
			
		||||
detect_vm(const char *systype)
 | 
			
		||||
{
 | 
			
		||||
#ifdef __NetBSD__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_NONE) == 0)
 | 
			
		||||
			return NULL;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/kern/xen/privcmd"))
 | 
			
		||||
		return RC_SYS_XEN0;
 | 
			
		||||
	if (exists("/kern/xen"))
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_NONE) == 0)
 | 
			
		||||
			return NULL;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/proc/xen")) {
 | 
			
		||||
		if (file_regex("/proc/xen/capabilities", "control_d"))
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *
 | 
			
		||||
rc_sys(void)
 | 
			
		||||
{
 | 
			
		||||
	const char *systype;
 | 
			
		||||
	const char *sys;
 | 
			
		||||
 | 
			
		||||
	systype = get_systype();
 | 
			
		||||
	sys = detect_prefix(systype);
 | 
			
		||||
	if (!sys) {
 | 
			
		||||
		sys = detect_container(systype);
 | 
			
		||||
		if (!sys) {
 | 
			
		||||
			sys = detect_vm(systype);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return sys;
 | 
			
		||||
}
 | 
			
		||||
librc_hidden_def(rc_sys)
 | 
			
		||||
 | 
			
		||||
static const char *
 | 
			
		||||
 
 | 
			
		||||
@@ -318,6 +318,7 @@ bool rc_service_daemons_crashed(const char *);
 | 
			
		||||
 * Some services cannot work in these systems, or we do something else. */
 | 
			
		||||
#define RC_SYS_DOCKER  "DOCKER"
 | 
			
		||||
#define RC_SYS_JAIL    "JAIL"
 | 
			
		||||
#define RC_SYS_NONE    ""
 | 
			
		||||
#define RC_SYS_OPENVZ  "OPENVZ"
 | 
			
		||||
#define RC_SYS_LXC     "LXC"
 | 
			
		||||
#define RC_SYS_PREFIX  "PREFIX"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,9 @@
 | 
			
		||||
SRCS=	rc.c 	rc-logger.c rc-misc.c rc-plugin.c
 | 
			
		||||
SRCS=	checkpath.c do_e.c do_mark_service.c do_service.c \
 | 
			
		||||
		do_value.c fstabinfo.c is_newer_than.c is_older_than.c \
 | 
			
		||||
		mountinfo.c openrc-run.c rc-abort.c rc.c \
 | 
			
		||||
		rc-depend.c rc-logger.c rc-misc.c rc-plugin.c \
 | 
			
		||||
		rc-service.c rc-status.c rc-update.c \
 | 
			
		||||
		shell_var.c start-stop-daemon.c swclock.c _usage.c
 | 
			
		||||
 | 
			
		||||
ifeq (${MKSELINUX},yes)
 | 
			
		||||
SRCS+=		rc-selinux.c
 | 
			
		||||
@@ -75,7 +80,10 @@ check test::
 | 
			
		||||
 | 
			
		||||
all: ${ALL_PROGS}
 | 
			
		||||
 | 
			
		||||
checkpath: checkpath.o _usage.o rc-misc.o rc-selinux.o
 | 
			
		||||
checkpath: checkpath.o _usage.o rc-misc.o
 | 
			
		||||
ifeq (${MKSELINUX},yes)
 | 
			
		||||
checkpath: rc-selinux.o
 | 
			
		||||
endif
 | 
			
		||||
	${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
 | 
			
		||||
 | 
			
		||||
einfon einfo ewarnn ewarn eerrorn eerror ebegin eend ewend \
 | 
			
		||||
@@ -101,10 +109,13 @@ mark_service_hotplugged mark_service_failed: do_mark_service.o rc-misc.o
 | 
			
		||||
mountinfo: mountinfo.o _usage.o rc-misc.o
 | 
			
		||||
	${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
 | 
			
		||||
 | 
			
		||||
openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o rc-selinux.o _usage.o
 | 
			
		||||
openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o _usage.o
 | 
			
		||||
	${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
 | 
			
		||||
 | 
			
		||||
openrc-run runscript: openrc-run.o _usage.o rc-misc.o rc-plugin.o
 | 
			
		||||
ifeq (${MKSELINUX},yes)
 | 
			
		||||
openrc-run runscript: rc-selinux.o
 | 
			
		||||
endif
 | 
			
		||||
	${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
 | 
			
		||||
 | 
			
		||||
rc-abort: rc-abort.o
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
#include "_usage.h"
 | 
			
		||||
#include "version.h"
 | 
			
		||||
@@ -46,10 +47,7 @@ _noreturn void show_version(void)
 | 
			
		||||
	const char *systype = NULL;
 | 
			
		||||
 | 
			
		||||
	printf("%s (OpenRC", applet);
 | 
			
		||||
	systype = detect_container();
 | 
			
		||||
	if (!systype)
 | 
			
		||||
		systype = detect_vm();
 | 
			
		||||
	if (systype)
 | 
			
		||||
	if ((systype = rc_sys()))
 | 
			
		||||
		printf(" [%s]", systype);
 | 
			
		||||
	printf(") %s", VERSION);
 | 
			
		||||
#ifdef BRANDING
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
#include "einfo.h"
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
#include "rc-selinux.h"
 | 
			
		||||
#include "_usage.h"
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,7 @@
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
#include "einfo.h"
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
 | 
			
		||||
const char *applet = NULL;
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,7 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,7 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
 
 | 
			
		||||
@@ -390,6 +390,14 @@ svc_exec(const char *arg1, const char *arg2)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (exists(RC_SVCDIR "/openrc-run.sh")) {
 | 
			
		||||
			if (arg2)
 | 
			
		||||
				einfov("Executing: %s %s %s %s %s",
 | 
			
		||||
					RC_SVCDIR "/openrc-run.sh", RC_SVCDIR "/openrc-run.sh",
 | 
			
		||||
					service, arg1, arg2);
 | 
			
		||||
			else
 | 
			
		||||
				einfov("Executing: %s %s %s %s",
 | 
			
		||||
					RC_SVCDIR "/openrc-run.sh", RC_SVCDIR "/openrc-run.sh",
 | 
			
		||||
					service, arg1);
 | 
			
		||||
			execl(RC_SVCDIR "/openrc-run.sh",
 | 
			
		||||
			    RC_SVCDIR "/openrc-run.sh",
 | 
			
		||||
			    service, arg1, arg2, (char *) NULL);
 | 
			
		||||
@@ -397,6 +405,16 @@ svc_exec(const char *arg1, const char *arg2)
 | 
			
		||||
			    service, strerror(errno));
 | 
			
		||||
			_exit(EXIT_FAILURE);
 | 
			
		||||
		} else {
 | 
			
		||||
			if (arg2)
 | 
			
		||||
				einfov("Executing: %s %s %s %s %s",
 | 
			
		||||
					RC_LIBEXECDIR "/sh/openrc-run.sh",
 | 
			
		||||
					RC_LIBEXECDIR "/sh/openrc-run.sh",
 | 
			
		||||
			    	service, arg1, arg2);
 | 
			
		||||
			else
 | 
			
		||||
				einfov("Executing: %s %s %s %s",
 | 
			
		||||
					RC_LIBEXECDIR "/sh/openrc-run.sh",
 | 
			
		||||
					RC_LIBEXECDIR "/sh/openrc-run.sh",
 | 
			
		||||
			    	service, arg1);
 | 
			
		||||
			execl(RC_LIBEXECDIR "/sh/openrc-run.sh",
 | 
			
		||||
			    RC_LIBEXECDIR "/sh/openrc-run.sh",
 | 
			
		||||
			    service, arg1, arg2, (char *) NULL);
 | 
			
		||||
@@ -1103,6 +1121,10 @@ int main(int argc, char **argv)
 | 
			
		||||
		exit(EXIT_FAILURE);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	applet = basename_c(argv[0]);
 | 
			
		||||
	if (strcmp(applet, "runscript") == 0)
 | 
			
		||||
		ewarnv("runscript is deprecated, please use openrc-run instead.");
 | 
			
		||||
 | 
			
		||||
	if (stat(argv[1], &stbuf) != 0) {
 | 
			
		||||
		fprintf(stderr, "openrc-run `%s': %s\n",
 | 
			
		||||
		    argv[1], strerror(errno));
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										171
									
								
								src/rc/rc-misc.c
									
									
									
									
									
								
							
							
						
						
									
										171
									
								
								src/rc/rc-misc.c
									
									
									
									
									
								
							@@ -27,7 +27,6 @@
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#include <limits.h>
 | 
			
		||||
#  include <regex.h>
 | 
			
		||||
#include <signal.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
@@ -53,6 +52,7 @@ rc_conf_yesno(const char *setting)
 | 
			
		||||
static const char *const env_whitelist[] = {
 | 
			
		||||
	"EERROR_QUIET", "EINFO_QUIET",
 | 
			
		||||
	"IN_BACKGROUND", "IN_HOTPLUG",
 | 
			
		||||
	"LANG", "LC_MESSAGES", "TERM",
 | 
			
		||||
	NULL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -68,6 +68,12 @@ env_filter(void)
 | 
			
		||||
 | 
			
		||||
	/* Add the user defined list of vars */
 | 
			
		||||
	env_allow = rc_stringlist_split(rc_conf_value("rc_env_allow"), " ");
 | 
			
		||||
	/*
 | 
			
		||||
	 * If '*' is an entry in rc_env_allow, do nothing as we are to pass
 | 
			
		||||
	 * through all environment variables.
 | 
			
		||||
	 */
 | 
			
		||||
	if (rc_stringlist_find(env_allow, "*"))
 | 
			
		||||
		return;
 | 
			
		||||
	profile = rc_config_load(RC_PROFILE_ENV);
 | 
			
		||||
 | 
			
		||||
	/* Copy the env and work from this so we can manipulate it safely */
 | 
			
		||||
@@ -125,7 +131,7 @@ env_config(void)
 | 
			
		||||
	char *np;
 | 
			
		||||
	char *npp;
 | 
			
		||||
	char *tok;
 | 
			
		||||
	const char *sys = NULL;
 | 
			
		||||
	const char *sys = rc_sys();
 | 
			
		||||
	char buffer[PATH_MAX];
 | 
			
		||||
 | 
			
		||||
	/* Ensure our PATH is prefixed with the system locations first
 | 
			
		||||
@@ -176,9 +182,7 @@ env_config(void)
 | 
			
		||||
	} else
 | 
			
		||||
		setenv("RC_DEFAULTLEVEL", RC_LEVEL_DEFAULT, 1);
 | 
			
		||||
 | 
			
		||||
	sys = detect_container();
 | 
			
		||||
	if (!sys)
 | 
			
		||||
		sys = detect_vm();
 | 
			
		||||
	if (sys)
 | 
			
		||||
		setenv("RC_SYS", sys, 1);
 | 
			
		||||
 | 
			
		||||
#ifdef PREFIX
 | 
			
		||||
@@ -335,163 +339,6 @@ is_writable(const char *path)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static bool file_regex(const char *file, const char *regex)
 | 
			
		||||
{
 | 
			
		||||
	FILE *fp;
 | 
			
		||||
	char *line = NULL;
 | 
			
		||||
	size_t len = 0;
 | 
			
		||||
	regex_t re;
 | 
			
		||||
	bool retval = true;
 | 
			
		||||
	int result;
 | 
			
		||||
 | 
			
		||||
	if (!(fp = fopen(file, "r")))
 | 
			
		||||
		return false;
 | 
			
		||||
 | 
			
		||||
	if ((result = regcomp(&re, regex, REG_EXTENDED | REG_NOSUB)) != 0) {
 | 
			
		||||
		fclose(fp);
 | 
			
		||||
		line = xmalloc(sizeof(char) * BUFSIZ);
 | 
			
		||||
		regerror(result, &re, line, BUFSIZ);
 | 
			
		||||
		fprintf(stderr, "file_regex: %s", line);
 | 
			
		||||
		free(line);
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while ((rc_getline(&line, &len, fp))) {
 | 
			
		||||
		char *str = line;
 | 
			
		||||
		/* some /proc files have \0 separated content so we have to
 | 
			
		||||
		   loop through the 'line' */
 | 
			
		||||
		do {
 | 
			
		||||
			if (regexec(&re, str, 0, NULL, 0) == 0)
 | 
			
		||||
				goto found;
 | 
			
		||||
			str += strlen(str) + 1;
 | 
			
		||||
			/* len is the size of allocated buffer and we don't
 | 
			
		||||
			   want call regexec BUFSIZE times. find next str */
 | 
			
		||||
			while (str < line + len && *str == '\0')
 | 
			
		||||
				str++;
 | 
			
		||||
		} while (str < line + len);
 | 
			
		||||
	}
 | 
			
		||||
	retval = false;
 | 
			
		||||
found:
 | 
			
		||||
	fclose(fp);
 | 
			
		||||
	free(line);
 | 
			
		||||
	regfree(&re);
 | 
			
		||||
 | 
			
		||||
	return retval;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *detect_prefix(void)
 | 
			
		||||
{
 | 
			
		||||
#ifdef PREFIX
 | 
			
		||||
	return RC_SYS_PREFIX;
 | 
			
		||||
#else
 | 
			
		||||
	return NULL;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *get_systype(void)
 | 
			
		||||
{
 | 
			
		||||
	char *systype = rc_conf_value("rc_sys");
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		char *s = systype;
 | 
			
		||||
		/* Convert to uppercase */
 | 
			
		||||
		while (s && *s) {
 | 
			
		||||
			if (islower((unsigned char) *s))
 | 
			
		||||
				*s = toupper((unsigned char) *s);
 | 
			
		||||
			s++;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return systype;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *detect_container(void)
 | 
			
		||||
{
 | 
			
		||||
	const char *systype = get_systype();
 | 
			
		||||
 | 
			
		||||
#ifdef __FreeBSD__
 | 
			
		||||
	if (systype && strcmp(systype, RC_SYS_JAIL) == 0)
 | 
			
		||||
		return RC_SYS_JAIL;
 | 
			
		||||
	int jailed = 0;
 | 
			
		||||
	size_t len = sizeof(jailed);
 | 
			
		||||
 | 
			
		||||
	if (sysctlbyname("security.jail.jailed", &jailed, &len, NULL, 0) == 0)
 | 
			
		||||
		if (jailed == 1)
 | 
			
		||||
			return RC_SYS_JAIL;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_UML) == 0)
 | 
			
		||||
			return RC_SYS_UML;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_VSERVER) == 0)
 | 
			
		||||
			return RC_SYS_VSERVER;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_OPENVZ) == 0)
 | 
			
		||||
			return RC_SYS_OPENVZ;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_LXC) == 0)
 | 
			
		||||
			return RC_SYS_LXC;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_RKT) == 0)
 | 
			
		||||
				return RC_SYS_RKT;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_SYSTEMD_NSPAWN) == 0)
 | 
			
		||||
				return RC_SYS_SYSTEMD_NSPAWN;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_DOCKER) == 0)
 | 
			
		||||
				return RC_SYS_DOCKER;
 | 
			
		||||
	}
 | 
			
		||||
	if (file_regex("/proc/cpuinfo", "UML"))
 | 
			
		||||
		return RC_SYS_UML;
 | 
			
		||||
	else if (file_regex("/proc/self/status",
 | 
			
		||||
		"(s_context|VxID):[[:space:]]*[1-9]"))
 | 
			
		||||
		return RC_SYS_VSERVER;
 | 
			
		||||
	else if (exists("/proc/vz/veinfo") && !exists("/proc/vz/version"))
 | 
			
		||||
		return RC_SYS_OPENVZ;
 | 
			
		||||
	else if (file_regex("/proc/self/status",
 | 
			
		||||
		"envID:[[:space:]]*[1-9]"))
 | 
			
		||||
		return RC_SYS_OPENVZ; /* old test */
 | 
			
		||||
	else if (file_regex("/proc/1/environ", "container=lxc"))
 | 
			
		||||
		return RC_SYS_LXC;
 | 
			
		||||
	else if (file_regex("/proc/1/environ", "container=rkt"))
 | 
			
		||||
		return RC_SYS_RKT;
 | 
			
		||||
	else if (file_regex("/proc/1/environ", "container=systemd-nspawn"))
 | 
			
		||||
		return RC_SYS_SYSTEMD_NSPAWN;
 | 
			
		||||
	else if (file_regex("/proc/1/environ", "container=docker"))
 | 
			
		||||
		return RC_SYS_DOCKER;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *detect_vm(void)
 | 
			
		||||
{
 | 
			
		||||
	const char *systype = get_systype();
 | 
			
		||||
 | 
			
		||||
#ifdef __NetBSD__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if(strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
				return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/kern/xen/privcmd"))
 | 
			
		||||
		return RC_SYS_XEN0;
 | 
			
		||||
	if (exists("/kern/xen"))
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	if (systype) {
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XEN0) == 0)
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		if (strcmp(systype, RC_SYS_XENU) == 0)
 | 
			
		||||
			return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
	if (exists("/proc/xen")) {
 | 
			
		||||
		if (file_regex("/proc/xen/capabilities", "control_d"))
 | 
			
		||||
			return RC_SYS_XEN0;
 | 
			
		||||
		return RC_SYS_XENU;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
RC_DEPTREE * _rc_deptree_load(int force, int *regen)
 | 
			
		||||
{
 | 
			
		||||
	int fd;
 | 
			
		||||
 
 | 
			
		||||
@@ -15,8 +15,6 @@
 | 
			
		||||
 *    except according to the terms contained in the LICENSE file.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifdef HAVE_SELINUX
 | 
			
		||||
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <dlfcn.h>
 | 
			
		||||
@@ -386,5 +384,3 @@ out:
 | 
			
		||||
	free(run_init_t);
 | 
			
		||||
	free(curr_t);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -25,10 +25,10 @@ void selinux_setup(char **argv);
 | 
			
		||||
 | 
			
		||||
/* always return false for selinux_util_open() */
 | 
			
		||||
#define selinux_util_open() (0)
 | 
			
		||||
#define selinux_util_label(x) do { } while(0)
 | 
			
		||||
#define selinux_util_close() do { } while(0)
 | 
			
		||||
#define selinux_util_label(x) do { } while (0)
 | 
			
		||||
#define selinux_util_close() do { } while (0)
 | 
			
		||||
 | 
			
		||||
#define selinux_setup(x) do { } while(0)
 | 
			
		||||
#define selinux_setup(x) do { } while (0)
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								src/rc/rc.c
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								src/rc/rc.c
									
									
									
									
									
								
							@@ -281,15 +281,10 @@ open_shell(void)
 | 
			
		||||
	struct passwd *pw;
 | 
			
		||||
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	const char *sys = NULL;
 | 
			
		||||
	const char *sys = rc_sys();
 | 
			
		||||
 | 
			
		||||
	sys = detect_container();
 | 
			
		||||
	if (!sys)
 | 
			
		||||
		sys = detect_vm();
 | 
			
		||||
 | 
			
		||||
	/* VSERVER and OPENVZ systems cannot really drop to shells */
 | 
			
		||||
	if (sys &&
 | 
			
		||||
	    (strcmp(sys, "VSERVER") == 0 || strcmp(sys, "OPENVZ") == 0))
 | 
			
		||||
	/* VSERVER systems cannot really drop to shells */
 | 
			
		||||
	if (sys && strcmp(sys, RC_SYS_VSERVER) == 0)
 | 
			
		||||
	{
 | 
			
		||||
		execl("/sbin/halt", "/sbin/halt", "-f", (char *) NULL);
 | 
			
		||||
		eerrorx("%s: unable to exec `/sbin/halt': %s",
 | 
			
		||||
@@ -491,10 +486,7 @@ do_sysinit()
 | 
			
		||||
	    uts.machine);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	sys = detect_container();
 | 
			
		||||
	if (!sys)
 | 
			
		||||
		sys = detect_vm();
 | 
			
		||||
	if (sys)
 | 
			
		||||
	if ((sys = rc_sys()))
 | 
			
		||||
		printf(" [%s]", sys);
 | 
			
		||||
 | 
			
		||||
	printf("%s\n\n", ecolor(ECOLOR_NORMAL));
 | 
			
		||||
@@ -509,10 +501,7 @@ do_sysinit()
 | 
			
		||||
 | 
			
		||||
	/* init may have mounted /proc so we can now detect or real
 | 
			
		||||
	 * sys */
 | 
			
		||||
	sys = detect_container();
 | 
			
		||||
	if (!sys)
 | 
			
		||||
		sys = detect_vm();
 | 
			
		||||
	if (sys)
 | 
			
		||||
	if ((sys = rc_sys()))
 | 
			
		||||
		setenv("RC_SYS", sys, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -832,9 +821,7 @@ int main(int argc, char **argv)
 | 
			
		||||
			eerrorx("%s: %s", applet, strerror(errno));
 | 
			
		||||
			/* NOTREACHED */
 | 
			
		||||
		case 'S':
 | 
			
		||||
			systype = detect_container();
 | 
			
		||||
			if (!systype)
 | 
			
		||||
				systype = detect_vm();
 | 
			
		||||
			systype = rc_sys();
 | 
			
		||||
			if (systype)
 | 
			
		||||
				printf("%s\n", systype);
 | 
			
		||||
			exit(EXIT_SUCCESS);
 | 
			
		||||
@@ -843,6 +830,8 @@ int main(int argc, char **argv)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (strcmp(applet, "rc") == 0)
 | 
			
		||||
		ewarnv("rc is deprecated, please use openrc instead.");
 | 
			
		||||
	newlevel = argv[optind++];
 | 
			
		||||
	/* To make life easier, we only have the shutdown runlevel as
 | 
			
		||||
	 * nothing really needs to know that we're rebooting.
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@
 | 
			
		||||
#include <utime.h>
 | 
			
		||||
 | 
			
		||||
#include "einfo.h"
 | 
			
		||||
#include "rc.h"
 | 
			
		||||
#include "rc-misc.h"
 | 
			
		||||
#include "_usage.h"
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -85,12 +85,14 @@ eend $? "Trailing newlines need to be deleted:"$'\n'"${out}"
 | 
			
		||||
 | 
			
		||||
ebegin "Checking for obsolete functions"
 | 
			
		||||
out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
 | 
			
		||||
	! -name queue.h \
 | 
			
		||||
	-exec grep -n -E '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' {} +)
 | 
			
		||||
[ -z "${out}" ]
 | 
			
		||||
eend $? "Avoid these obsolete functions:"$'\n'"${out}"
 | 
			
		||||
 | 
			
		||||
ebegin "Checking for x* func usage"
 | 
			
		||||
out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
 | 
			
		||||
	! -name queue.h \
 | 
			
		||||
	-exec grep -n -E '\<(malloc|strdup)[[:space:]]*\(' {} + \
 | 
			
		||||
	| grep -v \
 | 
			
		||||
		-e src/includes/helpers.h \
 | 
			
		||||
@@ -100,6 +102,7 @@ eend $? "These need to be using the x* variant:"$'\n'"${out}"
 | 
			
		||||
 | 
			
		||||
ebegin "Checking spacing style"
 | 
			
		||||
out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
 | 
			
		||||
	! -name queue.h \
 | 
			
		||||
	-exec grep -n -E \
 | 
			
		||||
		-e '\<(for|if|switch|while)\(' \
 | 
			
		||||
		-e '\<(for|if|switch|while) \( ' \
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,3 @@ LD_LIBRARY_PATH=${top_builddir}/src/libeinfo:${top_builddir}/src/librc:${LD_LIBR
 | 
			
		||||
PATH=${top_builddir}/src/rc:${PATH}
 | 
			
		||||
export LD_LIBRARY_PATH PATH
 | 
			
		||||
 | 
			
		||||
cd ${top_srcdir}/src/rc
 | 
			
		||||
${MAKE:-make} links >/dev/null
 | 
			
		||||
cd -
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user